From e599318e912d8836c59d8b5202e3e31a6b8dcae9 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 9 Oct 2013 22:52:54 +0200 Subject: Update files to match FreeBSD layout Add compatibility with Newlib header files. Some FreeBSD header files are mapped by the translation script: o rtems/bsd/sys/_types.h o rtems/bsd/sys/errno.h o rtems/bsd/sys/lock.h o rtems/bsd/sys/param.h o rtems/bsd/sys/resource.h o rtems/bsd/sys/time.h o rtems/bsd/sys/timespec.h o rtems/bsd/sys/types.h o rtems/bsd/sys/unistd.h It is now possible to include directly for example. Generate one Makefile which builds everything including tests. --- freebsd/sys/_iovec.h | 58 -- freebsd/sys/_null.h | 45 -- freebsd/sys/_pthreadtypes.h | 1 - freebsd/sys/arm/arm/in_cksum.c | 163 ++++- freebsd/sys/arm/arm/legacy.c | 347 +++++++++ freebsd/sys/arm/include/machine/cpufunc.h | 14 +- freebsd/sys/arm/include/machine/in_cksum.h | 63 +- freebsd/sys/arm/include/machine/legacyvar.h | 6 +- freebsd/sys/arm/pci/pci_bus.c | 38 +- freebsd/sys/avr/avr/in_cksum.c | 255 +++++++ freebsd/sys/avr/avr/legacy.c | 347 +++++++++ freebsd/sys/avr/include/machine/in_cksum.h | 93 +-- freebsd/sys/avr/include/machine/legacyvar.h | 57 ++ freebsd/sys/avr/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/avr/pci/pci_bus.c | 754 +++++++++++++++++-- freebsd/sys/bfin/bfin/in_cksum.c | 255 +++++++ freebsd/sys/bfin/bfin/legacy.c | 347 +++++++++ freebsd/sys/bfin/include/machine/in_cksum.h | 8 +- freebsd/sys/bfin/include/machine/legacyvar.h | 57 ++ freebsd/sys/bfin/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/bfin/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/bsm/audit.h | 6 +- freebsd/sys/bsm/audit_kevents.h | 6 +- freebsd/sys/cam/ata/ata_all.h | 2 +- freebsd/sys/cam/cam.c | 32 +- freebsd/sys/cam/cam.h | 6 +- freebsd/sys/cam/cam_ccb.h | 16 +- freebsd/sys/cam/cam_periph.h | 6 +- freebsd/sys/cam/cam_xpt_sim.h | 4 +- freebsd/sys/cam/scsi/scsi_all.c | 40 +- freebsd/sys/cam/scsi/scsi_all.h | 2 +- freebsd/sys/cam/scsi/scsi_da.h | 2 +- freebsd/sys/contrib/altq/altq/altq.h | 16 +- freebsd/sys/contrib/altq/altq/altq_cbq.c | 40 +- freebsd/sys/contrib/altq/altq/altq_cbq.h | 14 +- freebsd/sys/contrib/altq/altq/altq_cdnr.c | 48 +- freebsd/sys/contrib/altq/altq/altq_cdnr.h | 8 +- freebsd/sys/contrib/altq/altq/altq_classq.h | 6 +- freebsd/sys/contrib/altq/altq/altq_hfsc.c | 40 +- freebsd/sys/contrib/altq/altq/altq_hfsc.h | 14 +- freebsd/sys/contrib/altq/altq/altq_priq.c | 44 +- freebsd/sys/contrib/altq/altq/altq_priq.h | 14 +- freebsd/sys/contrib/altq/altq/altq_red.c | 50 +- freebsd/sys/contrib/altq/altq/altq_red.h | 8 +- freebsd/sys/contrib/altq/altq/altq_rio.c | 48 +- freebsd/sys/contrib/altq/altq/altq_rio.h | 8 +- freebsd/sys/contrib/altq/altq/altq_rmclass.c | 42 +- freebsd/sys/contrib/altq/altq/altq_rmclass.h | 8 +- freebsd/sys/contrib/altq/altq/altq_rmclass_debug.h | 6 +- freebsd/sys/contrib/altq/altq/altq_subr.c | 78 +- freebsd/sys/contrib/altq/altq/altq_var.h | 16 +- freebsd/sys/contrib/altq/altq/altqconf.h | 4 +- freebsd/sys/contrib/altq/altq/if_altq.h | 14 +- freebsd/sys/contrib/pf/net/if_pflog.c | 66 +- freebsd/sys/contrib/pf/net/if_pflog.h | 6 +- freebsd/sys/contrib/pf/net/if_pfsync.c | 90 +-- freebsd/sys/contrib/pf/net/if_pfsync.h | 6 +- freebsd/sys/contrib/pf/net/pf.c | 128 ++-- freebsd/sys/contrib/pf/net/pf_if.c | 48 +- freebsd/sys/contrib/pf/net/pf_ioctl.c | 110 +-- freebsd/sys/contrib/pf/net/pf_mtag.h | 6 +- freebsd/sys/contrib/pf/net/pf_norm.c | 68 +- freebsd/sys/contrib/pf/net/pf_osfp.c | 42 +- freebsd/sys/contrib/pf/net/pf_ruleset.c | 38 +- freebsd/sys/contrib/pf/net/pf_subr.c | 66 +- freebsd/sys/contrib/pf/net/pf_table.c | 34 +- freebsd/sys/contrib/pf/net/pfvar.h | 36 +- freebsd/sys/contrib/pf/netinet/in4_cksum.c | 18 +- freebsd/sys/crypto/blowfish/bf_ecb.c | 10 +- freebsd/sys/crypto/blowfish/bf_enc.c | 10 +- freebsd/sys/crypto/blowfish/bf_skey.c | 16 +- freebsd/sys/crypto/camellia/camellia-api.c | 10 +- freebsd/sys/crypto/camellia/camellia.c | 16 +- freebsd/sys/crypto/des/des_ecb.c | 12 +- freebsd/sys/crypto/des/des_enc.c | 8 +- freebsd/sys/crypto/des/des_locl.h | 2 +- freebsd/sys/crypto/des/des_setkey.c | 14 +- freebsd/sys/crypto/rc4/rc4.c | 14 +- freebsd/sys/crypto/rc4/rc4.h | 4 +- freebsd/sys/crypto/rijndael/rijndael-alg-fst.c | 18 +- freebsd/sys/crypto/rijndael/rijndael-api-fst.c | 14 +- freebsd/sys/crypto/rijndael/rijndael-api-fst.h | 2 +- freebsd/sys/crypto/rijndael/rijndael-api.c | 10 +- freebsd/sys/crypto/sha1.c | 14 +- freebsd/sys/crypto/sha1.h | 6 +- freebsd/sys/crypto/sha2/sha2.c | 16 +- freebsd/sys/crypto/sha2/sha2.h | 2 +- freebsd/sys/dev/bce/if_bce.c | 10 +- freebsd/sys/dev/bce/if_bcereg.h | 92 +-- freebsd/sys/dev/bfe/if_bfe.c | 66 +- freebsd/sys/dev/bge/if_bge.c | 96 +-- freebsd/sys/dev/dc/dcphy.c | 46 +- freebsd/sys/dev/dc/if_dc.c | 74 +- freebsd/sys/dev/dc/pnphy.c | 44 +- freebsd/sys/dev/e1000/e1000_80003es2lan.c | 6 +- freebsd/sys/dev/e1000/e1000_80003es2lan.h | 4 +- freebsd/sys/dev/e1000/e1000_82540.c | 6 +- freebsd/sys/dev/e1000/e1000_82541.c | 6 +- freebsd/sys/dev/e1000/e1000_82541.h | 4 +- freebsd/sys/dev/e1000/e1000_82542.c | 6 +- freebsd/sys/dev/e1000/e1000_82543.c | 6 +- freebsd/sys/dev/e1000/e1000_82543.h | 4 +- freebsd/sys/dev/e1000/e1000_82571.c | 6 +- freebsd/sys/dev/e1000/e1000_82571.h | 4 +- freebsd/sys/dev/e1000/e1000_82575.c | 6 +- freebsd/sys/dev/e1000/e1000_82575.h | 6 +- freebsd/sys/dev/e1000/e1000_api.c | 6 +- freebsd/sys/dev/e1000/e1000_api.h | 8 +- freebsd/sys/dev/e1000/e1000_defines.h | 6 +- freebsd/sys/dev/e1000/e1000_hw.h | 60 +- freebsd/sys/dev/e1000/e1000_ich8lan.c | 6 +- freebsd/sys/dev/e1000/e1000_ich8lan.h | 4 +- freebsd/sys/dev/e1000/e1000_mac.c | 6 +- freebsd/sys/dev/e1000/e1000_mac.h | 4 +- freebsd/sys/dev/e1000/e1000_manage.c | 6 +- freebsd/sys/dev/e1000/e1000_manage.h | 4 +- freebsd/sys/dev/e1000/e1000_mbx.c | 6 +- freebsd/sys/dev/e1000/e1000_mbx.h | 10 +- freebsd/sys/dev/e1000/e1000_nvm.c | 6 +- freebsd/sys/dev/e1000/e1000_nvm.h | 4 +- freebsd/sys/dev/e1000/e1000_osdep.c | 6 +- freebsd/sys/dev/e1000/e1000_osdep.h | 46 +- freebsd/sys/dev/e1000/e1000_phy.c | 6 +- freebsd/sys/dev/e1000/e1000_phy.h | 4 +- freebsd/sys/dev/e1000/e1000_regs.h | 4 +- freebsd/sys/dev/e1000/e1000_vf.c | 6 +- freebsd/sys/dev/e1000/e1000_vf.h | 22 +- freebsd/sys/dev/e1000/if_em.c | 100 +-- freebsd/sys/dev/e1000/if_igb.c | 110 +-- freebsd/sys/dev/e1000/if_lem.c | 94 +-- freebsd/sys/dev/fxp/if_fxp.c | 92 +-- freebsd/sys/dev/led/led.c | 28 +- freebsd/sys/dev/mii/brgphy.c | 44 +- freebsd/sys/dev/mii/brgphyreg.h | 6 +- freebsd/sys/dev/mii/icsphy.c | 30 +- freebsd/sys/dev/mii/icsphyreg.h | 6 +- freebsd/sys/dev/mii/mii.c | 28 +- freebsd/sys/dev/mii/mii.h | 6 +- freebsd/sys/dev/mii/mii_physubr.c | 28 +- freebsd/sys/dev/mii/miivar.h | 8 +- freebsd/sys/dev/pci/pci.c | 78 +- freebsd/sys/dev/pci/pci_pci.c | 30 +- freebsd/sys/dev/pci/pci_private.h | 6 +- freebsd/sys/dev/pci/pci_user.c | 58 +- freebsd/sys/dev/pci/pcivar.h | 16 +- freebsd/sys/dev/random/harvest.c | 34 +- freebsd/sys/dev/re/if_re.c | 80 +-- freebsd/sys/dev/smc/if_smc.c | 78 +- freebsd/sys/dev/smc/if_smcreg.h | 6 +- freebsd/sys/dev/smc/if_smcvar.h | 6 +- freebsd/sys/dev/usb/controller/ehci.c | 74 +- freebsd/sys/dev/usb/controller/ehci.h | 6 +- freebsd/sys/dev/usb/controller/ehcireg.h | 6 +- freebsd/sys/dev/usb/controller/ohci.c | 74 +- freebsd/sys/dev/usb/controller/ohci.h | 6 +- freebsd/sys/dev/usb/controller/ohcireg.h | 6 +- freebsd/sys/dev/usb/controller/usb_controller.c | 68 +- freebsd/sys/dev/usb/quirk/usb_quirk.c | 56 +- freebsd/sys/dev/usb/quirk/usb_quirk.h | 6 +- freebsd/sys/dev/usb/storage/umass.c | 74 +- freebsd/sys/dev/usb/ufm_ioctl.h | 2 +- freebsd/sys/dev/usb/usb.h | 14 +- freebsd/sys/dev/usb/usb_bus.h | 6 +- freebsd/sys/dev/usb/usb_busdma.c | 66 +- freebsd/sys/dev/usb/usb_busdma.h | 12 +- freebsd/sys/dev/usb/usb_cdc.h | 6 +- freebsd/sys/dev/usb/usb_controller.h | 6 +- freebsd/sys/dev/usb/usb_core.c | 44 +- freebsd/sys/dev/usb/usb_core.h | 6 +- freebsd/sys/dev/usb/usb_debug.c | 66 +- freebsd/sys/dev/usb/usb_debug.h | 6 +- freebsd/sys/dev/usb/usb_dev.c | 92 +-- freebsd/sys/dev/usb/usb_dev.h | 16 +- freebsd/sys/dev/usb/usb_device.c | 94 +-- freebsd/sys/dev/usb/usb_device.h | 6 +- freebsd/sys/dev/usb/usb_dynamic.c | 56 +- freebsd/sys/dev/usb/usb_dynamic.h | 6 +- freebsd/sys/dev/usb/usb_endian.h | 10 +- freebsd/sys/dev/usb/usb_error.c | 44 +- freebsd/sys/dev/usb/usb_freebsd.h | 6 +- freebsd/sys/dev/usb/usb_generic.c | 84 +-- freebsd/sys/dev/usb/usb_generic.h | 6 +- freebsd/sys/dev/usb/usb_handle_request.c | 72 +- freebsd/sys/dev/usb/usb_hid.c | 62 +- freebsd/sys/dev/usb/usb_hub.c | 76 +- freebsd/sys/dev/usb/usb_hub.h | 6 +- freebsd/sys/dev/usb/usb_ioctl.h | 12 +- freebsd/sys/dev/usb/usb_lookup.c | 44 +- freebsd/sys/dev/usb/usb_mbuf.c | 48 +- freebsd/sys/dev/usb/usb_mbuf.h | 6 +- freebsd/sys/dev/usb/usb_msctest.c | 68 +- freebsd/sys/dev/usb/usb_msctest.h | 6 +- freebsd/sys/dev/usb/usb_parse.c | 48 +- freebsd/sys/dev/usb/usb_process.c | 62 +- freebsd/sys/dev/usb/usb_process.h | 8 +- freebsd/sys/dev/usb/usb_request.c | 78 +- freebsd/sys/dev/usb/usb_request.h | 6 +- freebsd/sys/dev/usb/usb_transfer.c | 68 +- freebsd/sys/dev/usb/usb_transfer.h | 6 +- freebsd/sys/dev/usb/usb_util.c | 68 +- freebsd/sys/dev/usb/usb_util.h | 6 +- freebsd/sys/dev/usb/usbdi.h | 8 +- freebsd/sys/dev/usb/usbdi_util.h | 6 +- freebsd/sys/dev/usb/usbhid.h | 8 +- freebsd/sys/fs/devfs/devfs_int.h | 8 +- freebsd/sys/h8300/h8300/in_cksum.c | 255 +++++++ freebsd/sys/h8300/h8300/legacy.c | 347 +++++++++ freebsd/sys/h8300/include/machine/in_cksum.h | 27 +- freebsd/sys/h8300/include/machine/legacyvar.h | 57 ++ freebsd/sys/h8300/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/h8300/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/i386/i386/in_cksum.c | 18 +- freebsd/sys/i386/i386/legacy.c | 34 +- freebsd/sys/i386/include/machine/cpufunc.h | 8 +- freebsd/sys/i386/include/machine/in_cksum.h | 193 +++-- freebsd/sys/i386/include/machine/legacyvar.h | 57 ++ freebsd/sys/i386/include/machine/md_var.h | 6 +- freebsd/sys/i386/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/i386/include/machine/specialreg.h | 6 +- freebsd/sys/i386/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/ioccom.h | 80 --- freebsd/sys/isa/isavar.h | 12 +- freebsd/sys/isa/pnpvar.h | 6 +- freebsd/sys/kern/init_main.c | 92 +-- freebsd/sys/kern/kern_descrip.c | 216 +++--- freebsd/sys/kern/kern_environment.c | 36 +- freebsd/sys/kern/kern_event.c | 72 +- freebsd/sys/kern/kern_intr.c | 68 +- freebsd/sys/kern/kern_linker.c | 66 +- freebsd/sys/kern/kern_mbuf.c | 50 +- freebsd/sys/kern/kern_mib.c | 46 +- freebsd/sys/kern/kern_module.c | 44 +- freebsd/sys/kern/kern_mtxpool.c | 20 +- freebsd/sys/kern/kern_ntptime.c | 44 +- freebsd/sys/kern/kern_proc.c | 92 +-- freebsd/sys/kern/kern_prot.c | 110 +-- freebsd/sys/kern/kern_resource.c | 72 +- freebsd/sys/kern/kern_subr.c | 48 +- freebsd/sys/kern/kern_sysctl.c | 48 +- freebsd/sys/kern/kern_tc.c | 22 +- freebsd/sys/kern/kern_time.c | 76 +- freebsd/sys/kern/kern_timeout.c | 40 +- freebsd/sys/kern/subr_bufring.c | 16 +- freebsd/sys/kern/subr_bus.c | 62 +- freebsd/sys/kern/subr_eventhandler.c | 20 +- freebsd/sys/kern/subr_hints.c | 14 +- freebsd/sys/kern/subr_kobj.c | 22 +- freebsd/sys/kern/subr_module.c | 10 +- freebsd/sys/kern/subr_rman.c | 30 +- freebsd/sys/kern/subr_sbuf.c | 30 +- freebsd/sys/kern/subr_unit.c | 28 +- freebsd/sys/kern/sys_generic.c | 86 ++- freebsd/sys/kern/uipc_accf.c | 34 +- freebsd/sys/kern/uipc_domain.c | 34 +- freebsd/sys/kern/uipc_mbuf.c | 34 +- freebsd/sys/kern/uipc_mbuf2.c | 20 +- freebsd/sys/kern/uipc_sockbuf.c | 36 +- freebsd/sys/kern/uipc_socket.c | 98 +-- freebsd/sys/libkern/arc4random.c | 20 +- freebsd/sys/libkern/fls.c | 6 +- freebsd/sys/libkern/inet_ntoa.c | 10 +- freebsd/sys/libkern/random.c | 6 +- freebsd/sys/lm32/include/machine/in_cksum.h | 77 ++ freebsd/sys/lm32/include/machine/legacyvar.h | 57 ++ freebsd/sys/lm32/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/lm32/lm32/in_cksum.c | 255 +++++++ freebsd/sys/lm32/lm32/legacy.c | 347 +++++++++ freebsd/sys/lm32/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/m32c/include/machine/in_cksum.h | 77 ++ freebsd/sys/m32c/include/machine/legacyvar.h | 57 ++ freebsd/sys/m32c/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/m32c/m32c/in_cksum.c | 255 +++++++ freebsd/sys/m32c/m32c/legacy.c | 347 +++++++++ freebsd/sys/m32c/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/m32r/include/machine/in_cksum.h | 77 ++ freebsd/sys/m32r/include/machine/legacyvar.h | 57 ++ freebsd/sys/m32r/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/m32r/m32r/in_cksum.c | 255 +++++++ freebsd/sys/m32r/m32r/legacy.c | 347 +++++++++ freebsd/sys/m32r/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/m68k/include/machine/in_cksum.h | 77 ++ freebsd/sys/m68k/include/machine/legacyvar.h | 57 ++ freebsd/sys/m68k/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/m68k/m68k/in_cksum.c | 255 +++++++ freebsd/sys/m68k/m68k/legacy.c | 347 +++++++++ freebsd/sys/m68k/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/mips/include/machine/cpufunc.h | 10 +- freebsd/sys/mips/include/machine/cpuregs.h | 12 +- freebsd/sys/mips/include/machine/in_cksum.h | 77 ++ freebsd/sys/mips/include/machine/legacyvar.h | 57 ++ freebsd/sys/mips/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/mips/mips/in_cksum.c | 18 +- freebsd/sys/mips/mips/legacy.c | 347 +++++++++ freebsd/sys/mips/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/mman.h | 238 ------ freebsd/sys/net/bpf.c | 90 +-- freebsd/sys/net/bpf.h | 6 +- freebsd/sys/net/bpf_buffer.c | 28 +- freebsd/sys/net/bpf_buffer.h | 6 +- freebsd/sys/net/bpf_filter.c | 14 +- freebsd/sys/net/bpf_jitter.c | 26 +- freebsd/sys/net/bpf_jitter.h | 6 +- freebsd/sys/net/bpf_zerocopy.h | 6 +- freebsd/sys/net/bpfdesc.h | 14 +- freebsd/sys/net/bridgestp.c | 54 +- freebsd/sys/net/bridgestp.h | 4 +- freebsd/sys/net/ethernet.h | 407 ++++++++++- freebsd/sys/net/fddi.h | 6 +- freebsd/sys/net/firewire.h | 6 +- freebsd/sys/net/flowtable.h | 4 +- freebsd/sys/net/ieee8023ad_lacp.c | 44 +- freebsd/sys/net/if.c | 102 +-- freebsd/sys/net/if.h | 472 +++++++++++- freebsd/sys/net/if_arc.h | 6 +- freebsd/sys/net/if_arcsubr.c | 68 +- freebsd/sys/net/if_arp.h | 140 +++- freebsd/sys/net/if_atmsubr.c | 60 +- freebsd/sys/net/if_bridge.c | 106 +-- freebsd/sys/net/if_bridgevar.h | 6 +- freebsd/sys/net/if_clone.c | 38 +- freebsd/sys/net/if_clone.h | 6 +- freebsd/sys/net/if_dead.c | 14 +- freebsd/sys/net/if_disc.c | 36 +- freebsd/sys/net/if_dl.h | 84 ++- freebsd/sys/net/if_edsc.c | 32 +- freebsd/sys/net/if_ef.c | 58 +- freebsd/sys/net/if_enc.c | 66 +- freebsd/sys/net/if_epair.c | 44 +- freebsd/sys/net/if_ethersubr.c | 98 +-- freebsd/sys/net/if_faith.c | 64 +- freebsd/sys/net/if_fddisubr.c | 74 +- freebsd/sys/net/if_fwsubr.c | 54 +- freebsd/sys/net/if_gif.c | 96 +-- freebsd/sys/net/if_gif.h | 12 +- freebsd/sys/net/if_gre.c | 66 +- freebsd/sys/net/if_gre.h | 4 +- freebsd/sys/net/if_iso88025subr.c | 66 +- freebsd/sys/net/if_lagg.c | 82 +-- freebsd/sys/net/if_llatbl.c | 60 +- freebsd/sys/net/if_llatbl.h | 12 +- freebsd/sys/net/if_llc.h | 6 +- freebsd/sys/net/if_loop.c | 68 +- freebsd/sys/net/if_media.c | 20 +- freebsd/sys/net/if_media.h | 8 +- freebsd/sys/net/if_mib.c | 18 +- freebsd/sys/net/if_sppp.h | 6 +- freebsd/sys/net/if_spppfr.c | 68 +- freebsd/sys/net/if_spppsubr.c | 66 +- freebsd/sys/net/if_stf.c | 92 +-- freebsd/sys/net/if_stf.h | 6 +- freebsd/sys/net/if_tap.c | 74 +- freebsd/sys/net/if_tap.h | 6 +- freebsd/sys/net/if_tapvar.h | 6 +- freebsd/sys/net/if_tun.c | 82 +-- freebsd/sys/net/if_tun.h | 6 +- freebsd/sys/net/if_types.h | 256 ++++++- freebsd/sys/net/if_var.h | 30 +- freebsd/sys/net/if_vlan.c | 50 +- freebsd/sys/net/if_vlan_var.h | 6 +- freebsd/sys/net/iso88025.h | 4 +- freebsd/sys/net/netisr.c | 52 +- freebsd/sys/net/netisr.h | 6 +- freebsd/sys/net/pfil.c | 34 +- freebsd/sys/net/pfil.h | 18 +- freebsd/sys/net/pfkeyv2.h | 6 +- freebsd/sys/net/ppp_defs.h | 6 +- freebsd/sys/net/radix.c | 30 +- freebsd/sys/net/radix.h | 12 +- freebsd/sys/net/radix_mpath.c | 32 +- freebsd/sys/net/radix_mpath.h | 6 +- freebsd/sys/net/raw_cb.c | 30 +- freebsd/sys/net/raw_cb.h | 6 +- freebsd/sys/net/raw_usrreq.c | 36 +- freebsd/sys/net/route.c | 58 +- freebsd/sys/net/route.h | 448 +++++++++++- freebsd/sys/net/rtsock.c | 76 +- freebsd/sys/net/slcompress.c | 18 +- freebsd/sys/net/slcompress.h | 6 +- freebsd/sys/net/vnet.h | 20 +- freebsd/sys/net/zlib.c | 90 +-- freebsd/sys/net/zlib.h | 2 +- freebsd/sys/net80211/_ieee80211.h | 6 +- freebsd/sys/net80211/ieee80211.c | 34 +- freebsd/sys/net80211/ieee80211.h | 6 +- freebsd/sys/net80211/ieee80211_acl.c | 30 +- freebsd/sys/net80211/ieee80211_action.c | 28 +- freebsd/sys/net80211/ieee80211_action.h | 6 +- freebsd/sys/net80211/ieee80211_adhoc.c | 60 +- freebsd/sys/net80211/ieee80211_adhoc.h | 6 +- freebsd/sys/net80211/ieee80211_ageq.c | 22 +- freebsd/sys/net80211/ieee80211_ageq.h | 6 +- freebsd/sys/net80211/ieee80211_amrr.c | 30 +- freebsd/sys/net80211/ieee80211_amrr.h | 6 +- freebsd/sys/net80211/ieee80211_crypto.c | 24 +- freebsd/sys/net80211/ieee80211_crypto.h | 6 +- freebsd/sys/net80211/ieee80211_crypto_ccmp.c | 30 +- freebsd/sys/net80211/ieee80211_crypto_none.c | 26 +- freebsd/sys/net80211/ieee80211_crypto_tkip.c | 30 +- freebsd/sys/net80211/ieee80211_crypto_wep.c | 30 +- freebsd/sys/net80211/ieee80211_ddb.c | 42 +- freebsd/sys/net80211/ieee80211_dfs.c | 44 +- freebsd/sys/net80211/ieee80211_dfs.h | 6 +- freebsd/sys/net80211/ieee80211_freebsd.c | 56 +- freebsd/sys/net80211/ieee80211_freebsd.h | 20 +- freebsd/sys/net80211/ieee80211_hostap.c | 60 +- freebsd/sys/net80211/ieee80211_hostap.h | 6 +- freebsd/sys/net80211/ieee80211_ht.c | 30 +- freebsd/sys/net80211/ieee80211_ht.h | 6 +- freebsd/sys/net80211/ieee80211_hwmp.c | 58 +- freebsd/sys/net80211/ieee80211_input.c | 46 +- freebsd/sys/net80211/ieee80211_input.h | 6 +- freebsd/sys/net80211/ieee80211_ioctl.c | 50 +- freebsd/sys/net80211/ieee80211_ioctl.h | 12 +- freebsd/sys/net80211/ieee80211_mesh.c | 54 +- freebsd/sys/net80211/ieee80211_mesh.h | 6 +- freebsd/sys/net80211/ieee80211_monitor.c | 54 +- freebsd/sys/net80211/ieee80211_monitor.h | 6 +- freebsd/sys/net80211/ieee80211_node.c | 40 +- freebsd/sys/net80211/ieee80211_node.h | 10 +- freebsd/sys/net80211/ieee80211_output.c | 60 +- freebsd/sys/net80211/ieee80211_phy.c | 22 +- freebsd/sys/net80211/ieee80211_phy.h | 6 +- freebsd/sys/net80211/ieee80211_power.c | 24 +- freebsd/sys/net80211/ieee80211_power.h | 6 +- freebsd/sys/net80211/ieee80211_proto.c | 40 +- freebsd/sys/net80211/ieee80211_proto.h | 6 +- freebsd/sys/net80211/ieee80211_radiotap.c | 32 +- freebsd/sys/net80211/ieee80211_radiotap.h | 6 +- freebsd/sys/net80211/ieee80211_ratectl.c | 20 +- freebsd/sys/net80211/ieee80211_ratectl_none.c | 28 +- freebsd/sys/net80211/ieee80211_regdomain.c | 22 +- freebsd/sys/net80211/ieee80211_regdomain.h | 6 +- freebsd/sys/net80211/ieee80211_rssadapt.c | 24 +- freebsd/sys/net80211/ieee80211_rssadapt.h | 6 +- freebsd/sys/net80211/ieee80211_scan.c | 28 +- freebsd/sys/net80211/ieee80211_scan.h | 6 +- freebsd/sys/net80211/ieee80211_scan_sta.c | 34 +- freebsd/sys/net80211/ieee80211_sta.c | 60 +- freebsd/sys/net80211/ieee80211_sta.h | 6 +- freebsd/sys/net80211/ieee80211_superg.c | 38 +- freebsd/sys/net80211/ieee80211_superg.h | 6 +- freebsd/sys/net80211/ieee80211_tdma.c | 58 +- freebsd/sys/net80211/ieee80211_tdma.h | 6 +- freebsd/sys/net80211/ieee80211_var.h | 36 +- freebsd/sys/net80211/ieee80211_wds.c | 58 +- freebsd/sys/net80211/ieee80211_wds.h | 6 +- freebsd/sys/net80211/ieee80211_xauth.c | 28 +- freebsd/sys/netatalk/aarp.c | 36 +- freebsd/sys/netatalk/aarp.h | 6 +- freebsd/sys/netatalk/at.h | 88 ++- freebsd/sys/netatalk/at_control.c | 36 +- freebsd/sys/netatalk/at_extern.h | 6 +- freebsd/sys/netatalk/at_proto.c | 20 +- freebsd/sys/netatalk/at_rmx.c | 10 +- freebsd/sys/netatalk/at_var.h | 6 +- freebsd/sys/netatalk/ddp.h | 6 +- freebsd/sys/netatalk/ddp_input.c | 42 +- freebsd/sys/netatalk/ddp_output.c | 28 +- freebsd/sys/netatalk/ddp_pcb.c | 36 +- freebsd/sys/netatalk/ddp_pcb.h | 6 +- freebsd/sys/netatalk/ddp_usrreq.c | 34 +- freebsd/sys/netatalk/ddp_var.h | 6 +- freebsd/sys/netatalk/endian.h | 8 +- freebsd/sys/netatalk/phase2.h | 2 +- freebsd/sys/netinet/accf_data.c | 16 +- freebsd/sys/netinet/accf_dns.c | 16 +- freebsd/sys/netinet/accf_http.c | 18 +- freebsd/sys/netinet/icmp6.h | 743 ++++++++++++++++++- freebsd/sys/netinet/icmp_var.h | 4 +- freebsd/sys/netinet/if_atm.c | 38 +- freebsd/sys/netinet/if_ether.c | 64 +- freebsd/sys/netinet/if_ether.h | 124 +++- freebsd/sys/netinet/igmp.c | 60 +- freebsd/sys/netinet/igmp.h | 150 +++- freebsd/sys/netinet/igmp_var.h | 4 +- freebsd/sys/netinet/in.c | 66 +- freebsd/sys/netinet/in.h | 796 ++++++++++++++++++++- freebsd/sys/netinet/in_gif.c | 64 +- freebsd/sys/netinet/in_gif.h | 6 +- freebsd/sys/netinet/in_mcast.c | 52 +- freebsd/sys/netinet/in_pcb.c | 74 +- freebsd/sys/netinet/in_pcb.h | 22 +- freebsd/sys/netinet/in_proto.c | 84 +-- freebsd/sys/netinet/in_rmx.c | 36 +- freebsd/sys/netinet/in_systm.h | 60 +- freebsd/sys/netinet/in_var.h | 14 +- freebsd/sys/netinet/ip.h | 198 ++++- freebsd/sys/netinet/ip6.h | 354 ++++++++- freebsd/sys/netinet/ip_carp.c | 106 +-- freebsd/sys/netinet/ip_divert.c | 74 +- freebsd/sys/netinet/ip_divert.h | 6 +- freebsd/sys/netinet/ip_ecn.c | 28 +- freebsd/sys/netinet/ip_ecn.h | 6 +- freebsd/sys/netinet/ip_encap.c | 52 +- freebsd/sys/netinet/ip_encap.h | 6 +- freebsd/sys/netinet/ip_fastfwd.c | 62 +- freebsd/sys/netinet/ip_gre.c | 68 +- freebsd/sys/netinet/ip_icmp.c | 70 +- freebsd/sys/netinet/ip_icmp.h | 216 +++++- freebsd/sys/netinet/ip_id.c | 32 +- freebsd/sys/netinet/ip_input.c | 94 +-- freebsd/sys/netinet/ip_ipsec.c | 60 +- freebsd/sys/netinet/ip_ipsec.h | 4 +- freebsd/sys/netinet/ip_mroute.c | 90 +-- freebsd/sys/netinet/ip_mroute.h | 6 +- freebsd/sys/netinet/ip_options.c | 72 +- freebsd/sys/netinet/ip_options.h | 6 +- freebsd/sys/netinet/ip_output.c | 88 +-- freebsd/sys/netinet/ip_var.h | 10 +- freebsd/sys/netinet/ipfw/dn_heap.c | 22 +- freebsd/sys/netinet/ipfw/dn_sched_fifo.c | 32 +- freebsd/sys/netinet/ipfw/dn_sched_prio.c | 32 +- freebsd/sys/netinet/ipfw/dn_sched_qfq.c | 32 +- freebsd/sys/netinet/ipfw/dn_sched_rr.c | 32 +- freebsd/sys/netinet/ipfw/dn_sched_wf2q.c | 32 +- freebsd/sys/netinet/ipfw/ip_dn_glue.c | 52 +- freebsd/sys/netinet/ipfw/ip_dn_io.c | 66 +- freebsd/sys/netinet/ipfw/ip_dummynet.c | 54 +- freebsd/sys/netinet/ipfw/ip_fw2.c | 108 +-- freebsd/sys/netinet/ipfw/ip_fw_log.c | 70 +- freebsd/sys/netinet/ipfw/ip_fw_nat.c | 42 +- freebsd/sys/netinet/ipfw/ip_fw_pfil.c | 64 +- freebsd/sys/netinet/ipfw/ip_fw_sockopt.c | 62 +- freebsd/sys/netinet/ipfw/ip_fw_table.c | 54 +- freebsd/sys/netinet/libalias/alias.c | 52 +- freebsd/sys/netinet/libalias/alias.h | 12 +- freebsd/sys/netinet/libalias/alias_cuseeme.c | 34 +- freebsd/sys/netinet/libalias/alias_db.c | 56 +- freebsd/sys/netinet/libalias/alias_dummy.c | 32 +- freebsd/sys/netinet/libalias/alias_ftp.c | 42 +- freebsd/sys/netinet/libalias/alias_irc.c | 48 +- freebsd/sys/netinet/libalias/alias_local.h | 28 +- freebsd/sys/netinet/libalias/alias_mod.c | 34 +- freebsd/sys/netinet/libalias/alias_mod.h | 8 +- freebsd/sys/netinet/libalias/alias_nbt.c | 36 +- freebsd/sys/netinet/libalias/alias_pptp.c | 34 +- freebsd/sys/netinet/libalias/alias_proxy.c | 38 +- freebsd/sys/netinet/libalias/alias_sctp.c | 40 +- freebsd/sys/netinet/libalias/alias_sctp.h | 50 +- freebsd/sys/netinet/libalias/alias_skinny.c | 30 +- freebsd/sys/netinet/libalias/alias_smedia.c | 38 +- freebsd/sys/netinet/libalias/alias_util.c | 28 +- freebsd/sys/netinet/pim.h | 8 +- freebsd/sys/netinet/pim_var.h | 6 +- freebsd/sys/netinet/raw_ip.c | 74 +- freebsd/sys/netinet/sctp.h | 12 +- freebsd/sys/netinet/sctp_asconf.c | 22 +- freebsd/sys/netinet/sctp_asconf.h | 8 +- freebsd/sys/netinet/sctp_auth.c | 24 +- freebsd/sys/netinet/sctp_auth.h | 2 +- freebsd/sys/netinet/sctp_bsd_addr.c | 32 +- freebsd/sys/netinet/sctp_bsd_addr.h | 4 +- freebsd/sys/netinet/sctp_cc_functions.c | 32 +- freebsd/sys/netinet/sctp_cc_functions.h | 2 +- freebsd/sys/netinet/sctp_constants.h | 2 +- freebsd/sys/netinet/sctp_crc32.c | 12 +- freebsd/sys/netinet/sctp_crc32.h | 2 +- freebsd/sys/netinet/sctp_header.h | 8 +- freebsd/sys/netinet/sctp_indata.c | 26 +- freebsd/sys/netinet/sctp_indata.h | 2 +- freebsd/sys/netinet/sctp_input.c | 34 +- freebsd/sys/netinet/sctp_input.h | 2 +- freebsd/sys/netinet/sctp_lock_bsd.h | 2 +- freebsd/sys/netinet/sctp_os.h | 4 +- freebsd/sys/netinet/sctp_os_bsd.h | 122 ++-- freebsd/sys/netinet/sctp_output.c | 42 +- freebsd/sys/netinet/sctp_output.h | 4 +- freebsd/sys/netinet/sctp_pcb.c | 30 +- freebsd/sys/netinet/sctp_pcb.h | 16 +- freebsd/sys/netinet/sctp_peeloff.c | 26 +- freebsd/sys/netinet/sctp_peeloff.h | 2 +- freebsd/sys/netinet/sctp_structs.h | 8 +- freebsd/sys/netinet/sctp_sysctl.c | 20 +- freebsd/sys/netinet/sctp_sysctl.h | 6 +- freebsd/sys/netinet/sctp_timer.c | 32 +- freebsd/sys/netinet/sctp_timer.h | 2 +- freebsd/sys/netinet/sctp_uio.h | 14 +- freebsd/sys/netinet/sctp_usrreq.c | 36 +- freebsd/sys/netinet/sctp_var.h | 10 +- freebsd/sys/netinet/sctputil.c | 40 +- freebsd/sys/netinet/sctputil.h | 2 +- freebsd/sys/netinet/tcp.h | 228 +++++- freebsd/sys/netinet/tcp_debug.c | 48 +- freebsd/sys/netinet/tcp_debug.h | 6 +- freebsd/sys/netinet/tcp_fsm.h | 4 +- freebsd/sys/netinet/tcp_hostcache.c | 62 +- freebsd/sys/netinet/tcp_hostcache.h | 6 +- freebsd/sys/netinet/tcp_input.c | 110 +-- freebsd/sys/netinet/tcp_lro.c | 40 +- freebsd/sys/netinet/tcp_lro.h | 6 +- freebsd/sys/netinet/tcp_offload.c | 50 +- freebsd/sys/netinet/tcp_offload.h | 10 +- freebsd/sys/netinet/tcp_output.c | 84 +-- freebsd/sys/netinet/tcp_reass.c | 82 +-- freebsd/sys/netinet/tcp_sack.c | 94 +-- freebsd/sys/netinet/tcp_seq.h | 6 +- freebsd/sys/netinet/tcp_subr.c | 122 ++-- freebsd/sys/netinet/tcp_syncache.c | 108 +-- freebsd/sys/netinet/tcp_syncache.h | 6 +- freebsd/sys/netinet/tcp_timer.c | 62 +- freebsd/sys/netinet/tcp_timer.h | 6 +- freebsd/sys/netinet/tcp_timewait.c | 98 +-- freebsd/sys/netinet/tcp_usrreq.c | 80 +-- freebsd/sys/netinet/tcp_var.h | 16 +- freebsd/sys/netinet/tcpip.h | 4 +- freebsd/sys/netinet/toedev.h | 6 +- freebsd/sys/netinet/udp.h | 69 +- freebsd/sys/netinet/udp_usrreq.c | 94 +-- freebsd/sys/netinet/udp_var.h | 4 +- freebsd/sys/netinet6/dest6.c | 42 +- freebsd/sys/netinet6/frag6.c | 54 +- freebsd/sys/netinet6/icmp6.c | 92 +-- freebsd/sys/netinet6/in6.c | 88 +-- freebsd/sys/netinet6/in6.h | 6 +- freebsd/sys/netinet6/in6_cksum.c | 16 +- freebsd/sys/netinet6/in6_gif.c | 66 +- freebsd/sys/netinet6/in6_gif.h | 6 +- freebsd/sys/netinet6/in6_ifattach.c | 72 +- freebsd/sys/netinet6/in6_ifattach.h | 6 +- freebsd/sys/netinet6/in6_mcast.c | 68 +- freebsd/sys/netinet6/in6_pcb.c | 82 +-- freebsd/sys/netinet6/in6_pcb.h | 6 +- freebsd/sys/netinet6/in6_proto.c | 106 +-- freebsd/sys/netinet6/in6_rmx.c | 64 +- freebsd/sys/netinet6/in6_src.c | 86 +-- freebsd/sys/netinet6/in6_var.h | 10 +- freebsd/sys/netinet6/ip6_forward.c | 80 +-- freebsd/sys/netinet6/ip6_id.c | 26 +- freebsd/sys/netinet6/ip6_input.c | 90 +-- freebsd/sys/netinet6/ip6_ipsec.c | 66 +- freebsd/sys/netinet6/ip6_ipsec.h | 4 +- freebsd/sys/netinet6/ip6_mroute.c | 86 +-- freebsd/sys/netinet6/ip6_mroute.h | 10 +- freebsd/sys/netinet6/ip6_output.c | 86 +-- freebsd/sys/netinet6/ip6_var.h | 6 +- freebsd/sys/netinet6/ip6protosw.h | 6 +- freebsd/sys/netinet6/mld6.c | 64 +- freebsd/sys/netinet6/mld6.h | 6 +- freebsd/sys/netinet6/mld6_var.h | 6 +- freebsd/sys/netinet6/nd6.c | 84 +-- freebsd/sys/netinet6/nd6.h | 10 +- freebsd/sys/netinet6/nd6_nbr.c | 78 +- freebsd/sys/netinet6/nd6_rtr.c | 70 +- freebsd/sys/netinet6/pim6_var.h | 6 +- freebsd/sys/netinet6/raw_ip6.c | 84 +-- freebsd/sys/netinet6/raw_ip6.h | 4 +- freebsd/sys/netinet6/route6.c | 32 +- freebsd/sys/netinet6/scope6.c | 32 +- freebsd/sys/netinet6/scope6_var.h | 6 +- freebsd/sys/netinet6/sctp6_usrreq.c | 46 +- freebsd/sys/netinet6/sctp6_var.h | 6 +- freebsd/sys/netinet6/tcp6_var.h | 6 +- freebsd/sys/netinet6/udp6_usrreq.c | 94 +-- freebsd/sys/netinet6/udp6_var.h | 6 +- freebsd/sys/netipsec/ah.h | 6 +- freebsd/sys/netipsec/ah_var.h | 6 +- freebsd/sys/netipsec/esp.h | 6 +- freebsd/sys/netipsec/esp_var.h | 6 +- freebsd/sys/netipsec/ipcomp.h | 6 +- freebsd/sys/netipsec/ipcomp_var.h | 6 +- freebsd/sys/netipsec/ipip_var.h | 6 +- freebsd/sys/netipsec/ipsec.c | 104 +-- freebsd/sys/netipsec/ipsec.h | 14 +- freebsd/sys/netipsec/ipsec6.h | 10 +- freebsd/sys/netipsec/ipsec_input.c | 90 +-- freebsd/sys/netipsec/ipsec_mbuf.c | 20 +- freebsd/sys/netipsec/ipsec_output.c | 86 +-- freebsd/sys/netipsec/key.c | 98 +-- freebsd/sys/netipsec/key.h | 6 +- freebsd/sys/netipsec/key_debug.c | 40 +- freebsd/sys/netipsec/key_debug.h | 6 +- freebsd/sys/netipsec/key_var.h | 6 +- freebsd/sys/netipsec/keydb.h | 8 +- freebsd/sys/netipsec/keysock.c | 66 +- freebsd/sys/netipsec/keysock.h | 6 +- freebsd/sys/netipsec/xform.h | 12 +- freebsd/sys/netipsec/xform_ah.c | 64 +- freebsd/sys/netipsec/xform_esp.c | 72 +- freebsd/sys/netipsec/xform_ipcomp.c | 66 +- freebsd/sys/netipsec/xform_ipip.c | 76 +- freebsd/sys/netipsec/xform_tcp.c | 58 +- freebsd/sys/nios2/include/machine/in_cksum.h | 77 ++ freebsd/sys/nios2/include/machine/legacyvar.h | 57 ++ freebsd/sys/nios2/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/nios2/nios2/in_cksum.c | 255 +++++++ freebsd/sys/nios2/nios2/legacy.c | 347 +++++++++ freebsd/sys/nios2/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/opencrypto/cast.c | 10 +- freebsd/sys/opencrypto/cast.h | 6 +- freebsd/sys/opencrypto/criov.c | 22 +- freebsd/sys/opencrypto/crypto.c | 48 +- freebsd/sys/opencrypto/cryptodev.c | 52 +- freebsd/sys/opencrypto/cryptodev.h | 8 +- freebsd/sys/opencrypto/cryptosoft.c | 54 +- freebsd/sys/opencrypto/cryptosoft.h | 6 +- freebsd/sys/opencrypto/deflate.c | 26 +- freebsd/sys/opencrypto/deflate.h | 8 +- freebsd/sys/opencrypto/rmd160.c | 12 +- freebsd/sys/opencrypto/skipjack.c | 8 +- freebsd/sys/opencrypto/xform.c | 52 +- freebsd/sys/opencrypto/xform.h | 16 +- freebsd/sys/powerpc/include/machine/cpufunc.h | 12 +- freebsd/sys/powerpc/include/machine/in_cksum.h | 76 ++ freebsd/sys/powerpc/include/machine/legacyvar.h | 57 ++ freebsd/sys/powerpc/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/powerpc/include/machine/psl.h | 6 +- freebsd/sys/powerpc/include/machine/spr.h | 6 +- freebsd/sys/powerpc/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/powerpc/powerpc/in_cksum.c | 18 +- freebsd/sys/powerpc/powerpc/legacy.c | 347 +++++++++ freebsd/sys/rpc/types.h | 4 +- freebsd/sys/sched.h | 1 - freebsd/sys/security/mac/mac_framework.h | 10 +- freebsd/sys/select.h | 1 - freebsd/sys/sh/include/machine/in_cksum.h | 77 ++ freebsd/sys/sh/include/machine/legacyvar.h | 57 ++ freebsd/sys/sh/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/sh/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/sh/sh/in_cksum.c | 255 +++++++ freebsd/sys/sh/sh/legacy.c | 347 +++++++++ freebsd/sys/socket.h | 691 ------------------ freebsd/sys/socketvar.h | 393 ---------- freebsd/sys/sparc/include/machine/in_cksum.h | 77 ++ freebsd/sys/sparc/include/machine/legacyvar.h | 57 ++ freebsd/sys/sparc/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/sparc/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/sparc/sparc/in_cksum.c | 255 +++++++ freebsd/sys/sparc/sparc/legacy.c | 347 +++++++++ freebsd/sys/sparc64/include/machine/asi.h | 6 +- freebsd/sys/sparc64/include/machine/cpufunc.h | 10 +- freebsd/sys/sparc64/include/machine/in_cksum.h | 171 +++++ freebsd/sys/sparc64/include/machine/legacyvar.h | 57 ++ freebsd/sys/sparc64/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/sparc64/include/machine/pstate.h | 6 +- freebsd/sys/sparc64/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/sparc64/sparc64/in_cksum.c | 18 +- freebsd/sys/sparc64/sparc64/legacy.c | 347 +++++++++ freebsd/sys/stat.h | 1 - freebsd/sys/sys/_bus_dma.h | 6 +- freebsd/sys/sys/_lock.h | 10 +- freebsd/sys/sys/_lockmgr.h | 6 +- freebsd/sys/sys/_mutex.h | 6 +- freebsd/sys/sys/_rmlock.h | 10 +- freebsd/sys/sys/_rwlock.h | 6 +- freebsd/sys/sys/_semaphore.h | 8 +- freebsd/sys/sys/_sigset.h | 6 +- freebsd/sys/sys/_sx.h | 6 +- freebsd/sys/sys/_task.h | 8 +- freebsd/sys/sys/_timeval.h | 57 +- freebsd/sys/sys/acl.h | 12 +- freebsd/sys/sys/aio.h | 8 +- freebsd/sys/sys/ata.h | 8 +- freebsd/sys/sys/bitstring.h | 6 +- freebsd/sys/sys/buf.h | 20 +- freebsd/sys/sys/buf_ring.h | 10 +- freebsd/sys/sys/bufobj.h | 12 +- freebsd/sys/sys/bus.h | 18 +- freebsd/sys/sys/bus_dma.h | 8 +- freebsd/sys/sys/callout.h | 8 +- freebsd/sys/sys/condvar.h | 12 +- freebsd/sys/sys/conf.h | 10 +- freebsd/sys/sys/cpu.h | 8 +- freebsd/sys/sys/ctype.h | 6 +- freebsd/sys/sys/domain.h | 6 +- freebsd/sys/sys/endian.h | 12 +- freebsd/sys/sys/event.h | 10 +- freebsd/sys/sys/eventhandler.h | 8 +- freebsd/sys/sys/eventvar.h | 8 +- freebsd/sys/sys/fcntl.h | 10 +- freebsd/sys/sys/file.h | 18 +- freebsd/sys/sys/filedesc.h | 18 +- freebsd/sys/sys/filio.h | 8 +- freebsd/sys/sys/hash.h | 8 +- freebsd/sys/sys/interrupt.h | 8 +- freebsd/sys/sys/jail.h | 18 +- freebsd/sys/sys/kenv.h | 6 +- freebsd/sys/sys/kernel.h | 10 +- freebsd/sys/sys/kobj.h | 6 +- freebsd/sys/sys/kthread.h | 8 +- freebsd/sys/sys/ktr.h | 6 +- freebsd/sys/sys/libkern.h | 12 +- freebsd/sys/sys/limits.h | 105 ++- freebsd/sys/sys/linker.h | 12 +- freebsd/sys/sys/linker_set.h | 6 +- freebsd/sys/sys/lock_profile.h | 10 +- freebsd/sys/sys/lockmgr.h | 16 +- freebsd/sys/sys/mac.h | 6 +- freebsd/sys/sys/malloc.h | 14 +- freebsd/sys/sys/mbuf.h | 14 +- freebsd/sys/sys/md5.h | 8 +- freebsd/sys/sys/mman.h | 239 ++++++- freebsd/sys/sys/module.h | 10 +- freebsd/sys/sys/mount.h | 20 +- freebsd/sys/sys/mqueue.h | 4 +- freebsd/sys/sys/mutex.h | 26 +- freebsd/sys/sys/osd.h | 8 +- freebsd/sys/sys/pciio.h | 8 +- freebsd/sys/sys/pcpu.h | 14 +- freebsd/sys/sys/poll.h | 8 +- freebsd/sys/sys/priority.h | 6 +- freebsd/sys/sys/priv.h | 6 +- freebsd/sys/sys/proc.h | 48 +- freebsd/sys/sys/protosw.h | 4 +- freebsd/sys/sys/queue.h | 8 +- freebsd/sys/sys/random.h | 6 +- freebsd/sys/sys/reboot.h | 4 +- freebsd/sys/sys/refcount.h | 4 +- freebsd/sys/sys/resourcevar.h | 14 +- freebsd/sys/sys/rman.h | 12 +- freebsd/sys/sys/rmlock.h | 14 +- freebsd/sys/sys/rtprio.h | 10 +- freebsd/sys/sys/runq.h | 6 +- freebsd/sys/sys/rwlock.h | 20 +- freebsd/sys/sys/sbuf.h | 6 +- freebsd/sys/sys/select.h | 115 ++- freebsd/sys/sys/selinfo.h | 8 +- freebsd/sys/sys/sf_buf.h | 8 +- freebsd/sys/sys/sigio.h | 6 +- freebsd/sys/sys/smp.h | 6 +- freebsd/sys/sys/sockbuf.h | 14 +- freebsd/sys/sys/socket.h | 693 +++++++++++++++++- freebsd/sys/sys/socketvar.h | 395 +++++++++- freebsd/sys/sys/sockio.h | 8 +- freebsd/sys/sys/sockopt.h | 6 +- freebsd/sys/sys/sockstate.h | 6 +- freebsd/sys/sys/stddef.h | 14 +- freebsd/sys/sys/stdint.h | 14 +- freebsd/sys/sys/sx.h | 20 +- freebsd/sys/sys/sysctl.h | 764 +++++++++++++++++++- freebsd/sys/sys/syslog.h | 6 +- freebsd/sys/sys/systm.h | 20 +- freebsd/sys/sys/taskqueue.h | 10 +- freebsd/sys/sys/timepps.h | 10 +- freebsd/sys/sys/timetc.h | 6 +- freebsd/sys/sys/timex.h | 16 +- freebsd/sys/sys/tree.h | 8 +- freebsd/sys/sys/tty.h | 32 +- freebsd/sys/sys/ttycom.h | 8 +- freebsd/sys/sys/ttydevsw.h | 10 +- freebsd/sys/sys/ttydisc.h | 10 +- freebsd/sys/sys/ttyhook.h | 10 +- freebsd/sys/sys/ttyqueue.h | 10 +- freebsd/sys/sys/ucred.h | 8 +- freebsd/sys/sys/un.h | 2 +- freebsd/sys/sys/user.h | 44 +- freebsd/sys/sys/vmmeter.h | 4 +- freebsd/sys/sysctl.h | 762 -------------------- freebsd/sys/syslimits.h | 1 - freebsd/sys/syslog.h | 203 ------ freebsd/sys/uio.h | 117 --- freebsd/sys/v850/include/machine/in_cksum.h | 77 ++ freebsd/sys/v850/include/machine/legacyvar.h | 57 ++ freebsd/sys/v850/include/machine/pci_cfgreg.h | 52 ++ freebsd/sys/v850/pci/pci_bus.c | 729 +++++++++++++++++++ freebsd/sys/v850/v850/in_cksum.c | 255 +++++++ freebsd/sys/v850/v850/legacy.c | 347 +++++++++ freebsd/sys/vm/uma.h | 4 +- freebsd/sys/vm/uma_core.c | 67 +- freebsd/sys/vm/vm.h | 2 +- 859 files changed, 39618 insertions(+), 13628 deletions(-) delete mode 100644 freebsd/sys/_iovec.h delete mode 100644 freebsd/sys/_null.h delete mode 100644 freebsd/sys/_pthreadtypes.h create mode 100644 freebsd/sys/arm/arm/legacy.c create mode 100644 freebsd/sys/avr/avr/in_cksum.c create mode 100644 freebsd/sys/avr/avr/legacy.c create mode 100644 freebsd/sys/avr/include/machine/legacyvar.h create mode 100644 freebsd/sys/avr/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/bfin/bfin/in_cksum.c create mode 100644 freebsd/sys/bfin/bfin/legacy.c create mode 100644 freebsd/sys/bfin/include/machine/legacyvar.h create mode 100644 freebsd/sys/bfin/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/bfin/pci/pci_bus.c create mode 100644 freebsd/sys/h8300/h8300/in_cksum.c create mode 100644 freebsd/sys/h8300/h8300/legacy.c create mode 100644 freebsd/sys/h8300/include/machine/legacyvar.h create mode 100644 freebsd/sys/h8300/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/h8300/pci/pci_bus.c create mode 100644 freebsd/sys/i386/include/machine/legacyvar.h create mode 100644 freebsd/sys/i386/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/i386/pci/pci_bus.c delete mode 100644 freebsd/sys/ioccom.h create mode 100644 freebsd/sys/lm32/include/machine/in_cksum.h create mode 100644 freebsd/sys/lm32/include/machine/legacyvar.h create mode 100644 freebsd/sys/lm32/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/lm32/lm32/in_cksum.c create mode 100644 freebsd/sys/lm32/lm32/legacy.c create mode 100644 freebsd/sys/lm32/pci/pci_bus.c create mode 100644 freebsd/sys/m32c/include/machine/in_cksum.h create mode 100644 freebsd/sys/m32c/include/machine/legacyvar.h create mode 100644 freebsd/sys/m32c/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/m32c/m32c/in_cksum.c create mode 100644 freebsd/sys/m32c/m32c/legacy.c create mode 100644 freebsd/sys/m32c/pci/pci_bus.c create mode 100644 freebsd/sys/m32r/include/machine/in_cksum.h create mode 100644 freebsd/sys/m32r/include/machine/legacyvar.h create mode 100644 freebsd/sys/m32r/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/m32r/m32r/in_cksum.c create mode 100644 freebsd/sys/m32r/m32r/legacy.c create mode 100644 freebsd/sys/m32r/pci/pci_bus.c create mode 100644 freebsd/sys/m68k/include/machine/in_cksum.h create mode 100644 freebsd/sys/m68k/include/machine/legacyvar.h create mode 100644 freebsd/sys/m68k/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/m68k/m68k/in_cksum.c create mode 100644 freebsd/sys/m68k/m68k/legacy.c create mode 100644 freebsd/sys/m68k/pci/pci_bus.c create mode 100644 freebsd/sys/mips/include/machine/in_cksum.h create mode 100644 freebsd/sys/mips/include/machine/legacyvar.h create mode 100644 freebsd/sys/mips/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/mips/mips/legacy.c create mode 100644 freebsd/sys/mips/pci/pci_bus.c delete mode 100644 freebsd/sys/mman.h create mode 100644 freebsd/sys/nios2/include/machine/in_cksum.h create mode 100644 freebsd/sys/nios2/include/machine/legacyvar.h create mode 100644 freebsd/sys/nios2/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/nios2/nios2/in_cksum.c create mode 100644 freebsd/sys/nios2/nios2/legacy.c create mode 100644 freebsd/sys/nios2/pci/pci_bus.c create mode 100644 freebsd/sys/powerpc/include/machine/in_cksum.h create mode 100644 freebsd/sys/powerpc/include/machine/legacyvar.h create mode 100644 freebsd/sys/powerpc/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/powerpc/pci/pci_bus.c create mode 100644 freebsd/sys/powerpc/powerpc/legacy.c delete mode 100644 freebsd/sys/sched.h delete mode 100644 freebsd/sys/select.h create mode 100644 freebsd/sys/sh/include/machine/in_cksum.h create mode 100644 freebsd/sys/sh/include/machine/legacyvar.h create mode 100644 freebsd/sys/sh/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/sh/pci/pci_bus.c create mode 100644 freebsd/sys/sh/sh/in_cksum.c create mode 100644 freebsd/sys/sh/sh/legacy.c delete mode 100644 freebsd/sys/socket.h delete mode 100644 freebsd/sys/socketvar.h create mode 100644 freebsd/sys/sparc/include/machine/in_cksum.h create mode 100644 freebsd/sys/sparc/include/machine/legacyvar.h create mode 100644 freebsd/sys/sparc/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/sparc/pci/pci_bus.c create mode 100644 freebsd/sys/sparc/sparc/in_cksum.c create mode 100644 freebsd/sys/sparc/sparc/legacy.c create mode 100644 freebsd/sys/sparc64/include/machine/in_cksum.h create mode 100644 freebsd/sys/sparc64/include/machine/legacyvar.h create mode 100644 freebsd/sys/sparc64/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/sparc64/pci/pci_bus.c create mode 100644 freebsd/sys/sparc64/sparc64/legacy.c delete mode 100644 freebsd/sys/stat.h delete mode 100644 freebsd/sys/sysctl.h delete mode 100644 freebsd/sys/syslimits.h delete mode 100644 freebsd/sys/syslog.h delete mode 100644 freebsd/sys/uio.h create mode 100644 freebsd/sys/v850/include/machine/in_cksum.h create mode 100644 freebsd/sys/v850/include/machine/legacyvar.h create mode 100644 freebsd/sys/v850/include/machine/pci_cfgreg.h create mode 100644 freebsd/sys/v850/pci/pci_bus.c create mode 100644 freebsd/sys/v850/v850/in_cksum.c create mode 100644 freebsd/sys/v850/v850/legacy.c (limited to 'freebsd/sys') diff --git a/freebsd/sys/_iovec.h b/freebsd/sys/_iovec.h deleted file mode 100644 index e98d84b9..00000000 --- a/freebsd/sys/_iovec.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)uio.h 8.5 (Berkeley) 2/22/94 - * $FreeBSD$ - */ - -#ifndef _SYS__IOVEC_HH_ -#define _SYS__IOVEC_HH_ - -#include - -#ifndef _SIZE_T_DECLARED -typedef __size_t size_t; -#define _SIZE_T_DECLARED -#endif - -#ifdef __rtems__ -#ifndef __IOVEC_DEFINED -#define __IOVEC_DEFINED -struct iovec { - void *iov_base; /* Base address. */ - size_t iov_len; /* Length. */ -}; -#endif /* __IOVEC_DEFINED */ -#else -struct iovec { - void *iov_base; /* Base address. */ - size_t iov_len; /* Length. */ -}; -#endif /* rtems */ - -#endif /* !_SYS__IOVEC_HH_ */ diff --git a/freebsd/sys/_null.h b/freebsd/sys/_null.h deleted file mode 100644 index ed6804cc..00000000 --- a/freebsd/sys/_null.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2003 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef NULL - -#if !defined(__cplusplus) -#define NULL ((void *)0) -#else -#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 -#define NULL __null -#else -#if defined(__LP64__) -#define NULL (0L) -#else -#define NULL 0 -#endif /* __LP64__ */ -#endif /* __GNUG__ */ -#endif /* !__cplusplus */ - -#endif diff --git a/freebsd/sys/_pthreadtypes.h b/freebsd/sys/_pthreadtypes.h deleted file mode 100644 index 936ffd88..00000000 --- a/freebsd/sys/_pthreadtypes.h +++ /dev/null @@ -1 +0,0 @@ -/* EMPTY */ diff --git a/freebsd/sys/arm/arm/in_cksum.c b/freebsd/sys/arm/arm/in_cksum.c index db98915d..c6f7b568 100644 --- a/freebsd/sys/arm/arm/in_cksum.c +++ b/freebsd/sys/arm/arm/in_cksum.c @@ -1,6 +1,4 @@ -#include - -/* $NetBSD: in_cksum.c,v 1.7 1997/09/02 13:18:15 thorpej Exp $ */ +#include /*- * Copyright (c) 1988, 1992, 1993 @@ -39,16 +37,16 @@ * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 */ -#include /* RCS ID & Copyright macro defns */ +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * Checksum routine for Internet Protocol family headers @@ -72,6 +70,22 @@ __FBSDID("$FreeBSD$"); ADDCARRY(sum); \ } +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + union l_util { u_int16_t s[2]; u_int32_t l; @@ -82,6 +96,87 @@ union q_util { u_int64_t q; }; +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + u_short in_addword(u_short a, u_short b) { @@ -91,14 +186,20 @@ in_addword(u_short a, u_short b) return (sum); } -static -uint64_t _do_cksum(void *addr, int len) +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif { - uint64_t sum; + u_int64_t sum; union q_util q_util; + union l_util l_util; - sum = do_cksum(addr, len); - REDUCE32; + sum = (u_int64_t) a + b + c; + REDUCE16; return (sum); } @@ -112,16 +213,16 @@ in_cksum_skip(struct mbuf *m, int len, int skip) union q_util q_util; union l_util l_util; - len -= skip; - for (; skip && m; m = m->m_next) { - if (m->m_len > skip) { - mlen = m->m_len - skip; + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; addr = mtod(m, caddr_t) + skip; - goto skip_start; - } else { - skip -= m->m_len; - } - } + goto skip_start; + } else { + skip -= m->m_len; + } + } for (; m && len; m = m->m_next) { if (m->m_len == 0) @@ -132,10 +233,10 @@ skip_start: if (len < mlen) mlen = len; - if ((clen ^ (int) addr) & 1) - sum += _do_cksum(addr, mlen) << 8; + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; else - sum += _do_cksum(addr, mlen); + sum += in_cksumdata(addr, mlen); clen += mlen; len -= mlen; @@ -146,9 +247,9 @@ skip_start: u_int in_cksum_hdr(const struct ip *ip) { - u_int64_t sum = do_cksum(ip, sizeof(struct ip)); + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); union q_util q_util; - union l_util l_util; + union l_util l_util; REDUCE16; return (~sum & 0xffff); -} +} diff --git a/freebsd/sys/arm/arm/legacy.c b/freebsd/sys/arm/arm/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/arm/arm/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/arm/include/machine/cpufunc.h b/freebsd/sys/arm/include/machine/cpufunc.h index 822fadb1..a4c1bc83 100644 --- a/freebsd/sys/arm/include/machine/cpufunc.h +++ b/freebsd/sys/arm/include/machine/cpufunc.h @@ -41,14 +41,15 @@ * $FreeBSD$ */ -#ifndef _MACHINE_CPUFUNC_HH_ -#define _MACHINE_CPUFUNC_HH_ +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ #ifdef _KERNEL +#ifndef __rtems__ -#include -#include -#include /* For in[bwl] and out[bwl] */ +#include +#include +#include /* For in[bwl] and out[bwl] */ static __inline void breakpoint(void) @@ -612,7 +613,8 @@ extern int arm_pcache_unified; extern int arm_dcache_align; extern int arm_dcache_align_mask; +#endif /* __rtems__ */ #endif /* _KERNEL */ -#endif /* _MACHINE_CPUFUNC_HH_ */ +#endif /* _MACHINE_CPUFUNC_H_ */ /* End of cpufunc.h */ diff --git a/freebsd/sys/arm/include/machine/in_cksum.h b/freebsd/sys/arm/include/machine/in_cksum.h index 5e3e9333..37d88e2e 100644 --- a/freebsd/sys/arm/include/machine/in_cksum.h +++ b/freebsd/sys/arm/include/machine/in_cksum.h @@ -10,10 +10,6 @@ * 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. @@ -33,34 +29,49 @@ * from tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg * $FreeBSD$ */ -#ifndef _MACHINE_IN_CKSUM_HH_ -#define _MACHINE_IN_CKSUM_HH_ 1 +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 -#include +#include -#ifdef _KERNEL -u_short in_cksum(struct mbuf *m, int len); -u_short in_addword(u_short sum, u_short b); -u_short in_cksum_skip(struct mbuf *m, int len, int skip); -u_int do_cksum(const void *, int); -u_int in_cksum_hdr(const struct ip *); +#define in_cksum(m, len) in_cksum_skip(m, len, 0) -static __inline u_short -in_pseudo(u_int sum, u_int b, u_int c) +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) { - __asm __volatile("adds %0, %0, %1\n" - "adcs %0, %0, %2\n" - "adc %0, %0, #0\n" - : "+r" (sum) - : "r" (b), "r" (c)); - sum = (sum & 0xffff) + (sum >> 16); - if (sum > 0xffff) - sum -= 0xffff; - return (sum); + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); } -#endif /* _KERNEL */ -#endif /* _MACHINE_IN_CKSUM_HH_ */ +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/arm/include/machine/legacyvar.h b/freebsd/sys/arm/include/machine/legacyvar.h index 4771faf5..0b0fa433 100644 --- a/freebsd/sys/arm/include/machine/legacyvar.h +++ b/freebsd/sys/arm/include/machine/legacyvar.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_LEGACYVAR_HH_ -#define _MACHINE_LEGACYVAR_HH_ +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ enum legacy_device_ivars { LEGACY_IVAR_PCIDOMAIN, @@ -54,4 +54,4 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which, struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); -#endif /* !_MACHINE_LEGACYVAR_HH_ */ +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/arm/pci/pci_bus.c b/freebsd/sys/arm/pci/pci_bus.c index ec62ec14..6627db98 100644 --- a/freebsd/sys/arm/pci/pci_bus.c +++ b/freebsd/sys/arm/pci/pci_bus.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, Stefan Esser @@ -26,31 +26,31 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef CPU_ELAN -#include +#include #endif -#include -#include -#include +#include +#include +#include -#include +#include #ifndef __rtems__ static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, diff --git a/freebsd/sys/avr/avr/in_cksum.c b/freebsd/sys/avr/avr/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/avr/avr/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/avr/avr/legacy.c b/freebsd/sys/avr/avr/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/avr/avr/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/avr/include/machine/in_cksum.h b/freebsd/sys/avr/include/machine/in_cksum.h index 1f7dbac7..37d88e2e 100644 --- a/freebsd/sys/avr/include/machine/in_cksum.h +++ b/freebsd/sys/avr/include/machine/in_cksum.h @@ -29,23 +29,16 @@ * from tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg * $FreeBSD$ */ -#ifndef _MACHINE_IN_CKSUM_HH_ -#define _MACHINE_IN_CKSUM_HH_ 1 +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 -#ifndef _SYS_CDEFS_HH_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -/* - * MP safe (alfred) - */ - -#include +#include -#define in_cksum(m, len) in_cksum_skip(m, len, 0) +#define in_cksum(m, len) in_cksum_skip(m, len, 0) /* * It it useful to have an Internet checksum routine which is inlineable @@ -53,33 +46,7 @@ * in the normal case (where there are no options and the header length is * therefore always exactly five 32-bit words. */ -#if defined(__GNUCLIKE_ASM) && !defined(__INTEL_COMPILER) -static __inline u_int -in_cksum_hdr(const struct ip *ip) -{ - u_int sum = 0; - - __asm( - "addl %1, %0\n" - "adcl %2, %0\n" - "adcl %3, %0\n" - "adcl %4, %0\n" - "adcl %5, %0\n" - "adcl $0, %0" - : "+r" (sum) - : "g" (((const u_int32_t *)ip)[0]), - "g" (((const u_int32_t *)ip)[1]), - "g" (((const u_int32_t *)ip)[2]), - "g" (((const u_int32_t *)ip)[3]), - "g" (((const u_int32_t *)ip)[4]) - : "cc" - ); - sum = (sum & 0xffff) + (sum >> 16); - if (sum > 0xffff) - sum -= 0xffff; - - return ~sum & 0xffff; -} +#ifdef __CC_SUPPORTS___INLINE static __inline void in_cksum_update(struct ip *ip) @@ -89,54 +56,22 @@ in_cksum_update(struct ip *ip) ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); } -static __inline u_short -in_addword(u_short sum, u_short b) -{ - __asm( - "addw %1, %0\n" - "adcw $0, %0" - : "+r" (sum) - : "g" (b) - : "cc" - ); - return (sum); -} - -static __inline u_short -in_pseudo(u_int sum, u_int b, u_int c) -{ - __asm( - "addl %1, %0\n" - "adcl %2, %0\n" - "adcl $0, %0" - : "+r" (sum) - : "g" (b), - "g" (c) - : "cc" - ); - sum = (sum & 0xffff) + (sum >> 16); - if (sum > 0xffff) - sum -= 0xffff; - return (sum); -} - #else -#define in_cksum_update(ip) \ - do { \ - int __tmpsum; \ - __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ } while(0) #endif #ifdef _KERNEL -#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER) u_int in_cksum_hdr(const struct ip *ip); u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); -#endif u_short in_cksum_skip(struct mbuf *m, int len, int skip); -#endif /* _KERNEL */ +#endif -#endif /* _MACHINE_IN_CKSUM_HH_ */ +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/avr/include/machine/legacyvar.h b/freebsd/sys/avr/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/avr/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/avr/include/machine/pci_cfgreg.h b/freebsd/sys/avr/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/avr/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/avr/pci/pci_bus.c b/freebsd/sys/avr/pci/pci_bus.c index 62cd96c1..6627db98 100644 --- a/freebsd/sys/avr/pci/pci_bus.c +++ b/freebsd/sys/avr/pci/pci_bus.c @@ -1,71 +1,729 @@ -#include +#include -/** - * @file - * - * @ingroup rtems_bsd_rtems - * - * @brief This file contains methods that are rtems specific implementation - * of methods in pci_bus.c. - */ - -/* - * COPYRIGHT (c) 2012. On-Line Applications Research Corporation (OAR). +/*- + * Copyright (c) 1997, Stefan Esser * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice unmodified, this list of conditions, and the following + * disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include + +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include -#include -#include -#include -#include +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ -#include -#include -#include int -pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) { - int bus; - int slot; - int func; - uint8_t irq; - - bus = pci_get_bus(dev); - slot = pci_get_slot(dev); - func = pci_get_function(dev); + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } - pci_read_config_byte(bus, slot, func, PCI_INTERRUPT_LINE, &irq); - return irq; + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); } +#endif /* __rtems__ */ diff --git a/freebsd/sys/bfin/bfin/in_cksum.c b/freebsd/sys/bfin/bfin/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/bfin/bfin/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/bfin/bfin/legacy.c b/freebsd/sys/bfin/bfin/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/bfin/bfin/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/bfin/include/machine/in_cksum.h b/freebsd/sys/bfin/include/machine/in_cksum.h index 4539d129..37d88e2e 100644 --- a/freebsd/sys/bfin/include/machine/in_cksum.h +++ b/freebsd/sys/bfin/include/machine/in_cksum.h @@ -33,10 +33,10 @@ * $FreeBSD$ */ -#ifndef _MACHINE_IN_CKSUM_HH_ -#define _MACHINE_IN_CKSUM_HH_ 1 +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 -#include +#include #define in_cksum(m, len) in_cksum_skip(m, len, 0) @@ -74,4 +74,4 @@ u_short in_pseudo(u_int sum, u_int b, u_int c); u_short in_cksum_skip(struct mbuf *m, int len, int skip); #endif -#endif /* _MACHINE_IN_CKSUM_HH_ */ +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/bfin/include/machine/legacyvar.h b/freebsd/sys/bfin/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/bfin/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/bfin/include/machine/pci_cfgreg.h b/freebsd/sys/bfin/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/bfin/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/bfin/pci/pci_bus.c b/freebsd/sys/bfin/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/bfin/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/bsm/audit.h b/freebsd/sys/bsm/audit.h index 98ee45c8..42e1e171 100644 --- a/freebsd/sys/bsm/audit.h +++ b/freebsd/sys/bsm/audit.h @@ -33,8 +33,8 @@ #ifndef _BSM_AUDIT_H #define _BSM_AUDIT_H -#include -#include +#include +#include #define AUDIT_RECORD_MAGIC 0x828a0f1b #define MAX_AUDIT_RECORDS 20 @@ -316,7 +316,7 @@ int getaudit_addr(struct auditinfo_addr *, int); int setaudit_addr(const struct auditinfo_addr *, int); #ifdef __APPLE_API_PRIVATE -#include +#include mach_port_name_t audit_session_self(void); au_asid_t audit_session_join(mach_port_name_t port); #endif /* __APPLE_API_PRIVATE */ diff --git a/freebsd/sys/bsm/audit_kevents.h b/freebsd/sys/bsm/audit_kevents.h index 82580920..f4f77a55 100644 --- a/freebsd/sys/bsm/audit_kevents.h +++ b/freebsd/sys/bsm/audit_kevents.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _BSM_AUDIT_KEVENTS_HH_ -#define _BSM_AUDIT_KEVENTS_HH_ +#ifndef _BSM_AUDIT_KEVENTS_H_ +#define _BSM_AUDIT_KEVENTS_H_ /* * The reserved event numbers for kernel events are 1...2047 and 43001..44900. @@ -796,4 +796,4 @@ #define AUE_WORKQOPEN AUE_NULL #define AUE_WORKQOPS AUE_NULL -#endif /* !_BSM_AUDIT_KEVENTS_HH_ */ +#endif /* !_BSM_AUDIT_KEVENTS_H_ */ diff --git a/freebsd/sys/cam/ata/ata_all.h b/freebsd/sys/cam/ata/ata_all.h index 6b23bd79..2e838fdc 100644 --- a/freebsd/sys/cam/ata/ata_all.h +++ b/freebsd/sys/cam/ata/ata_all.h @@ -29,7 +29,7 @@ #ifndef CAM_ATA_ALL_H #define CAM_ATA_ALL_H 1 -#include +#include struct ccb_ataio; struct cam_periph; diff --git a/freebsd/sys/cam/cam.c b/freebsd/sys/cam/cam.c index 852d1d5b..5b21ae8a 100644 --- a/freebsd/sys/cam/cam.c +++ b/freebsd/sys/cam/cam.c @@ -1,4 +1,4 @@ -#include +#include /*- * Generic utility routines for the Common Access Method layer. @@ -28,29 +28,29 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else /* _KERNEL */ -#include -#include -#include +#include +#include +#include #endif /* _KERNEL */ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #endif static int camstatusentrycomp(const void *key, const void *member); diff --git a/freebsd/sys/cam/cam.h b/freebsd/sys/cam/cam.h index 6533fa42..5a58db6c 100644 --- a/freebsd/sys/cam/cam.h +++ b/freebsd/sys/cam/cam.h @@ -33,13 +33,13 @@ #ifdef _KERNEL #ifndef __rtems__ -#include +#include #else /* __rtems__ */ -#include +#include #endif /* __rtems__ */ #endif -#include +#include typedef u_int path_id_t; typedef u_int target_id_t; diff --git a/freebsd/sys/cam/cam_ccb.h b/freebsd/sys/cam/cam_ccb.h index d8b14458..89042942 100644 --- a/freebsd/sys/cam/cam_ccb.h +++ b/freebsd/sys/cam/cam_ccb.h @@ -31,16 +31,16 @@ #ifndef _CAM_CAM_CCB_H #define _CAM_CAM_CCB_H 1 -#include -#include -#include -#include +#include +#include +#include +#include #ifndef _KERNEL -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef __rtems__ #include diff --git a/freebsd/sys/cam/cam_periph.h b/freebsd/sys/cam/cam_periph.h index 8bf8fd21..33e9f758 100644 --- a/freebsd/sys/cam/cam_periph.h +++ b/freebsd/sys/cam/cam_periph.h @@ -31,8 +31,8 @@ #ifndef _CAM_CAM_PERIPH_H #define _CAM_CAM_PERIPH_H 1 -#include -#include +#include +#include #ifdef _KERNEL @@ -44,7 +44,7 @@ extern struct periph_driver **periph_drivers; void periphdriver_register(void *); void periphdriver_init(int level); -#include +#include #define PERIPHDRIVER_DECLARE(name, driver) \ static int name ## _modevent(module_t mod, int type, void *data) \ { \ diff --git a/freebsd/sys/cam/cam_xpt_sim.h b/freebsd/sys/cam/cam_xpt_sim.h index 32c3082b..323f786c 100644 --- a/freebsd/sys/cam/cam_xpt_sim.h +++ b/freebsd/sys/cam/cam_xpt_sim.h @@ -32,8 +32,8 @@ #ifndef _CAM_CAM_XPT_SIM_H #define _CAM_CAM_XPT_SIM_H 1 -#include -#include +#include +#include /* Functions accessed by SIM drivers */ #ifdef _KERNEL diff --git a/freebsd/sys/cam/scsi/scsi_all.c b/freebsd/sys/cam/scsi/scsi_all.c index a25a20b8..324a8e3a 100644 --- a/freebsd/sys/cam/scsi/scsi_all.c +++ b/freebsd/sys/cam/scsi/scsi_all.c @@ -1,4 +1,4 @@ -#include +#include /*- * Implementation of Utility functions for all SCSI device types. @@ -29,37 +29,37 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #ifdef _KERNEL #ifndef __rtems__ -#include +#include #else /* __rtems__ */ -#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifndef _KERNEL -#include +#include #ifndef FALSE #define FALSE 0 diff --git a/freebsd/sys/cam/scsi/scsi_all.h b/freebsd/sys/cam/scsi/scsi_all.h index 47908b82..cddf4f9f 100644 --- a/freebsd/sys/cam/scsi/scsi_all.h +++ b/freebsd/sys/cam/scsi/scsi_all.h @@ -24,7 +24,7 @@ #ifndef _SCSI_SCSI_ALL_H #define _SCSI_SCSI_ALL_H 1 -#include +#include #ifdef _KERNEL /* diff --git a/freebsd/sys/cam/scsi/scsi_da.h b/freebsd/sys/cam/scsi/scsi_da.h index 69dafefc..da099f69 100644 --- a/freebsd/sys/cam/scsi/scsi_da.h +++ b/freebsd/sys/cam/scsi/scsi_da.h @@ -52,7 +52,7 @@ #ifndef _SCSI_SCSI_DA_H #define _SCSI_SCSI_DA_H 1 -#include +#include struct scsi_rezero_unit { diff --git a/freebsd/sys/contrib/altq/altq/altq.h b/freebsd/sys/contrib/altq/altq/altq.h index 2c9e3536..9319e44c 100644 --- a/freebsd/sys/contrib/altq/altq/altq.h +++ b/freebsd/sys/contrib/altq/altq/altq.h @@ -26,8 +26,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_HH_ -#define _ALTQ_ALTQ_HH_ +#ifndef _ALTQ_ALTQ_H_ +#define _ALTQ_ALTQ_H_ #if 0 /* @@ -39,10 +39,10 @@ #endif #ifdef ALTQ3_COMPAT -#include -#include -#include -#include +#include +#include +#include +#include #ifndef IFNAMSIZ #define IFNAMSIZ 16 @@ -198,7 +198,7 @@ struct pktcntr { #endif /* ALTQ3_COMPAT */ #ifdef _KERNEL -#include +#include #endif -#endif /* _ALTQ_ALTQ_HH_ */ +#endif /* _ALTQ_ALTQ_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_cbq.c b/freebsd/sys/contrib/altq/altq/altq_cbq.c index b5f21fb3..7991c0f5 100644 --- a/freebsd/sys/contrib/altq/altq/altq_cbq.c +++ b/freebsd/sys/contrib/altq/altq/altq_cbq.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_cbq.c,v 1.19 2003/09/17 14:23:25 kjc Exp $ */ @@ -34,37 +34,37 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_CBQ /* cbq is enabled by ALTQ_CBQ option in opt_altq.h */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include -#include +#include +#include #endif -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif #ifdef ALTQ3_COMPAT diff --git a/freebsd/sys/contrib/altq/altq/altq_cbq.h b/freebsd/sys/contrib/altq/altq/altq_cbq.h index 4b90beb4..30a15c73 100644 --- a/freebsd/sys/contrib/altq/altq/altq_cbq.h +++ b/freebsd/sys/contrib/altq/altq/altq_cbq.h @@ -30,13 +30,13 @@ * These notices must be retained in any copies of any part of this software. */ -#ifndef _ALTQ_ALTQ_CBQ_HH_ -#define _ALTQ_ALTQ_CBQ_HH_ +#ifndef _ALTQ_ALTQ_CBQ_H_ +#define _ALTQ_ALTQ_CBQ_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -218,4 +218,4 @@ typedef struct cbqstate { } #endif -#endif /* !_ALTQ_ALTQ_CBQ_HH_ */ +#endif /* !_ALTQ_ALTQ_CBQ_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_cdnr.c b/freebsd/sys/contrib/altq/altq/altq_cdnr.c index 66095acc..426e8ddf 100644 --- a/freebsd/sys/contrib/altq/altq/altq_cdnr.c +++ b/freebsd/sys/contrib/altq/altq/altq_cdnr.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_cdnr.c,v 1.14 2003/09/05 22:40:36 itojun Exp $ */ @@ -30,40 +30,40 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif -#include +#include #ifdef ALTQ3_COMPAT /* diff --git a/freebsd/sys/contrib/altq/altq/altq_cdnr.h b/freebsd/sys/contrib/altq/altq/altq_cdnr.h index b765833f..d55402f4 100644 --- a/freebsd/sys/contrib/altq/altq/altq_cdnr.h +++ b/freebsd/sys/contrib/altq/altq/altq_cdnr.h @@ -26,10 +26,10 @@ * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_CDNR_HH_ -#define _ALTQ_ALTQ_CDNR_HH_ +#ifndef _ALTQ_ALTQ_CDNR_H_ +#define _ALTQ_ALTQ_CDNR_H_ -#include +#include /* * traffic conditioner element types @@ -332,4 +332,4 @@ struct tswtcm { #endif /* _KERNEL */ -#endif /* _ALTQ_ALTQ_CDNR_HH_ */ +#endif /* _ALTQ_ALTQ_CDNR_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_classq.h b/freebsd/sys/contrib/altq/altq/altq_classq.h index c3cfea37..dc5c646f 100644 --- a/freebsd/sys/contrib/altq/altq/altq_classq.h +++ b/freebsd/sys/contrib/altq/altq/altq_classq.h @@ -35,8 +35,8 @@ /* * class queue definitions extracted from rm_class.h. */ -#ifndef _ALTQ_ALTQ_CLASSQ_HH_ -#define _ALTQ_ALTQ_CLASSQ_HH_ +#ifndef _ALTQ_ALTQ_CLASSQ_H_ +#define _ALTQ_ALTQ_CLASSQ_H_ #ifdef __cplusplus extern "C" { @@ -203,4 +203,4 @@ _flushq(class_queue_t *q) } #endif -#endif /* _ALTQ_ALTQ_CLASSQ_HH_ */ +#endif /* _ALTQ_ALTQ_CLASSQ_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_hfsc.c b/freebsd/sys/contrib/altq/altq/altq_hfsc.c index a559f006..c4648af3 100644 --- a/freebsd/sys/contrib/altq/altq/altq_hfsc.c +++ b/freebsd/sys/contrib/altq/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_hfsc.c,v 1.24 2003/12/05 05:40:46 kjc Exp $ */ @@ -45,38 +45,38 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_HFSC /* hfsc is enabled by ALTQ_HFSC option in opt_altq.h */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #if 1 /* ALTQ3_COMPAT */ -#include -#include -#include +#include +#include +#include #endif /* ALTQ3_COMPAT */ -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif /* diff --git a/freebsd/sys/contrib/altq/altq/altq_hfsc.h b/freebsd/sys/contrib/altq/altq/altq_hfsc.h index fc983586..91ba3d18 100644 --- a/freebsd/sys/contrib/altq/altq/altq_hfsc.h +++ b/freebsd/sys/contrib/altq/altq/altq_hfsc.h @@ -29,13 +29,13 @@ * and to grant Carnegie Mellon the rights to redistribute these * changes without encumbrance. */ -#ifndef _ALTQ_ALTQ_HFSC_HH_ -#define _ALTQ_ALTQ_HFSC_HH_ +#ifndef _ALTQ_ALTQ_HFSC_H_ +#define _ALTQ_ALTQ_HFSC_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -317,4 +317,4 @@ struct hfsc_if { } #endif -#endif /* _ALTQ_ALTQ_HFSC_HH_ */ +#endif /* _ALTQ_ALTQ_HFSC_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_priq.c b/freebsd/sys/contrib/altq/altq/altq_priq.c index d395a833..0bc6f453 100644 --- a/freebsd/sys/contrib/altq/altq/altq_priq.c +++ b/freebsd/sys/contrib/altq/altq/altq_priq.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_priq.c,v 1.11 2003/09/17 14:23:25 kjc Exp $ */ @@ -32,37 +32,37 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_PRIQ /* priq is enabled by ALTQ_PRIQ option in opt_altq.h */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif -#include +#include /* * function prototypes diff --git a/freebsd/sys/contrib/altq/altq/altq_priq.h b/freebsd/sys/contrib/altq/altq/altq_priq.h index 7f553b8a..481d31b8 100644 --- a/freebsd/sys/contrib/altq/altq/altq_priq.h +++ b/freebsd/sys/contrib/altq/altq/altq_priq.h @@ -25,13 +25,13 @@ * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_PRIQ_HH_ -#define _ALTQ_ALTQ_PRIQ_HH_ +#ifndef _ALTQ_ALTQ_PRIQ_H_ +#define _ALTQ_ALTQ_PRIQ_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -167,4 +167,4 @@ struct priq_if { } #endif -#endif /* _ALTQ_ALTQ_PRIQ_HH_ */ +#endif /* _ALTQ_ALTQ_PRIQ_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_red.c b/freebsd/sys/contrib/altq/altq/altq_red.c index 18fa7209..7491c2f0 100644 --- a/freebsd/sys/contrib/altq/altq/altq_red.c +++ b/freebsd/sys/contrib/altq/altq/altq_red.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_red.c,v 1.18 2003/09/05 22:40:36 itojun Exp $ */ @@ -63,48 +63,48 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_RED /* red is enabled by ALTQ_RED option in opt_altq.h */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if 1 /* ALTQ3_COMPAT */ -#include -#include -#include +#include +#include +#include #ifdef ALTQ_FLOWVALVE -#include -#include +#include +#include #endif #endif /* ALTQ3_COMPAT */ -#include +#include -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #ifdef ALTQ_FLOWVALVE -#include +#include #endif #endif diff --git a/freebsd/sys/contrib/altq/altq/altq_red.h b/freebsd/sys/contrib/altq/altq/altq_red.h index 2d267101..dc8ea0ac 100644 --- a/freebsd/sys/contrib/altq/altq/altq_red.h +++ b/freebsd/sys/contrib/altq/altq/altq_red.h @@ -26,10 +26,10 @@ * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_RED_HH_ -#define _ALTQ_ALTQ_RED_HH_ +#ifndef _ALTQ_ALTQ_RED_H_ +#define _ALTQ_ALTQ_RED_H_ -#include +#include #ifdef ALTQ3_COMPAT struct red_interface { @@ -195,4 +195,4 @@ extern int32_t pow_w(struct wtab *, int); #endif /* _KERNEL */ -#endif /* _ALTQ_ALTQ_RED_HH_ */ +#endif /* _ALTQ_ALTQ_RED_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_rio.c b/freebsd/sys/contrib/altq/altq/altq_rio.c index 33a5fce6..a24c9006 100644 --- a/freebsd/sys/contrib/altq/altq/altq_rio.c +++ b/freebsd/sys/contrib/altq/altq/altq_rio.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_rio.c,v 1.17 2003/07/10 12:07:49 kjc Exp $ */ @@ -62,44 +62,44 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_RIO /* rio is enabled by ALTQ_RIO option in opt_altq.h */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if 1 /* ALTQ3_COMPAT */ -#include -#include -#include +#include +#include +#include #endif -#include +#include -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif /* diff --git a/freebsd/sys/contrib/altq/altq/altq_rio.h b/freebsd/sys/contrib/altq/altq/altq_rio.h index e32d2ee2..83210f23 100644 --- a/freebsd/sys/contrib/altq/altq/altq_rio.h +++ b/freebsd/sys/contrib/altq/altq/altq_rio.h @@ -26,10 +26,10 @@ * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_RIO_HH_ -#define _ALTQ_ALTQ_RIO_HH_ +#ifndef _ALTQ_ALTQ_RIO_H_ +#define _ALTQ_ALTQ_RIO_H_ -#include +#include /* * RIO: RED with IN/OUT bit @@ -141,4 +141,4 @@ extern struct mbuf *rio_getq(rio_t *, class_queue_t *); #endif /* _KERNEL */ -#endif /* _ALTQ_ALTQ_RIO_HH_ */ +#endif /* _ALTQ_ALTQ_RIO_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_rmclass.c b/freebsd/sys/contrib/altq/altq/altq_rmclass.c index 06f61bd3..390d7308 100644 --- a/freebsd/sys/contrib/altq/altq/altq_rmclass.c +++ b/freebsd/sys/contrib/altq/altq/altq_rmclass.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_rmclass.c,v 1.18 2003/11/06 06:32:53 kjc Exp $ */ @@ -42,39 +42,39 @@ #ident "@(#)rm_class.c 1.48 97/12/05 SMI" #if defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include #if (__FreeBSD__ != 2) -#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif #endif /* __FreeBSD__ || __NetBSD__ */ #ifdef ALTQ_CBQ /* cbq is enabled by ALTQ_CBQ option in opt_altq.h */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif -#include +#include #ifdef ALTQ3_COMPAT -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * Local Macros diff --git a/freebsd/sys/contrib/altq/altq/altq_rmclass.h b/freebsd/sys/contrib/altq/altq/altq_rmclass.h index feb30c1c..cf0ddf48 100644 --- a/freebsd/sys/contrib/altq/altq/altq_rmclass.h +++ b/freebsd/sys/contrib/altq/altq/altq_rmclass.h @@ -33,10 +33,10 @@ * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_RMCLASS_HH_ -#define _ALTQ_ALTQ_RMCLASS_HH_ +#ifndef _ALTQ_ALTQ_RMCLASS_H_ +#define _ALTQ_ALTQ_RMCLASS_H_ -#include +#include /* #pragma ident "@(#)rm_class.h 1.20 97/10/23 SMI" */ @@ -263,4 +263,4 @@ extern int rmc_get_weight(struct rm_ifdat *, int); } #endif -#endif /* _ALTQ_ALTQ_RMCLASS_HH_ */ +#endif /* _ALTQ_ALTQ_RMCLASS_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_rmclass_debug.h b/freebsd/sys/contrib/altq/altq/altq_rmclass_debug.h index 6723a4b7..8f471b2f 100644 --- a/freebsd/sys/contrib/altq/altq/altq_rmclass_debug.h +++ b/freebsd/sys/contrib/altq/altq/altq_rmclass_debug.h @@ -30,8 +30,8 @@ * These notices must be retained in any copies of any part of this software. */ -#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_HH_ -#define _ALTQ_ALTQ_RMCLASS_DEBUG_HH_ +#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_ +#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_ /* #pragma ident "@(#)rm_class_debug.h 1.7 98/05/04 SMI" */ @@ -109,4 +109,4 @@ extern int cbqtrace_count; } #endif -#endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_HH_ */ +#endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_subr.c b/freebsd/sys/contrib/altq/altq/altq_subr.c index f4bb6b47..b6e20082 100644 --- a/freebsd/sys/contrib/altq/altq/altq_subr.c +++ b/freebsd/sys/contrib/altq/altq/altq_subr.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: altq_subr.c,v 1.21 2003/11/06 06:32:53 kjc Exp $ */ @@ -30,65 +30,65 @@ */ #if defined(__FreeBSD__) || defined(__NetBSD__) -#include -#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif #endif /* __FreeBSD__ || __NetBSD__ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include -#include -#include +#include +#include #ifdef ALTQ3_COMPAT -#include +#include #endif /* machine dependent clock related includes */ #ifdef __FreeBSD__ #if __FreeBSD__ < 3 -#include /* for FreeBSD-2.2.8 to get i586_ctr_freq */ +#include /* for FreeBSD-2.2.8 to get i586_ctr_freq */ #endif -#include -#include -#include -#include +#include +#include +#include +#include #endif #if defined(__i386__) -#include /* for pentium tsc */ -#include /* for CPUID_TSC */ +#include /* for pentium tsc */ +#include /* for CPUID_TSC */ #ifdef __FreeBSD__ -#include /* for cpu_feature */ +#include /* for cpu_feature */ #elif defined(__NetBSD__) || defined(__OpenBSD__) -#include /* for cpu_feature */ +#include /* for cpu_feature */ #endif #endif /* __i386__ */ diff --git a/freebsd/sys/contrib/altq/altq/altq_var.h b/freebsd/sys/contrib/altq/altq/altq_var.h index 9ebfe2ed..6f37f182 100644 --- a/freebsd/sys/contrib/altq/altq/altq_var.h +++ b/freebsd/sys/contrib/altq/altq/altq_var.h @@ -26,14 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _ALTQ_ALTQ_VAR_HH_ -#define _ALTQ_ALTQ_VAR_HH_ +#ifndef _ALTQ_ALTQ_VAR_H_ +#define _ALTQ_ALTQ_VAR_H_ #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #ifdef ALTQ3_CLFIER_COMPAT /* @@ -167,7 +167,7 @@ typedef u_long ioctlcmd_t; /* macro for timeout/untimeout */ #if (__FreeBSD_version > 300000) || defined(__NetBSD__) /* use callout */ -#include +#include #if (__FreeBSD_version > 500000) #define CALLOUT_INIT(c) callout_init((c), 0) @@ -180,7 +180,7 @@ typedef u_long ioctlcmd_t; #define CALLOUT_INITIALIZER { { { NULL } }, 0, NULL, NULL, 0 } #endif #elif defined(__OpenBSD__) -#include +#include /* callout structure as a wrapper of struct timeout */ struct callout { struct timeout c_to; @@ -262,4 +262,4 @@ int hfsc_remove_queue(struct pf_altq *); int hfsc_getqstats(struct pf_altq *, void *, int *); #endif /* _KERNEL */ -#endif /* _ALTQ_ALTQ_VAR_HH_ */ +#endif /* _ALTQ_ALTQ_VAR_H_ */ diff --git a/freebsd/sys/contrib/altq/altq/altqconf.h b/freebsd/sys/contrib/altq/altq/altqconf.h index b4d0f84e..1b4271eb 100644 --- a/freebsd/sys/contrib/altq/altq/altqconf.h +++ b/freebsd/sys/contrib/altq/altq/altqconf.h @@ -4,10 +4,10 @@ #if defined(_KERNEL_OPT) || defined(__OpenBSD__) #if defined(_KERNEL_OPT) -#include +#include #endif -#include +#include #ifdef ALTQ #define NALTQ 1 diff --git a/freebsd/sys/contrib/altq/altq/if_altq.h b/freebsd/sys/contrib/altq/altq/if_altq.h index c2255b8c..50462e9e 100644 --- a/freebsd/sys/contrib/altq/altq/if_altq.h +++ b/freebsd/sys/contrib/altq/altq/if_altq.h @@ -26,17 +26,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _ALTQ_IF_ALTQ_HH_ -#define _ALTQ_IF_ALTQ_HH_ +#ifndef _ALTQ_IF_ALTQ_H_ +#define _ALTQ_IF_ALTQ_H_ #if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ #endif #ifdef _KERNEL_OPT -#include +#include #endif struct altq_pktattr; struct tb_regulator; struct top_cdnr; @@ -188,4 +188,4 @@ void altq_etherclassify(struct ifaltq *, struct mbuf *, struct altq_pktattr *); #endif #endif /* _KERNEL */ -#endif /* _ALTQ_IF_ALTQ_HH_ */ +#endif /* _ALTQ_IF_ALTQ_H_ */ diff --git a/freebsd/sys/contrib/pf/net/if_pflog.c b/freebsd/sys/contrib/pf/net/if_pflog.c index 8ecc7cee..a05c6435 100644 --- a/freebsd/sys/contrib/pf/net/if_pflog.c +++ b/freebsd/sys/contrib/pf/net/if_pflog.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: if_pflog.c,v 1.22 2006/12/15 09:31:20 otto Exp $ */ /* @@ -36,12 +36,12 @@ */ #ifdef __FreeBSD__ -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #ifdef DEV_BPF @@ -57,53 +57,53 @@ __FBSDID("$FreeBSD$"); #endif #else /* ! __FreeBSD__ */ -#include -#include +#include +#include #endif /* __FreeBSD__ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #else -#include +#include #endif -#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef INET6 #ifndef INET -#include +#include #endif -#include +#include #endif /* INET6 */ -#include -#include +#include +#include #ifdef INET #ifdef __FreeBSD__ -#include +#include #endif #endif diff --git a/freebsd/sys/contrib/pf/net/if_pflog.h b/freebsd/sys/contrib/pf/net/if_pflog.h index 9e9efbef..a3c74d16 100644 --- a/freebsd/sys/contrib/pf/net/if_pflog.h +++ b/freebsd/sys/contrib/pf/net/if_pflog.h @@ -25,8 +25,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _NET_IF_PFLOG_HH_ -#define _NET_IF_PFLOG_HH_ +#ifndef _NET_IF_PFLOG_H_ +#define _NET_IF_PFLOG_H_ #define PFLOGIFS_MAX 16 @@ -100,4 +100,4 @@ extern pflog_packet_t *pflog_packet_ptr; #endif /* NPFLOG > 0 */ #endif /* __FreeBSD__ */ #endif /* _KERNEL */ -#endif /* _NET_IF_PFLOG_HH_ */ +#endif /* _NET_IF_PFLOG_H_ */ diff --git a/freebsd/sys/contrib/pf/net/if_pfsync.c b/freebsd/sys/contrib/pf/net/if_pfsync.c index bc70adfe..c3b830be 100644 --- a/freebsd/sys/contrib/pf/net/if_pfsync.c +++ b/freebsd/sys/contrib/pf/net/if_pfsync.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: if_pfsync.c,v 1.73 2006/11/16 13:13:38 henning Exp $ */ @@ -29,13 +29,13 @@ */ #ifdef __FreeBSD__ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #ifdef DEV_BPF @@ -57,66 +57,66 @@ __FBSDID("$FreeBSD$"); #endif #endif /* __FreeBSD__ */ -#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #else -#include -#include +#include +#include #endif -#include +#include -#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif /* INET6 */ #ifndef __FreeBSD__ -#include +#include #endif #if NCARP > 0 -#include +#include #endif -#include -#include +#include +#include #ifndef __FreeBSD__ -#include -#include +#include +#include #endif #define PFSYNC_MINMTU \ diff --git a/freebsd/sys/contrib/pf/net/if_pfsync.h b/freebsd/sys/contrib/pf/net/if_pfsync.h index e3e6caf9..f306610f 100644 --- a/freebsd/sys/contrib/pf/net/if_pfsync.h +++ b/freebsd/sys/contrib/pf/net/if_pfsync.h @@ -27,8 +27,8 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _NET_IF_PFSYNC_HH_ -#define _NET_IF_PFSYNC_HH_ +#ifndef _NET_IF_PFSYNC_H_ +#define _NET_IF_PFSYNC_H_ #define PFSYNC_ID_LEN sizeof(u_int64_t) @@ -372,4 +372,4 @@ int pfsync_update_tdb(struct tdb *, int); #endif #endif -#endif /* _NET_IF_PFSYNC_HH_ */ +#endif /* _NET_IF_PFSYNC_H_ */ diff --git a/freebsd/sys/contrib/pf/net/pf.c b/freebsd/sys/contrib/pf/net/pf.c index 4ac395f1..bad7a1cd 100644 --- a/freebsd/sys/contrib/pf/net/pf.c +++ b/freebsd/sys/contrib/pf/net/pf.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf.c,v 1.527 2007/02/22 15:23:23 pyr Exp $ */ /* add: $OpenBSD: pf.c,v 1.559 2007/09/18 18:45:59 markus Exp $ */ @@ -39,16 +39,16 @@ */ #ifdef __FreeBSD__ -#include -#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #endif #ifdef __FreeBSD__ -#include -#include +#include +#include #ifdef DEV_BPF #define NBPFILTER DEV_BPF @@ -69,84 +69,84 @@ __FBSDID("$FreeBSD$"); #endif #else -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __FreeBSD__ -#include -#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __FreeBSD__ +#include +#include #else -#include +#include #endif -#include +#include #ifdef __FreeBSD__ -#include -#include -#include +#include +#include +#include #else -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifndef __FreeBSD__ -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __FreeBSD__ -#include +#include #endif -#include -#include +#include +#include #if NPFSYNC > 0 -#include +#include #endif /* NPFSYNC > 0 */ #ifdef INET6 -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include -#include +#include +#include #endif #endif /* INET6 */ #ifdef __FreeBSD__ -#include -#include -#include -#include +#include +#include +#include +#include extern int ip_optcopy(struct ip *, struct ip *); extern int debug_pfugidhack; diff --git a/freebsd/sys/contrib/pf/net/pf_if.c b/freebsd/sys/contrib/pf/net/pf_if.c index e873a2ef..97c036cb 100644 --- a/freebsd/sys/contrib/pf/net/pf_if.c +++ b/freebsd/sys/contrib/pf/net/pf_if.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_if.c,v 1.46 2006/12/13 09:01:59 itojun Exp $ */ @@ -35,44 +35,44 @@ */ #if defined(__FreeBSD__) -#include -#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #endif -#include -#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifndef __FreeBSD__ -#include +#include #endif -#include +#include -#include -#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include #ifdef INET6 -#include +#include #endif /* INET6 */ struct pfi_kif *pfi_all = NULL; diff --git a/freebsd/sys/contrib/pf/net/pf_ioctl.c b/freebsd/sys/contrib/pf/net/pf_ioctl.c index de612b4f..766268cf 100644 --- a/freebsd/sys/contrib/pf/net/pf_ioctl.c +++ b/freebsd/sys/contrib/pf/net/pf_ioctl.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_ioctl.c,v 1.175 2007/02/26 22:47:43 deraadt Exp $ */ @@ -38,13 +38,13 @@ */ #ifdef __FreeBSD__ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include #ifdef DEV_BPF #define NBPFILTER DEV_BPF @@ -65,79 +65,79 @@ __FBSDID("$FreeBSD$"); #endif #else -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __FreeBSD__ -#include -#include -#include -#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __FreeBSD__ +#include +#include +#include +#include #else -#include -#include +#include +#include #endif -#include -#include -#include +#include +#include +#include #ifndef __FreeBSD__ -#include -#include +#include +#include #endif -#include -#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include +#include #else -#include -#include +#include +#include #endif -#include +#include #if NPFSYNC > 0 -#include +#include #endif /* NPFSYNC > 0 */ -#include +#include #ifdef INET6 -#include -#include +#include +#include #endif /* INET6 */ #ifdef ALTQ -#include +#include #endif #ifdef __FreeBSD__ -#include -#include -#include -#include +#include +#include +#include +#include #endif /* __FreeBSD__ */ #ifdef __FreeBSD__ diff --git a/freebsd/sys/contrib/pf/net/pf_mtag.h b/freebsd/sys/contrib/pf/net/pf_mtag.h index 09aeb25c..a0ebf7ef 100644 --- a/freebsd/sys/contrib/pf/net/pf_mtag.h +++ b/freebsd/sys/contrib/pf/net/pf_mtag.h @@ -29,8 +29,8 @@ * */ -#ifndef _NET_PF_MTAG_HH_ -#define _NET_PF_MTAG_HH_ +#ifndef _NET_PF_MTAG_H_ +#define _NET_PF_MTAG_H_ #ifdef _KERNEL @@ -79,4 +79,4 @@ pf_get_mtag(struct mbuf *m) return ((struct pf_mtag *)(mtag + 1)); } #endif /* _KERNEL */ -#endif /* _NET_PF_MTAG_HH_ */ +#endif /* _NET_PF_MTAG_H_ */ diff --git a/freebsd/sys/contrib/pf/net/pf_norm.c b/freebsd/sys/contrib/pf/net/pf_norm.c index ea68ab50..bf0b6046 100644 --- a/freebsd/sys/contrib/pf/net/pf_norm.c +++ b/freebsd/sys/contrib/pf/net/pf_norm.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_norm.c,v 1.107 2006/04/16 00:59:52 pascoe Exp $ */ @@ -28,11 +28,11 @@ */ #ifdef __FreeBSD__ -#include -#include -#include +#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #ifdef DEV_PFLOG @@ -41,46 +41,46 @@ __FBSDID("$FreeBSD$"); #define NPFLOG 0 #endif #else -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __FreeBSD__ -#include +#include -#include +#include #endif -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif /* INET6 */ -#include +#include #ifndef __FreeBSD__ -#include +#include struct pf_frent { LIST_ENTRY(pf_frent) fr_next; diff --git a/freebsd/sys/contrib/pf/net/pf_osfp.c b/freebsd/sys/contrib/pf/net/pf_osfp.c index dafeabf1..67486b2d 100644 --- a/freebsd/sys/contrib/pf/net/pf_osfp.c +++ b/freebsd/sys/contrib/pf/net/pf_osfp.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_osfp.c,v 1.12 2006/12/13 18:14:10 itojun Exp $ */ @@ -20,28 +20,28 @@ */ #ifdef __FreeBSD__ -#include +#include __FBSDID("$FreeBSD$"); #endif -#include -#include +#include +#include #ifdef _KERNEL -# include +# include #endif /* _KERNEL */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include #ifdef _KERNEL -#include +#include #endif #ifdef _KERNEL @@ -57,12 +57,12 @@ typedef struct pool pool_t; #else /* Userland equivalents so we can lend code to tcpdump et al. */ -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include # define pool_t int # define pool_get(pool, flags) malloc(*(pool)) # define pool_put(pool, item) free(item) @@ -73,7 +73,7 @@ typedef struct pool pool_t; # endif # ifdef PFDEBUG -# include +# include # define DPFPRINTF(format, x...) fprintf(stderr, format , ##x) # else # define DPFPRINTF(format, x...) ((void)0) diff --git a/freebsd/sys/contrib/pf/net/pf_ruleset.c b/freebsd/sys/contrib/pf/net/pf_ruleset.c index 8705d4ca..8e0b65c8 100644 --- a/freebsd/sys/contrib/pf/net/pf_ruleset.c +++ b/freebsd/sys/contrib/pf/net/pf_ruleset.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_ruleset.c,v 1.1 2006/10/27 13:56:51 mcbride Exp $ */ @@ -38,27 +38,27 @@ */ #ifdef __FreeBSD__ -#include +#include __FBSDID("$FreeBSD$"); #endif -#include -#include +#include +#include #ifdef _KERNEL -# include +# include #endif /* _KERNEL */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef INET6 -#include +#include #endif /* INET6 */ @@ -76,16 +76,16 @@ __FBSDID("$FreeBSD$"); #else /* Userland equivalents so we can lend code to pfctl et al. */ -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include # define rs_malloc(x) malloc(x) # define rs_free(x) free(x) # ifdef PFDEBUG -# include +# include # define DPFPRINTF(format, x...) fprintf(stderr, format , ##x) # else # define DPFPRINTF(format, x...) ((void)0) diff --git a/freebsd/sys/contrib/pf/net/pf_subr.c b/freebsd/sys/contrib/pf/net/pf_subr.c index 14cf232e..c46d61f2 100644 --- a/freebsd/sys/contrib/pf/net/pf_subr.c +++ b/freebsd/sys/contrib/pf/net/pf_subr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -30,43 +30,43 @@ * */ -#include -#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * Following is where TCP initial sequence number generation occurs. diff --git a/freebsd/sys/contrib/pf/net/pf_table.c b/freebsd/sys/contrib/pf/net/pf_table.c index b07fb7c0..bfe98b11 100644 --- a/freebsd/sys/contrib/pf/net/pf_table.c +++ b/freebsd/sys/contrib/pf/net/pf_table.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: pf_table.c,v 1.68 2006/05/02 10:08:45 dhartmei Exp $ */ @@ -33,32 +33,32 @@ */ #ifdef __FreeBSD__ -#include -#include +#include +#include -#include +#include __FBSDID("$FreeBSD$"); #endif -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifndef __FreeBSD__ -#include +#include #endif -#include +#include #define ACCEPT_FLAGS(oklist) \ do { \ diff --git a/freebsd/sys/contrib/pf/net/pfvar.h b/freebsd/sys/contrib/pf/net/pfvar.h index c6429781..0d711ffc 100644 --- a/freebsd/sys/contrib/pf/net/pfvar.h +++ b/freebsd/sys/contrib/pf/net/pfvar.h @@ -31,35 +31,35 @@ * */ -#ifndef _NET_PFVAR_HH_ -#define _NET_PFVAR_HH_ +#ifndef _NET_PFVAR_H_ +#define _NET_PFVAR_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __FreeBSD__ -#include -#include +#include +#include #else -#include +#include #endif -#include -#include +#include +#include #ifdef __FreeBSD__ -#include -#include -#include +#include +#include +#include #else -#include +#include #endif #ifdef __FreeBSD__ -#include +#include #endif -#include +#include struct ip; struct ip6_hdr; @@ -1863,4 +1863,4 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t); struct pf_os_fingerprint * pf_osfp_validate(void); -#endif /* _NET_PFVAR_HH_ */ +#endif /* _NET_PFVAR_H_ */ diff --git a/freebsd/sys/contrib/pf/netinet/in4_cksum.c b/freebsd/sys/contrib/pf/netinet/in4_cksum.c index 105f26f0..de81173f 100644 --- a/freebsd/sys/contrib/pf/netinet/in4_cksum.c +++ b/freebsd/sys/contrib/pf/netinet/in4_cksum.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: in4_cksum.c,v 1.7 2003/06/02 23:28:13 millert Exp $ */ @@ -65,16 +65,16 @@ * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 */ -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);} diff --git a/freebsd/sys/crypto/blowfish/bf_ecb.c b/freebsd/sys/crypto/blowfish/bf_ecb.c index 50f26508..53b1c307 100644 --- a/freebsd/sys/crypto/blowfish/bf_ecb.c +++ b/freebsd/sys/crypto/blowfish/bf_ecb.c @@ -1,4 +1,4 @@ -#include +#include /* crypto/bf/bf_ecb.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) @@ -58,12 +58,12 @@ * [including the GNU Public Licence.] */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, diff --git a/freebsd/sys/crypto/blowfish/bf_enc.c b/freebsd/sys/crypto/blowfish/bf_enc.c index 59cb399b..3629f433 100644 --- a/freebsd/sys/crypto/blowfish/bf_enc.c +++ b/freebsd/sys/crypto/blowfish/bf_enc.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: bf_enc.c,v 1.7 2002/02/27 01:33:59 itojun Exp $ */ @@ -61,12 +61,12 @@ * [including the GNU Public Licence.] */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, diff --git a/freebsd/sys/crypto/blowfish/bf_skey.c b/freebsd/sys/crypto/blowfish/bf_skey.c index cc53ae55..86720555 100644 --- a/freebsd/sys/crypto/blowfish/bf_skey.c +++ b/freebsd/sys/crypto/blowfish/bf_skey.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: bf_skey.c,v 1.7 2002/02/27 01:33:59 itojun Exp $ */ @@ -61,15 +61,15 @@ * [including the GNU Public Licence.] */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include void BF_set_key(key, len, data) diff --git a/freebsd/sys/crypto/camellia/camellia-api.c b/freebsd/sys/crypto/camellia/camellia-api.c index 1b749b48..82e7a61c 100644 --- a/freebsd/sys/crypto/camellia/camellia-api.c +++ b/freebsd/sys/crypto/camellia/camellia-api.c @@ -1,4 +1,4 @@ -#include +#include /* * @@ -29,13 +29,13 @@ * $FreeBSD$ */ -#include +#include -#include +#include #ifdef _KERNEL -#include +#include #endif -#include +#include void camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits) diff --git a/freebsd/sys/crypto/camellia/camellia.c b/freebsd/sys/crypto/camellia/camellia.c index 512dfd99..6d01a512 100644 --- a/freebsd/sys/crypto/camellia/camellia.c +++ b/freebsd/sys/crypto/camellia/camellia.c @@ -1,4 +1,4 @@ -#include +#include /* camellia.h ver 1.1.0 * @@ -34,18 +34,18 @@ * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html */ -#include -#include -#include +#include +#include +#include #ifdef _KERNEL -#include +#include #else -#include -#include +#include +#include #define KASSERT(exp, msg) assert(exp) #endif -#include +#include /* key constants */ diff --git a/freebsd/sys/crypto/des/des_ecb.c b/freebsd/sys/crypto/des/des_ecb.c index 7c4c8386..7b950e55 100644 --- a/freebsd/sys/crypto/des/des_ecb.c +++ b/freebsd/sys/crypto/des/des_ecb.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: des_ecb.c,v 1.6 2001/09/10 04:03:58 itojun Exp $ */ @@ -50,13 +50,13 @@ * [including the GNU Public Licence.] */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include /* char *libdes_version="libdes v 3.24 - 20-Apr-1996 - eay"; */ /* wrong */ /* char *DES_version="DES part of SSLeay 0.6.4 30-Aug-1996"; */ diff --git a/freebsd/sys/crypto/des/des_enc.c b/freebsd/sys/crypto/des/des_enc.c index ec5f96dd..fca59b3a 100644 --- a/freebsd/sys/crypto/des/des_enc.c +++ b/freebsd/sys/crypto/des/des_enc.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: des_enc.c,v 1.1 2001/09/10 04:03:58 itojun Exp $ */ @@ -61,11 +61,11 @@ * [including the GNU Public Licence.] */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include extern const DES_LONG des_SPtrans[8][64]; diff --git a/freebsd/sys/crypto/des/des_locl.h b/freebsd/sys/crypto/des/des_locl.h index 6c92eb74..2c3cacc1 100644 --- a/freebsd/sys/crypto/des/des_locl.h +++ b/freebsd/sys/crypto/des/des_locl.h @@ -51,7 +51,7 @@ #ifndef HEADER_DES_LOCL_H #define HEADER_DES_LOCL_H -#include +#include #undef DES_PTR diff --git a/freebsd/sys/crypto/des/des_setkey.c b/freebsd/sys/crypto/des/des_setkey.c index 398a89d4..b8519ef2 100644 --- a/freebsd/sys/crypto/des/des_setkey.c +++ b/freebsd/sys/crypto/des/des_setkey.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: des_setkey.c,v 1.7 2001/09/10 04:03:58 itojun Exp $ */ @@ -58,14 +58,14 @@ * 1.0 First working version */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int des_check_key=0; diff --git a/freebsd/sys/crypto/rc4/rc4.c b/freebsd/sys/crypto/rc4/rc4.c index 417c3b44..ce62c712 100644 --- a/freebsd/sys/crypto/rc4/rc4.c +++ b/freebsd/sys/crypto/rc4/rc4.c @@ -1,4 +1,4 @@ -#include +#include /* * rc4.c @@ -36,14 +36,14 @@ * OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static __inline void swap_bytes(u_char *a, u_char *b) diff --git a/freebsd/sys/crypto/rc4/rc4.h b/freebsd/sys/crypto/rc4/rc4.h index 90723ddb..670b1a00 100644 --- a/freebsd/sys/crypto/rc4/rc4.h +++ b/freebsd/sys/crypto/rc4/rc4.h @@ -37,8 +37,8 @@ * $FreeBSD$ */ -#ifndef _SYS_CRYPTO_RC4_RC4_HH_ -#define _SYS_CRYPTO_RC4_RC4_HH_ +#ifndef _SYS_CRYPTO_RC4_RC4_H_ +#define _SYS_CRYPTO_RC4_RC4_H_ struct rc4_state { u_char perm[256]; diff --git a/freebsd/sys/crypto/rijndael/rijndael-alg-fst.c b/freebsd/sys/crypto/rijndael/rijndael-alg-fst.c index 351f6526..14ac56ba 100644 --- a/freebsd/sys/crypto/rijndael/rijndael-alg-fst.c +++ b/freebsd/sys/crypto/rijndael/rijndael-alg-fst.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: rijndael-alg-fst.c,v 1.10 2003/07/15 10:47:16 itojun Exp $ */ /** @@ -26,21 +26,21 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include #ifdef _KERNEL -#include +#include #else -#include -#include +#include +#include #define KASSERT(exp, msg) assert(exp) #endif -#include -#include +#include +#include /* Te0[x] = S [x].[02, 01, 01, 03]; diff --git a/freebsd/sys/crypto/rijndael/rijndael-api-fst.c b/freebsd/sys/crypto/rijndael/rijndael-api-fst.c index d63997e5..e715c9b7 100644 --- a/freebsd/sys/crypto/rijndael/rijndael-api-fst.c +++ b/freebsd/sys/crypto/rijndael/rijndael-api-fst.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: rijndael-api-fst.c,v 1.10 2001/05/27 09:34:18 itojun Exp $ */ @@ -17,18 +17,18 @@ * This code is placed in the public domain. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #ifdef _KERNEL -#include +#include #else -#include +#include #endif -#include -#include +#include +#include #ifndef TRUE #define TRUE 1 diff --git a/freebsd/sys/crypto/rijndael/rijndael-api-fst.h b/freebsd/sys/crypto/rijndael/rijndael-api-fst.h index f21cb790..122bf52d 100644 --- a/freebsd/sys/crypto/rijndael/rijndael-api-fst.h +++ b/freebsd/sys/crypto/rijndael/rijndael-api-fst.h @@ -11,7 +11,7 @@ #ifndef __RIJNDAEL_API_FST_H #define __RIJNDAEL_API_FST_H -#include +#include /* Generic Defines */ #define DIR_ENCRYPT 0 /* Are we encrpyting? */ diff --git a/freebsd/sys/crypto/rijndael/rijndael-api.c b/freebsd/sys/crypto/rijndael/rijndael-api.c index 2134aa5c..46823e7d 100644 --- a/freebsd/sys/crypto/rijndael/rijndael-api.c +++ b/freebsd/sys/crypto/rijndael/rijndael-api.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: rijndael.c,v 1.3 2003/08/28 14:20:22 itojun Exp $ */ @@ -28,15 +28,15 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #ifdef _KERNEL -#include +#include #endif -#include +#include void rijndael_set_key(rijndael_ctx *ctx, const u_char *key, int bits) diff --git a/freebsd/sys/crypto/sha1.c b/freebsd/sys/crypto/sha1.c index 76b938af..a850eb60 100644 --- a/freebsd/sys/crypto/sha1.c +++ b/freebsd/sys/crypto/sha1.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: sha1.c,v 1.5 2000/11/08 06:13:08 itojun Exp $ */ /* @@ -36,15 +36,15 @@ * implemented by Jun-ichiro itojun Itoh */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include /* sanity check */ #if BYTE_ORDER != BIG_ENDIAN diff --git a/freebsd/sys/crypto/sha1.h b/freebsd/sys/crypto/sha1.h index 18aedda0..3686d7dd 100644 --- a/freebsd/sys/crypto/sha1.h +++ b/freebsd/sys/crypto/sha1.h @@ -35,8 +35,8 @@ * implemented by Jun-ichiro itojun Itoh */ -#ifndef _NETINET6_SHA1_HH_ -#define _NETINET6_SHA1_HH_ +#ifndef _NETINET6_SHA1_H_ +#define _NETINET6_SHA1_H_ struct sha1_ctxt { union { @@ -69,4 +69,4 @@ typedef struct sha1_ctxt SHA1_CTX; #define SHA1_RESULTLEN (160/8) -#endif /*_NETINET6_SHA1_HH_*/ +#endif /*_NETINET6_SHA1_H_*/ diff --git a/freebsd/sys/crypto/sha2/sha2.c b/freebsd/sys/crypto/sha2/sha2.c index 3303a318..c5330f31 100644 --- a/freebsd/sys/crypto/sha2/sha2.c +++ b/freebsd/sys/crypto/sha2/sha2.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: sha2.c,v 1.8 2001/11/08 01:07:52 itojun Exp $ */ @@ -36,18 +36,18 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include #ifdef _KERNEL -#include +#include #else -#include +#include #endif -#include -#include +#include +#include /* * ASSERT NOTE: diff --git a/freebsd/sys/crypto/sha2/sha2.h b/freebsd/sys/crypto/sha2/sha2.h index a2443ca1..446d2ea6 100644 --- a/freebsd/sys/crypto/sha2/sha2.h +++ b/freebsd/sys/crypto/sha2/sha2.h @@ -72,7 +72,7 @@ typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ * uintXX_t types defined by very recent ANSI C standards and included * in the file: * - * #include + * #include * * If you choose to use then please define: * diff --git a/freebsd/sys/dev/bce/if_bce.c b/freebsd/sys/dev/bce/if_bce.c index 646e6cbf..ab8c938e 100644 --- a/freebsd/sys/dev/bce/if_bce.c +++ b/freebsd/sys/dev/bce/if_bce.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2006-2010 Broadcom Corporation @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -53,10 +53,10 @@ __FBSDID("$FreeBSD$"); * BCM5709S A0, B0, B1, B2 (pre-production) */ -#include +#include -#include -#include +#include +#include /****************************************************************************/ /* BCE Debug Options */ diff --git a/freebsd/sys/dev/bce/if_bcereg.h b/freebsd/sys/dev/bce/if_bcereg.h index 4ed5fdda..1f2ed1df 100644 --- a/freebsd/sys/dev/bce/if_bcereg.h +++ b/freebsd/sys/dev/bce/if_bcereg.h @@ -33,53 +33,53 @@ #define _BCEREG_HH_DEFINED #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include /****************************************************************************/ /* Conversion to FreeBSD type definitions. */ @@ -468,7 +468,7 @@ bce_debug = bce_debug_temp; /* Needed for random() function which is only used in debugging. */ -#include +#include /* Returns FALSE in "defects" per 2^31 - 1 calls, otherwise returns TRUE. */ #define DB_RANDOMFALSE(defects) (random() > defects) diff --git a/freebsd/sys/dev/bfe/if_bfe.c b/freebsd/sys/dev/bfe/if_bfe.c index 7ce821b8..74746c28 100644 --- a/freebsd/sys/dev/bfe/if_bfe.c +++ b/freebsd/sys/dev/bfe/if_bfe.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2003 Stuart Walsh @@ -27,46 +27,46 @@ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include MODULE_DEPEND(bfe, pci, 1, 1, 1); MODULE_DEPEND(bfe, ether, 1, 1, 1); MODULE_DEPEND(bfe, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ -#include +#include #define BFE_DEVDESC_MAX 64 /* Maximum device description length */ diff --git a/freebsd/sys/dev/bge/if_bge.c b/freebsd/sys/dev/bge/if_bge.c index 4ae441bd..06f5ba7b 100644 --- a/freebsd/sys/dev/bge/if_bge.c +++ b/freebsd/sys/dev/bge/if_bge.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Wind River Systems @@ -33,7 +33,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -69,58 +69,58 @@ __FBSDID("$FreeBSD$"); */ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef __sparc64__ -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include +#include +#include -#include +#include #define BGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP) #define ETHER_MIN_NOPAD (ETHER_MIN_LEN - ETHER_CRC_LEN) /* i.e., 60 */ @@ -130,7 +130,7 @@ MODULE_DEPEND(bge, ether, 1, 1, 1); MODULE_DEPEND(bge, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ -#include +#include /* * Various supported device vendors/types and their names. Note: the diff --git a/freebsd/sys/dev/dc/dcphy.c b/freebsd/sys/dev/dc/dcphy.c index 75ba2ce5..fcfa7d6c 100644 --- a/freebsd/sys/dev/dc/dcphy.c +++ b/freebsd/sys/dev/dc/dcphy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, 1998, 1999 @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -44,33 +44,33 @@ __FBSDID("$FreeBSD$"); * which is harder to do. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include -#include +#include #define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, \ diff --git a/freebsd/sys/dev/dc/if_dc.c b/freebsd/sys/dev/dc/if_dc.c index 512555b5..9b60bc06 100644 --- a/freebsd/sys/dev/dc/if_dc.c +++ b/freebsd/sys/dev/dc/if_dc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, 1998, 1999 @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -95,47 +95,47 @@ __FBSDID("$FreeBSD$"); */ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include #define DC_USEIOSPACE -#include +#include #ifdef __sparc64__ -#include -#include +#include +#include #endif MODULE_DEPEND(dc, pci, 1, 1, 1); @@ -146,7 +146,7 @@ MODULE_DEPEND(dc, miibus, 1, 1, 1); * "device miibus" is required in kernel config. See GENERIC if you get * errors here. */ -#include +#include /* * Various supported device vendors/types and their names. diff --git a/freebsd/sys/dev/dc/pnphy.c b/freebsd/sys/dev/dc/pnphy.c index d5837e54..b59ddf61 100644 --- a/freebsd/sys/dev/dc/pnphy.c +++ b/freebsd/sys/dev/dc/pnphy.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 1997, 1998, 1999 @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -42,31 +42,31 @@ __FBSDID("$FreeBSD$"); * NWAY to work right is amazingly difficult. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include #define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, \ diff --git a/freebsd/sys/dev/e1000/e1000_80003es2lan.c b/freebsd/sys/dev/e1000/e1000_80003es2lan.c index bec2a8ac..79fba337 100644 --- a/freebsd/sys/dev/e1000/e1000_80003es2lan.c +++ b/freebsd/sys/dev/e1000/e1000_80003es2lan.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -40,9 +40,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_80003es2lan.h b/freebsd/sys/dev/e1000/e1000_80003es2lan.h index 923d66b3..3ab1ec9d 100644 --- a/freebsd/sys/dev/e1000/e1000_80003es2lan.h +++ b/freebsd/sys/dev/e1000/e1000_80003es2lan.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_80003ES2LAN_HH_ -#define _E1000_80003ES2LAN_HH_ +#ifndef _E1000_80003ES2LAN_H_ +#define _E1000_80003ES2LAN_H_ #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00 #define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02 diff --git a/freebsd/sys/dev/e1000/e1000_82540.c b/freebsd/sys/dev/e1000/e1000_82540.c index 2f2f0b08..c0e8932f 100644 --- a/freebsd/sys/dev/e1000/e1000_82540.c +++ b/freebsd/sys/dev/e1000/e1000_82540.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -46,9 +46,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82540(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82541.c b/freebsd/sys/dev/e1000/e1000_82541.c index 9faee5fd..2b655738 100644 --- a/freebsd/sys/dev/e1000/e1000_82541.c +++ b/freebsd/sys/dev/e1000/e1000_82541.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -44,9 +44,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82541(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82541.h b/freebsd/sys/dev/e1000/e1000_82541.h index f730c3a4..3b6b9612 100644 --- a/freebsd/sys/dev/e1000/e1000_82541.h +++ b/freebsd/sys/dev/e1000/e1000_82541.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_82541_HH_ -#define _E1000_82541_HH_ +#ifndef _E1000_82541_H_ +#define _E1000_82541_H_ #define NVM_WORD_SIZE_BASE_SHIFT_82541 (NVM_WORD_SIZE_BASE_SHIFT + 1) diff --git a/freebsd/sys/dev/e1000/e1000_82542.c b/freebsd/sys/dev/e1000/e1000_82542.c index 96687ed4..1e2f8671 100644 --- a/freebsd/sys/dev/e1000/e1000_82542.c +++ b/freebsd/sys/dev/e1000/e1000_82542.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -39,9 +39,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82542(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82543.c b/freebsd/sys/dev/e1000/e1000_82543.c index 0836cf51..ccf5bddf 100644 --- a/freebsd/sys/dev/e1000/e1000_82543.c +++ b/freebsd/sys/dev/e1000/e1000_82543.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -44,9 +44,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82543(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82543.h b/freebsd/sys/dev/e1000/e1000_82543.h index a95ad502..60e5c15d 100644 --- a/freebsd/sys/dev/e1000/e1000_82543.h +++ b/freebsd/sys/dev/e1000/e1000_82543.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_82543_HH_ -#define _E1000_82543_HH_ +#ifndef _E1000_82543_H_ +#define _E1000_82543_H_ #define PHY_PREAMBLE 0xFFFFFFFF #define PHY_PREAMBLE_SIZE 32 diff --git a/freebsd/sys/dev/e1000/e1000_82571.c b/freebsd/sys/dev/e1000/e1000_82571.c index bb122d3e..8faf6f91 100644 --- a/freebsd/sys/dev/e1000/e1000_82571.c +++ b/freebsd/sys/dev/e1000/e1000_82571.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -52,9 +52,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82571(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82571.h b/freebsd/sys/dev/e1000/e1000_82571.h index afccbf04..c76f16fe 100644 --- a/freebsd/sys/dev/e1000/e1000_82571.h +++ b/freebsd/sys/dev/e1000/e1000_82571.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_82571_HH_ -#define _E1000_82571_HH_ +#ifndef _E1000_82571_H_ +#define _E1000_82571_H_ #define ID_LED_RESERVED_F746 0xF746 #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \ diff --git a/freebsd/sys/dev/e1000/e1000_82575.c b/freebsd/sys/dev/e1000/e1000_82575.c index 5637832c..4ce9d194 100644 --- a/freebsd/sys/dev/e1000/e1000_82575.c +++ b/freebsd/sys/dev/e1000/e1000_82575.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -44,9 +44,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_82575(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_82575.h b/freebsd/sys/dev/e1000/e1000_82575.h index 11a27b9b..eb05262d 100644 --- a/freebsd/sys/dev/e1000/e1000_82575.h +++ b/freebsd/sys/dev/e1000/e1000_82575.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_82575_HH_ -#define _E1000_82575_HH_ +#ifndef _E1000_82575_H_ +#define _E1000_82575_H_ #define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \ (ID_LED_DEF1_DEF2 << 8) | \ @@ -472,4 +472,4 @@ void e1000_vfta_set_vf(struct e1000_hw *, u16, bool); void e1000_rlpml_set_vf(struct e1000_hw *, u16); s32 e1000_promisc_set_vf(struct e1000_hw *, enum e1000_promisc_type type); u16 e1000_rxpbs_adjust_82580(u32 data); -#endif /* _E1000_82575_HH_ */ +#endif /* _E1000_82575_H_ */ diff --git a/freebsd/sys/dev/e1000/e1000_api.c b/freebsd/sys/dev/e1000/e1000_api.c index b7f72837..17b4c817 100644 --- a/freebsd/sys/dev/e1000/e1000_api.c +++ b/freebsd/sys/dev/e1000/e1000_api.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif /** diff --git a/freebsd/sys/dev/e1000/e1000_api.h b/freebsd/sys/dev/e1000/e1000_api.h index 94af19ce..c28fc2de 100644 --- a/freebsd/sys/dev/e1000/e1000_api.h +++ b/freebsd/sys/dev/e1000/e1000_api.h @@ -32,13 +32,13 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_API_HH_ -#define _E1000_API_HH_ +#ifndef _E1000_API_H_ +#define _E1000_API_H_ #ifdef __rtems__ -#include +#include #else -#include +#include #endif extern void e1000_init_function_pointers_82542(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_defines.h b/freebsd/sys/dev/e1000/e1000_defines.h index 142903f9..5d09ad92 100644 --- a/freebsd/sys/dev/e1000/e1000_defines.h +++ b/freebsd/sys/dev/e1000/e1000_defines.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_DEFINES_HH_ -#define _E1000_DEFINES_HH_ +#ifndef _E1000_DEFINES_H_ +#define _E1000_DEFINES_H_ /* Number of Transmit and Receive Descriptors must be a multiple of 8 */ #define REQ_TX_DESCRIPTOR_MULTIPLE 8 @@ -1720,4 +1720,4 @@ on DMA coal */ -#endif /* _E1000_DEFINES_HH_ */ +#endif /* _E1000_DEFINES_H_ */ diff --git a/freebsd/sys/dev/e1000/e1000_hw.h b/freebsd/sys/dev/e1000/e1000_hw.h index c51089f8..e5dfe84d 100644 --- a/freebsd/sys/dev/e1000/e1000_hw.h +++ b/freebsd/sys/dev/e1000/e1000_hw.h @@ -32,17 +32,17 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_HW_HH_ -#define _E1000_HW_HH_ +#ifndef _E1000_HW_H_ +#define _E1000_HW_H_ #ifdef __rtems__ -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif struct e1000_hw; @@ -630,17 +630,17 @@ struct e1000_host_mng_command_info { }; #ifdef __rtems__ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif struct e1000_mac_operations { @@ -942,19 +942,19 @@ struct e1000_hw { }; #ifdef __rtems__ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif /* These functions must be implemented by drivers */ diff --git a/freebsd/sys/dev/e1000/e1000_ich8lan.c b/freebsd/sys/dev/e1000/e1000_ich8lan.c index d8c02cb5..6bf287c8 100644 --- a/freebsd/sys/dev/e1000/e1000_ich8lan.c +++ b/freebsd/sys/dev/e1000/e1000_ich8lan.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -65,9 +65,9 @@ */ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_ich8lan.h b/freebsd/sys/dev/e1000/e1000_ich8lan.h index 9e87f4d5..2935af56 100644 --- a/freebsd/sys/dev/e1000/e1000_ich8lan.h +++ b/freebsd/sys/dev/e1000/e1000_ich8lan.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_ICH8LAN_HH_ -#define _E1000_ICH8LAN_HH_ +#ifndef _E1000_ICH8LAN_H_ +#define _E1000_ICH8LAN_H_ #define ICH_FLASH_GFPREG 0x0000 #define ICH_FLASH_HSFSTS 0x0004 diff --git a/freebsd/sys/dev/e1000/e1000_mac.c b/freebsd/sys/dev/e1000/e1000_mac.c index 8b38ef9d..0a78d95d 100644 --- a/freebsd/sys/dev/e1000/e1000_mac.c +++ b/freebsd/sys/dev/e1000/e1000_mac.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_mac.h b/freebsd/sys/dev/e1000/e1000_mac.h index e1ec987e..348d660f 100644 --- a/freebsd/sys/dev/e1000/e1000_mac.h +++ b/freebsd/sys/dev/e1000/e1000_mac.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_MAC_HH_ -#define _E1000_MAC_HH_ +#ifndef _E1000_MAC_H_ +#define _E1000_MAC_H_ /* * Functions that should not be called directly from drivers but can be used diff --git a/freebsd/sys/dev/e1000/e1000_manage.c b/freebsd/sys/dev/e1000/e1000_manage.c index 4198425e..540b8a0c 100644 --- a/freebsd/sys/dev/e1000/e1000_manage.c +++ b/freebsd/sys/dev/e1000/e1000_manage.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static u8 e1000_calculate_checksum(u8 *buffer, u32 length); diff --git a/freebsd/sys/dev/e1000/e1000_manage.h b/freebsd/sys/dev/e1000/e1000_manage.h index 42f3bf2e..146caeb5 100644 --- a/freebsd/sys/dev/e1000/e1000_manage.h +++ b/freebsd/sys/dev/e1000/e1000_manage.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_MANAGE_HH_ -#define _E1000_MANAGE_HH_ +#ifndef _E1000_MANAGE_H_ +#define _E1000_MANAGE_H_ bool e1000_check_mng_mode_generic(struct e1000_hw *hw); bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_mbx.c b/freebsd/sys/dev/e1000/e1000_mbx.c index b30ede51..5236837a 100644 --- a/freebsd/sys/dev/e1000/e1000_mbx.c +++ b/freebsd/sys/dev/e1000/e1000_mbx.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif /** diff --git a/freebsd/sys/dev/e1000/e1000_mbx.h b/freebsd/sys/dev/e1000/e1000_mbx.h index 4c705282..0785ee2e 100644 --- a/freebsd/sys/dev/e1000/e1000_mbx.h +++ b/freebsd/sys/dev/e1000/e1000_mbx.h @@ -32,13 +32,13 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_MBX_HH_ -#define _E1000_MBX_HH_ +#ifndef _E1000_MBX_H_ +#define _E1000_MBX_H_ #ifdef __rtems__ -#include +#include #else -#include +#include #endif /* Define mailbox register bits */ @@ -107,4 +107,4 @@ void e1000_init_mbx_ops_generic(struct e1000_hw *hw); s32 e1000_init_mbx_params_vf(struct e1000_hw *); s32 e1000_init_mbx_params_pf(struct e1000_hw *); -#endif /* _E1000_MBX_HH_ */ +#endif /* _E1000_MBX_H_ */ diff --git a/freebsd/sys/dev/e1000/e1000_nvm.c b/freebsd/sys/dev/e1000/e1000_nvm.c index cc2e9edc..8fefe31c 100644 --- a/freebsd/sys/dev/e1000/e1000_nvm.c +++ b/freebsd/sys/dev/e1000/e1000_nvm.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static void e1000_reload_nvm_generic(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_nvm.h b/freebsd/sys/dev/e1000/e1000_nvm.h index 89b65a0f..36ee4448 100644 --- a/freebsd/sys/dev/e1000/e1000_nvm.h +++ b/freebsd/sys/dev/e1000/e1000_nvm.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_NVM_HH_ -#define _E1000_NVM_HH_ +#ifndef _E1000_NVM_H_ +#define _E1000_NVM_H_ void e1000_init_nvm_ops_generic(struct e1000_hw *hw); s32 e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c); diff --git a/freebsd/sys/dev/e1000/e1000_osdep.c b/freebsd/sys/dev/e1000/e1000_osdep.c index bf95d850..e02899ad 100644 --- a/freebsd/sys/dev/e1000/e1000_osdep.c +++ b/freebsd/sys/dev/e1000/e1000_osdep.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif /* diff --git a/freebsd/sys/dev/e1000/e1000_osdep.h b/freebsd/sys/dev/e1000/e1000_osdep.h index 64ea32e1..e3db3ec5 100644 --- a/freebsd/sys/dev/e1000/e1000_osdep.h +++ b/freebsd/sys/dev/e1000/e1000_osdep.h @@ -33,28 +33,28 @@ /*$FreeBSD$*/ -#ifndef _FREEBSD_OS_HH_ -#define _FREEBSD_OS_HH_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef _FREEBSD_OS_H_ +#define _FREEBSD_OS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define ASSERT(x) if(!(x)) panic("EM: x") @@ -216,5 +216,5 @@ struct e1000_osdep bus_space_write_2(((struct e1000_osdep *)(hw)->back)->flash_bus_space_tag, \ ((struct e1000_osdep *)(hw)->back)->flash_bus_space_handle, reg, value) -#endif /* _FREEBSD_OS_HH_ */ +#endif /* _FREEBSD_OS_H_ */ diff --git a/freebsd/sys/dev/e1000/e1000_phy.c b/freebsd/sys/dev/e1000/e1000_phy.c index 5b567f45..c5365e51 100644 --- a/freebsd/sys/dev/e1000/e1000_phy.c +++ b/freebsd/sys/dev/e1000/e1000_phy.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg); diff --git a/freebsd/sys/dev/e1000/e1000_phy.h b/freebsd/sys/dev/e1000/e1000_phy.h index 7fd83969..c42ef6c6 100644 --- a/freebsd/sys/dev/e1000/e1000_phy.h +++ b/freebsd/sys/dev/e1000/e1000_phy.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_PHY_HH_ -#define _E1000_PHY_HH_ +#ifndef _E1000_PHY_H_ +#define _E1000_PHY_H_ void e1000_init_phy_ops_generic(struct e1000_hw *hw); s32 e1000_null_read_reg(struct e1000_hw *hw, u32 offset, u16 *data); diff --git a/freebsd/sys/dev/e1000/e1000_regs.h b/freebsd/sys/dev/e1000/e1000_regs.h index 536f087f..38ccff32 100644 --- a/freebsd/sys/dev/e1000/e1000_regs.h +++ b/freebsd/sys/dev/e1000/e1000_regs.h @@ -32,8 +32,8 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_REGS_HH_ -#define _E1000_REGS_HH_ +#ifndef _E1000_REGS_H_ +#define _E1000_REGS_H_ #define E1000_CTRL 0x00000 /* Device Control - RW */ #define E1000_CTRL_DUP 0x00004 /* Device Control Duplicate (Shadow) - RW */ diff --git a/freebsd/sys/dev/e1000/e1000_vf.c b/freebsd/sys/dev/e1000/e1000_vf.c index 943b24e7..de6feb6a 100644 --- a/freebsd/sys/dev/e1000/e1000_vf.c +++ b/freebsd/sys/dev/e1000/e1000_vf.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,9 +35,9 @@ /*$FreeBSD$*/ #ifdef __rtems__ -#include +#include #else -#include +#include #endif static s32 e1000_init_phy_params_vf(struct e1000_hw *hw); diff --git a/freebsd/sys/dev/e1000/e1000_vf.h b/freebsd/sys/dev/e1000/e1000_vf.h index 28bb4fde..8d02eda3 100644 --- a/freebsd/sys/dev/e1000/e1000_vf.h +++ b/freebsd/sys/dev/e1000/e1000_vf.h @@ -32,17 +32,17 @@ ******************************************************************************/ /*$FreeBSD$*/ -#ifndef _E1000_VF_HH_ -#define _E1000_VF_HH_ +#ifndef _E1000_VF_H_ +#define _E1000_VF_H_ #ifdef __rtems__ -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif struct e1000_hw; @@ -196,9 +196,9 @@ struct e1000_vf_stats { }; #ifdef __rtems__ -#include +#include #else -#include +#include #endif struct e1000_mac_operations { @@ -298,4 +298,4 @@ s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); void e1000_vfta_set_vf(struct e1000_hw *, u16, bool); void e1000_rlpml_set_vf(struct e1000_hw *, u16); s32 e1000_promisc_set_vf(struct e1000_hw *, enum e1000_promisc_type); -#endif /* _E1000_VF_HH_ */ +#endif /* _E1000_VF_H_ */ diff --git a/freebsd/sys/dev/e1000/if_em.c b/freebsd/sys/dev/e1000/if_em.c index bc3ac3a3..c0fffc30 100644 --- a/freebsd/sys/dev/e1000/if_em.c +++ b/freebsd/sys/dev/e1000/if_em.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,62 +35,62 @@ /*$FreeBSD$*/ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include -#include +#include +#include #endif -#include -#include +#include +#include #if __FreeBSD_version >= 800000 -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef __rtems__ -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif /********************************************************************* diff --git a/freebsd/sys/dev/e1000/if_igb.c b/freebsd/sys/dev/e1000/if_igb.c index 2653ccbb..27d9c92b 100644 --- a/freebsd/sys/dev/e1000/if_igb.c +++ b/freebsd/sys/dev/e1000/if_igb.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -36,67 +36,67 @@ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include -#include -#include +#include +#include +#include #endif -#include -#include +#include +#include #if __FreeBSD_version >= 800000 -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef __rtems__ -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif /********************************************************************* diff --git a/freebsd/sys/dev/e1000/if_lem.c b/freebsd/sys/dev/e1000/if_lem.c index b0daee16..402a6f48 100644 --- a/freebsd/sys/dev/e1000/if_lem.c +++ b/freebsd/sys/dev/e1000/if_lem.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,57 +35,57 @@ /*$FreeBSD$*/ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include -#include +#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef __rtems__ -#include -#include +#include +#include #else -#include -#include +#include +#include #endif /********************************************************************* diff --git a/freebsd/sys/dev/fxp/if_fxp.c b/freebsd/sys/dev/fxp/if_fxp.c index 51ee51a9..7bc247dc 100644 --- a/freebsd/sys/dev/fxp/if_fxp.c +++ b/freebsd/sys/dev/fxp/if_fxp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1995, David Greenman @@ -29,7 +29,7 @@ * */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -37,56 +37,56 @@ __FBSDID("$FreeBSD$"); */ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include /* for PCIM_CMD_xxx */ - -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include /* for PCIM_CMD_xxx */ + +#include +#include + +#include +#include +#include MODULE_DEPEND(fxp, pci, 1, 1, 1); MODULE_DEPEND(fxp, ether, 1, 1, 1); MODULE_DEPEND(fxp, miibus, 1, 1, 1); -#include +#include /* * NOTE! On the Alpha, we have an alignment constraint. The diff --git a/freebsd/sys/dev/led/led.c b/freebsd/sys/dev/led/led.c index ae214909..db609a45 100644 --- a/freebsd/sys/dev/led/led.c +++ b/freebsd/sys/dev/led/led.c @@ -1,4 +1,4 @@ -#include +#include /*- * ---------------------------------------------------------------------------- @@ -10,21 +10,21 @@ * */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include struct ledsc { LIST_ENTRY(ledsc) list; diff --git a/freebsd/sys/dev/mii/brgphy.c b/freebsd/sys/dev/mii/brgphy.c index 9b53c83d..5633413c 100644 --- a/freebsd/sys/dev/mii/brgphy.c +++ b/freebsd/sys/dev/mii/brgphy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000 @@ -32,38 +32,38 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * Driver for the Broadcom BCM54xx/57xx 1000baseTX PHY. */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include static int brgphy_probe(device_t); static int brgphy_attach(device_t); diff --git a/freebsd/sys/dev/mii/brgphyreg.h b/freebsd/sys/dev/mii/brgphyreg.h index fb8b65a5..3f5ee5df 100644 --- a/freebsd/sys/dev/mii/brgphyreg.h +++ b/freebsd/sys/dev/mii/brgphyreg.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _DEV_MII_BRGPHYREG_HH_ -#define _DEV_MII_BRGPHYREG_HH_ +#ifndef _DEV_MII_BRGPHYREG_H_ +#define _DEV_MII_BRGPHYREG_H_ /* * Broadcom BCM5400 registers @@ -417,4 +417,4 @@ #define BRGPHY_INTRS \ ~(BRGPHY_IMR_LNK_CHG|BRGPHY_IMR_LSP_CHG|BRGPHY_IMR_DUP_CHG) -#endif /* _DEV_BRGPHY_MIIREG_HH_ */ +#endif /* _DEV_BRGPHY_MIIREG_H_ */ diff --git a/freebsd/sys/dev/mii/icsphy.c b/freebsd/sys/dev/mii/icsphy.c index a034eb36..e2315bc8 100644 --- a/freebsd/sys/dev/mii/icsphy.c +++ b/freebsd/sys/dev/mii/icsphy.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: icsphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $ */ @@ -56,7 +56,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -64,23 +64,23 @@ __FBSDID("$FreeBSD$"); * datasheet from www.icst.com */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include static int icsphy_probe(device_t dev); static int icsphy_attach(device_t dev); diff --git a/freebsd/sys/dev/mii/icsphyreg.h b/freebsd/sys/dev/mii/icsphyreg.h index a5754b7d..d92d0b51 100644 --- a/freebsd/sys/dev/mii/icsphyreg.h +++ b/freebsd/sys/dev/mii/icsphyreg.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _DEV_MII_ICSPHYREG_HH_ -#define _DEV_MII_ICSPHYREG_HH_ +#ifndef _DEV_MII_ICSPHYREG_H_ +#define _DEV_MII_ICSPHYREG_H_ /* * ICS1890 registers. @@ -126,4 +126,4 @@ #define ECR2_10AUTOPWRDN 0x0002 /* Automatic 10baseT power down */ #define ECR2_100AUTOPWRDN 0x0001 /* Automatic 100baseTX power down */ -#endif /* _DEV_MII_ICSPHYREG_HH_ */ +#endif /* _DEV_MII_ICSPHYREG_H_ */ diff --git a/freebsd/sys/dev/mii/mii.c b/freebsd/sys/dev/mii/mii.c index c5aebad6..5b949156 100644 --- a/freebsd/sys/dev/mii/mii.c +++ b/freebsd/sys/dev/mii/mii.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: mii.c,v 1.12 1999/08/03 19:41:49 drochner Exp $ */ @@ -32,7 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -41,23 +41,23 @@ __FBSDID("$FreeBSD$"); * plus some NetBSD extensions. */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include MODULE_VERSION(miibus, 1); -#include +#include static int miibus_print_child(device_t dev, device_t child); static int miibus_read_ivar(device_t dev, device_t child, int which, diff --git a/freebsd/sys/dev/mii/mii.h b/freebsd/sys/dev/mii/mii.h index 21c6b768..1d887d23 100644 --- a/freebsd/sys/dev/mii/mii.h +++ b/freebsd/sys/dev/mii/mii.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _DEV_MII_MII_HH_ -#define _DEV_MII_MII_HH_ +#ifndef _DEV_MII_MII_H_ +#define _DEV_MII_MII_H_ /* * Registers common to all PHYs. @@ -209,4 +209,4 @@ #define EXTSR_MEDIAMASK (EXTSR_1000XFDX|EXTSR_1000XHDX| \ EXTSR_1000TFDX|EXTSR_1000THDX) -#endif /* _DEV_MII_MII_HH_ */ +#endif /* _DEV_MII_MII_H_ */ diff --git a/freebsd/sys/dev/mii/mii_physubr.c b/freebsd/sys/dev/mii/mii_physubr.c index f5a278d6..3b6e0042 100644 --- a/freebsd/sys/dev/mii/mii_physubr.c +++ b/freebsd/sys/dev/mii/mii_physubr.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: mii_physubr.c,v 1.5 1999/08/03 19:41:49 drochner Exp $ */ @@ -32,28 +32,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * Subroutines common to all PHYs. */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include -#include +#include /* * Media to register setting conversion table. Order matters. diff --git a/freebsd/sys/dev/mii/miivar.h b/freebsd/sys/dev/mii/miivar.h index e8d467f7..d56ea18d 100644 --- a/freebsd/sys/dev/mii/miivar.h +++ b/freebsd/sys/dev/mii/miivar.h @@ -32,10 +32,10 @@ * $FreeBSD$ */ -#ifndef _DEV_MII_MIIVAR_HH_ -#define _DEV_MII_MIIVAR_HH_ +#ifndef _DEV_MII_MIIVAR_H_ +#define _DEV_MII_MIIVAR_H_ -#include +#include /* * Media Independent Interface configuration defintions. @@ -257,4 +257,4 @@ int mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv); void ukphy_status(struct mii_softc *); #endif /* _KERNEL */ -#endif /* _DEV_MII_MIIVAR_HH_ */ +#endif /* _DEV_MII_MIIVAR_H_ */ diff --git a/freebsd/sys/dev/pci/pci.c b/freebsd/sys/dev/pci/pci.c index ebff0fff..8552fdb7 100644 --- a/freebsd/sys/dev/pci/pci.c +++ b/freebsd/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, Stefan Esser @@ -28,56 +28,56 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include -#include +#include +#include #ifdef __HAVE_ACPI -#include -#include +#include +#include #else #define ACPI_PWR_FOR_SLEEP(x, y, z) #endif @@ -3591,10 +3591,10 @@ pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) } -#include +#include #ifdef DDB -#include -#include +#include +#include /* * List resources based on pci map registers, used for within ddb diff --git a/freebsd/sys/dev/pci/pci_pci.c b/freebsd/sys/dev/pci/pci_pci.c index c2a829c8..470386a3 100644 --- a/freebsd/sys/dev/pci/pci_pci.c +++ b/freebsd/sys/dev/pci/pci_pci.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier @@ -30,29 +30,29 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * PCI:PCI bridge support. */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include static int pcib_probe(device_t dev); diff --git a/freebsd/sys/dev/pci/pci_private.h b/freebsd/sys/dev/pci/pci_private.h index 93da2538..e45afb7a 100644 --- a/freebsd/sys/dev/pci/pci_private.h +++ b/freebsd/sys/dev/pci/pci_private.h @@ -29,8 +29,8 @@ * */ -#ifndef _PCI_PRIVATE_HH_ -#define _PCI_PRIVATE_HH_ +#ifndef _PCI_PRIVATE_H_ +#define _PCI_PRIVATE_H_ /* * Export definitions of the pci bus so that we can more easily share @@ -113,4 +113,4 @@ void pci_cfg_restore(device_t, struct pci_devinfo *); */ void pci_cfg_save(device_t, struct pci_devinfo *, int); -#endif /* _PCI_PRIVATE_HH_ */ +#endif /* _PCI_PRIVATE_H_ */ diff --git a/freebsd/sys/dev/pci/pci_user.c b/freebsd/sys/dev/pci/pci_user.c index c0b1eda0..e7306476 100644 --- a/freebsd/sys/dev/pci/pci_user.c +++ b/freebsd/sys/dev/pci/pci_user.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, Stefan Esser @@ -26,41 +26,41 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include /* XXX trim includes */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include /* XXX trim includes */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include /* * This is the user interface to PCI configuration space. diff --git a/freebsd/sys/dev/pci/pcivar.h b/freebsd/sys/dev/pci/pcivar.h index a095db6d..8e2da638 100644 --- a/freebsd/sys/dev/pci/pcivar.h +++ b/freebsd/sys/dev/pci/pcivar.h @@ -27,10 +27,10 @@ * */ -#ifndef _PCIVAR_HH_ -#define _PCIVAR_HH_ +#ifndef _PCIVAR_H_ +#define _PCIVAR_H_ -#include +#include /* some PCI bus constants */ #define PCI_MAXMAPS_0 6 /* max. no. of memory/port maps */ @@ -198,7 +198,7 @@ typedef struct { extern uint32_t pci_numdevs; /* Only if the prerequisites are present */ -#if defined(_SYS_BUS_HH_) && defined(_SYS_PCIIO_HH_) +#if defined(_SYS_BUS_H_) && defined(_SYS_PCIIO_H_) struct pci_devinfo { STAILQ_ENTRY(pci_devinfo) pci_links; struct resource_list resources; @@ -207,9 +207,9 @@ struct pci_devinfo { }; #endif -#ifdef _SYS_BUS_HH_ +#ifdef _SYS_BUS_H_ -#include +#include enum pci_device_ivars { PCI_IVAR_SUBVENDOR, @@ -460,7 +460,7 @@ void pci_ht_map_msi(device_t dev, uint64_t addr); int pci_get_max_read_req(device_t dev); int pci_set_max_read_req(device_t dev, int size); -#endif /* _SYS_BUS_HH_ */ +#endif /* _SYS_BUS_H_ */ /* * cdev switch for control device, initialised in generic PCI code @@ -475,4 +475,4 @@ STAILQ_HEAD(devlist, pci_devinfo); extern struct devlist pci_devq; extern uint32_t pci_generation; -#endif /* _PCIVAR_HH_ */ +#endif /* _PCIVAR_H_ */ diff --git a/freebsd/sys/dev/random/harvest.c b/freebsd/sys/dev/random/harvest.c index 68c60676..8f6efd22 100644 --- a/freebsd/sys/dev/random/harvest.c +++ b/freebsd/sys/dev/random/harvest.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000-2004 Mark R V Murray @@ -27,24 +27,24 @@ * */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include static int read_random_phony(void *, int); diff --git a/freebsd/sys/dev/re/if_re.c b/freebsd/sys/dev/re/if_re.c index 9424f670..2327aa1f 100644 --- a/freebsd/sys/dev/re/if_re.c +++ b/freebsd/sys/dev/re/if_re.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, 1998-2003 @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -111,52 +111,52 @@ __FBSDID("$FreeBSD$"); */ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include MODULE_DEPEND(re, pci, 1, 1, 1); MODULE_DEPEND(re, ether, 1, 1, 1); MODULE_DEPEND(re, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ -#include +#include /* Tunables. */ static int msi_disable = 0; diff --git a/freebsd/sys/dev/smc/if_smc.c b/freebsd/sys/dev/smc/if_smc.c index d943111f..236eb546 100644 --- a/freebsd/sys/dev/smc/if_smc.c +++ b/freebsd/sys/dev/smc/if_smc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 Benno Rice. All rights reserved. @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -32,51 +32,51 @@ __FBSDID("$FreeBSD$"); */ #ifdef HAVE_KERNEL_OPTION_HEADERS -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #define SMC_LOCK(sc) mtx_lock(&(sc)->smc_mtx) #define SMC_UNLOCK(sc) mtx_unlock(&(sc)->smc_mtx) diff --git a/freebsd/sys/dev/smc/if_smcreg.h b/freebsd/sys/dev/smc/if_smcreg.h index 50af8077..4b939076 100644 --- a/freebsd/sys/dev/smc/if_smcreg.h +++ b/freebsd/sys/dev/smc/if_smcreg.h @@ -25,8 +25,8 @@ * */ -#ifndef _IF_SMCREG_HH_ -#define _IF_SMCREG_HH_ +#ifndef _IF_SMCREG_H_ +#define _IF_SMCREG_H_ /* All Banks, Offset 0xe: Bank Select Register */ #define BSR 0xe @@ -258,4 +258,4 @@ /* Number of times to spin on TX allocations */ #define TX_ALLOC_WAIT_TIME 1000 -#endif /* IF_SMCREG_HH_ */ +#endif /* IF_SMCREG_H_ */ diff --git a/freebsd/sys/dev/smc/if_smcvar.h b/freebsd/sys/dev/smc/if_smcvar.h index a9e4a668..fd42edbb 100644 --- a/freebsd/sys/dev/smc/if_smcvar.h +++ b/freebsd/sys/dev/smc/if_smcvar.h @@ -25,8 +25,8 @@ * */ -#ifndef _IF_SMCVAR_HH_ -#define _IF_SMCVAR_HH_ +#ifndef _IF_SMCVAR_H_ +#define _IF_SMCVAR_H_ struct smc_softc { struct ifnet *smc_ifp; @@ -74,4 +74,4 @@ int smc_miibus_readreg(device_t, int, int); int smc_miibus_writereg(device_t, int, int, int); void smc_miibus_statchg(device_t); -#endif /* _IF_SMCVAR_HH_ */ +#endif /* _IF_SMCVAR_H_ */ diff --git a/freebsd/sys/dev/usb/controller/ehci.c b/freebsd/sys/dev/usb/controller/ehci.c index 39221b7a..8a98f608 100644 --- a/freebsd/sys/dev/usb/controller/ehci.c +++ b/freebsd/sys/dev/usb/controller/ehci.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. @@ -45,47 +45,47 @@ * 1) command failures are not recovered correctly */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define USB_DEBUG_VAR ehcidebug -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define EHCI_BUS2SC(bus) \ ((ehci_softc_t *)(((uint8_t *)(bus)) - \ diff --git a/freebsd/sys/dev/usb/controller/ehci.h b/freebsd/sys/dev/usb/controller/ehci.h index 26ba336e..19d32426 100644 --- a/freebsd/sys/dev/usb/controller/ehci.h +++ b/freebsd/sys/dev/usb/controller/ehci.h @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _EHCI_HH_ -#define _EHCI_HH_ +#ifndef _EHCI_H_ +#define _EHCI_H_ #define EHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) @@ -483,4 +483,4 @@ void ehci_resume(struct ehci_softc *sc); void ehci_shutdown(ehci_softc_t *sc); void ehci_interrupt(ehci_softc_t *sc); -#endif /* _EHCI_HH_ */ +#endif /* _EHCI_H_ */ diff --git a/freebsd/sys/dev/usb/controller/ehcireg.h b/freebsd/sys/dev/usb/controller/ehcireg.h index 7677dfad..1f5fc5c0 100644 --- a/freebsd/sys/dev/usb/controller/ehcireg.h +++ b/freebsd/sys/dev/usb/controller/ehcireg.h @@ -28,8 +28,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _EHCIREG_HH_ -#define _EHCIREG_HH_ +#ifndef _EHCIREG_H_ +#define _EHCIREG_H_ /* PCI config registers */ #define PCI_CBMEM 0x10 /* configuration base MEM */ @@ -168,4 +168,4 @@ #define EHCI_PORT_RESET_COMPLETE 2 /* ms */ -#endif /* _EHCIREG_HH_ */ +#endif /* _EHCIREG_H_ */ diff --git a/freebsd/sys/dev/usb/controller/ohci.c b/freebsd/sys/dev/usb/controller/ohci.c index 28261d80..6390156a 100644 --- a/freebsd/sys/dev/usb/controller/ohci.c +++ b/freebsd/sys/dev/usb/controller/ohci.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -37,44 +37,44 @@ __FBSDID("$FreeBSD$"); * USB spec: http://www.usb.org/developers/docs/usbspec.zip */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define USB_DEBUG_VAR ohcidebug -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define OHCI_BUS2SC(bus) \ ((ohci_softc_t *)(((uint8_t *)(bus)) - \ diff --git a/freebsd/sys/dev/usb/controller/ohci.h b/freebsd/sys/dev/usb/controller/ohci.h index 1affa420..c878af07 100644 --- a/freebsd/sys/dev/usb/controller/ohci.h +++ b/freebsd/sys/dev/usb/controller/ohci.h @@ -36,8 +36,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _OHCI_HH_ -#define _OHCI_HH_ +#ifndef _OHCI_H_ +#define _OHCI_H_ #define OHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) @@ -273,4 +273,4 @@ void ohci_suspend(ohci_softc_t *sc); void ohci_resume(ohci_softc_t *sc); void ohci_interrupt(ohci_softc_t *sc); -#endif /* _OHCI_HH_ */ +#endif /* _OHCI_H_ */ diff --git a/freebsd/sys/dev/usb/controller/ohcireg.h b/freebsd/sys/dev/usb/controller/ohcireg.h index b3acb69b..9127a02a 100644 --- a/freebsd/sys/dev/usb/controller/ohcireg.h +++ b/freebsd/sys/dev/usb/controller/ohcireg.h @@ -36,8 +36,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _OHCIREG_HH_ -#define _OHCIREG_HH_ +#ifndef _OHCIREG_H_ +#define _OHCIREG_H_ /* PCI config registers */ #define PCI_CBMEM 0x10 /* configuration base memory */ @@ -128,4 +128,4 @@ #define OHCI_FSMPS(i) (((i-210)*6/7) << 16) #define OHCI_PERIODIC(i) ((i)*9/10) -#endif /* _OHCIREG_HH_ */ +#endif /* _OHCIREG_H_ */ diff --git a/freebsd/sys/dev/usb/controller/usb_controller.c b/freebsd/sys/dev/usb/controller/usb_controller.c index ee37c265..f4220daf 100644 --- a/freebsd/sys/dev/usb/controller/usb_controller.c +++ b/freebsd/sys/dev/usb/controller/usb_controller.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,43 +26,43 @@ * SUCH DAMAGE. */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define USB_DEBUG_VAR usb_ctrl_debug -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include /* function prototypes */ diff --git a/freebsd/sys/dev/usb/quirk/usb_quirk.c b/freebsd/sys/dev/usb/quirk/usb_quirk.c index 8e597dea..6f50452b 100644 --- a/freebsd/sys/dev/usb/quirk/usb_quirk.c +++ b/freebsd/sys/dev/usb/quirk/usb_quirk.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -28,36 +28,36 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include +#include +#include -#include +#include MODULE_DEPEND(usb_quirk, usb, 1, 1, 1); MODULE_VERSION(usb_quirk, 1); diff --git a/freebsd/sys/dev/usb/quirk/usb_quirk.h b/freebsd/sys/dev/usb/quirk/usb_quirk.h index e8cc0dbf..522b15a4 100644 --- a/freebsd/sys/dev/usb/quirk/usb_quirk.h +++ b/freebsd/sys/dev/usb/quirk/usb_quirk.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_QUIRK_HH_ -#define _USB_QUIRK_HH_ +#ifndef _USB_QUIRK_H_ +#define _USB_QUIRK_H_ enum { /* @@ -105,4 +105,4 @@ enum { uint8_t usb_test_quirk(const struct usb_attach_arg *uaa, uint16_t quirk); -#endif /* _USB_QUIRK_HH_ */ +#endif /* _USB_QUIRK_H_ */ diff --git a/freebsd/sys/dev/usb/storage/umass.c b/freebsd/sys/dev/usb/storage/umass.c index b1867dc2..f59062d9 100644 --- a/freebsd/sys/dev/usb/storage/umass.c +++ b/freebsd/sys/dev/usb/storage/umass.c @@ -1,6 +1,6 @@ -#include +#include -#include +#include __FBSDID("$FreeBSD$"); /*- @@ -104,41 +104,41 @@ __FBSDID("$FreeBSD$"); * umass_cam_cb again to complete the CAM command. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include #define UMASS_EXT_BUFFER #ifdef UMASS_EXT_BUFFER diff --git a/freebsd/sys/dev/usb/ufm_ioctl.h b/freebsd/sys/dev/usb/ufm_ioctl.h index 20a0b96e..921b3d4f 100644 --- a/freebsd/sys/dev/usb/ufm_ioctl.h +++ b/freebsd/sys/dev/usb/ufm_ioctl.h @@ -30,7 +30,7 @@ /* $FreeBSD$ */ -#include +#include #define FM_SET_FREQ _IOWR('U', 200, int) #define FM_GET_FREQ _IOWR('U', 201, int) diff --git a/freebsd/sys/dev/usb/usb.h b/freebsd/sys/dev/usb/usb.h index 9a6cb8f7..433a0471 100644 --- a/freebsd/sys/dev/usb/usb.h +++ b/freebsd/sys/dev/usb/usb.h @@ -36,26 +36,26 @@ * USB v3.0 */ -#ifndef _USB_STANDARD_HH_ -#define _USB_STANDARD_HH_ +#ifndef _USB_STANDARD_H_ +#define _USB_STANDARD_H_ #if defined(_KERNEL) -#include +#include /* Declare parent SYSCTL USB node. */ #ifdef SYSCTL_DECL SYSCTL_DECL(_hw_usb); #endif -#include +#include MALLOC_DECLARE(M_USB); MALLOC_DECLARE(M_USBDEV); MALLOC_DECLARE(M_USBHC); #endif /* _KERNEL */ -#include -#include +#include +#include #define USB_STACK_VERSION 2000 /* 2.0 */ @@ -752,4 +752,4 @@ enum usb_dev_state { USB_STATE_CONFIGURED, }; #define USB_STATE_MAX (USB_STATE_CONFIGURED+1) -#endif /* _USB_STANDARD_HH_ */ +#endif /* _USB_STANDARD_H_ */ diff --git a/freebsd/sys/dev/usb/usb_bus.h b/freebsd/sys/dev/usb/usb_bus.h index b437fac0..c9840fcb 100644 --- a/freebsd/sys/dev/usb/usb_bus.h +++ b/freebsd/sys/dev/usb/usb_bus.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_BUS_HH_ -#define _USB_BUS_HH_ +#ifndef _USB_BUS_H_ +#define _USB_BUS_H_ /* * The following structure defines the USB explore message sent to the USB @@ -111,4 +111,4 @@ struct usb_bus { } scratch[1]; }; -#endif /* _USB_BUS_HH_ */ +#endif /* _USB_BUS_H_ */ diff --git a/freebsd/sys/dev/usb/usb_busdma.c b/freebsd/sys/dev/usb/usb_busdma.c index 979136b8..e08bcbd3 100644 --- a/freebsd/sys/dev/usb/usb_busdma.c +++ b/freebsd/sys/dev/usb/usb_busdma.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,42 +26,42 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #if USB_HAVE_BUSDMA static void usb_dma_tag_create(struct usb_dma_tag *, usb_size_t, usb_size_t); diff --git a/freebsd/sys/dev/usb/usb_busdma.h b/freebsd/sys/dev/usb/usb_busdma.h index bd761819..6b6e4039 100644 --- a/freebsd/sys/dev/usb/usb_busdma.h +++ b/freebsd/sys/dev/usb/usb_busdma.h @@ -24,13 +24,13 @@ * SUCH DAMAGE. */ -#ifndef _USB_BUSDMA_HH_ -#define _USB_BUSDMA_HH_ +#ifndef _USB_BUSDMA_H_ +#define _USB_BUSDMA_H_ -#include -#include +#include +#include -#include +#include /* defines */ @@ -158,4 +158,4 @@ void usb_pc_cpu_invalidate(struct usb_page_cache *pc); void usb_pc_dmamap_destroy(struct usb_page_cache *pc); void usb_pc_free_mem(struct usb_page_cache *pc); -#endif /* _USB_BUSDMA_HH_ */ +#endif /* _USB_BUSDMA_H_ */ diff --git a/freebsd/sys/dev/usb/usb_cdc.h b/freebsd/sys/dev/usb/usb_cdc.h index 632cfe9c..23fd111c 100644 --- a/freebsd/sys/dev/usb/usb_cdc.h +++ b/freebsd/sys/dev/usb/usb_cdc.h @@ -38,8 +38,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _USB_CDC_HH_ -#define _USB_CDC_HH_ +#ifndef _USB_CDC_H_ +#define _USB_CDC_H_ #define UDESCSUB_CDC_HEADER 0 #define UDESCSUB_CDC_CM 1 /* Call Management */ @@ -292,4 +292,4 @@ struct usb_ncm_parameters { #define UCDC_NCM_NOTIF_RESPONSE_AVAILABLE 0x01 #define UCDC_NCM_NOTIF_CONNECTION_SPEED_CHANGE 0x2A -#endif /* _USB_CDC_HH_ */ +#endif /* _USB_CDC_H_ */ diff --git a/freebsd/sys/dev/usb/usb_controller.h b/freebsd/sys/dev/usb/usb_controller.h index 8f3f3de4..6b15dab9 100644 --- a/freebsd/sys/dev/usb/usb_controller.h +++ b/freebsd/sys/dev/usb/usb_controller.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_CONTROLLER_HH_ -#define _USB_CONTROLLER_HH_ +#ifndef _USB_CONTROLLER_H_ +#define _USB_CONTROLLER_H_ /* defines */ @@ -222,4 +222,4 @@ uint16_t usb_isoc_time_expand(struct usb_bus *bus, uint16_t isoc_time_curr); uint16_t usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, struct usb_fs_isoc_schedule **pp_start, struct usb_fs_isoc_schedule **pp_end, uint16_t isoc_time); uint8_t usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len); -#endif /* _USB_CONTROLLER_HH_ */ +#endif /* _USB_CONTROLLER_H_ */ diff --git a/freebsd/sys/dev/usb/usb_core.c b/freebsd/sys/dev/usb/usb_core.c index 17f9d903..38504363 100644 --- a/freebsd/sys/dev/usb/usb_core.c +++ b/freebsd/sys/dev/usb/usb_core.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -32,28 +32,28 @@ * http://www.usb.org/developers/devclass_docs/ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include MALLOC_DEFINE(M_USB, "USB", "USB"); MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device"); diff --git a/freebsd/sys/dev/usb/usb_core.h b/freebsd/sys/dev/usb/usb_core.h index 9d724171..3dfd0d1a 100644 --- a/freebsd/sys/dev/usb/usb_core.h +++ b/freebsd/sys/dev/usb/usb_core.h @@ -28,8 +28,8 @@ * Including this file is mandatory for all USB related c-files in the kernel. */ -#ifndef _USB_CORE_HH_ -#define _USB_CORE_HH_ +#ifndef _USB_CORE_H_ +#define _USB_CORE_H_ /* * The following macro will tell if an USB transfer is currently @@ -180,4 +180,4 @@ typedef struct malloc_type *usb_malloc_type; /* prototypes */ -#endif /* _USB_CORE_HH_ */ +#endif /* _USB_CORE_H_ */ diff --git a/freebsd/sys/dev/usb/usb_debug.c b/freebsd/sys/dev/usb/usb_debug.c index 907d31e1..40dafa20 100644 --- a/freebsd/sys/dev/usb/usb_debug.c +++ b/freebsd/sys/dev/usb/usb_debug.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,38 +26,38 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include /* * Define this unconditionally in case a kernel module is loaded that diff --git a/freebsd/sys/dev/usb/usb_debug.h b/freebsd/sys/dev/usb/usb_debug.h index aa3a5a49..8718c89b 100644 --- a/freebsd/sys/dev/usb/usb_debug.h +++ b/freebsd/sys/dev/usb/usb_debug.h @@ -26,8 +26,8 @@ /* This file contains various factored out debug macros. */ -#ifndef _USB_DEBUG_HH_ -#define _USB_DEBUG_HH_ +#ifndef _USB_DEBUG_H_ +#define _USB_DEBUG_H_ /* Declare global USB debug variable. */ extern int usb_debug; @@ -59,4 +59,4 @@ void usb_dump_queue(struct usb_endpoint *ep); void usb_dump_endpoint(struct usb_endpoint *ep); void usb_dump_xfer(struct usb_xfer *xfer); -#endif /* _USB_DEBUG_HH_ */ +#endif /* _USB_DEBUG_H_ */ diff --git a/freebsd/sys/dev/usb/usb_dev.c b/freebsd/sys/dev/usb/usb_dev.c index 3517f7cc..eaad5952 100644 --- a/freebsd/sys/dev/usb/usb_dev.c +++ b/freebsd/sys/dev/usb/usb_dev.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -29,57 +29,57 @@ * usb_dev.c - An abstraction layer for creating devices under /dev/... */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define USB_DEBUG_VAR usb_fifo_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include #if USB_HAVE_UGEN diff --git a/freebsd/sys/dev/usb/usb_dev.h b/freebsd/sys/dev/usb/usb_dev.h index ccf873bd..aa9197f5 100644 --- a/freebsd/sys/dev/usb/usb_dev.h +++ b/freebsd/sys/dev/usb/usb_dev.h @@ -24,14 +24,14 @@ * SUCH DAMAGE. */ -#ifndef _USB_DEV_HH_ -#define _USB_DEV_HH_ +#ifndef _USB_DEV_H_ +#define _USB_DEV_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include struct usb_fifo; struct usb_mbuf; @@ -151,4 +151,4 @@ void usb_free_symlink(struct usb_symlink *ps); int usb_read_symlink(uint8_t *user_ptr, uint32_t startentry, uint32_t user_len); -#endif /* _USB_DEV_HH_ */ +#endif /* _USB_DEV_H_ */ diff --git a/freebsd/sys/dev/usb/usb_device.c b/freebsd/sys/dev/usb/usb_device.c index 1d5b5182..a2db2727 100644 --- a/freebsd/sys/dev/usb/usb_device.c +++ b/freebsd/sys/dev/usb/usb_device.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,61 +26,61 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #if USB_HAVE_UGEN -#include +#include #endif -#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if USB_HAVE_UGEN -#include -#include +#include +#include #endif -#include +#include -#include -#include +#include +#include /* function prototypes */ @@ -2216,8 +2216,8 @@ struct usb_knowndev { #define USB_KNOWNDEV_NOPROD 0x01 /* match on vendor only */ -#include -#include +#include +#include #endif /* USB_VERBOSE */ static void diff --git a/freebsd/sys/dev/usb/usb_device.h b/freebsd/sys/dev/usb/usb_device.h index eb6a3fcb..c8bc5eb9 100644 --- a/freebsd/sys/dev/usb/usb_device.h +++ b/freebsd/sys/dev/usb/usb_device.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_DEVICE_HH_ -#define _USB_DEVICE_HH_ +#ifndef _USB_DEVICE_H_ +#define _USB_DEVICE_H_ struct usb_symlink; /* UGEN */ struct usb_device; /* linux compat */ @@ -224,4 +224,4 @@ void usbd_sr_lock(struct usb_device *); void usbd_sr_unlock(struct usb_device *); uint8_t usbd_enum_is_locked(struct usb_device *); -#endif /* _USB_DEVICE_HH_ */ +#endif /* _USB_DEVICE_H_ */ diff --git a/freebsd/sys/dev/usb/usb_dynamic.c b/freebsd/sys/dev/usb/usb_dynamic.c index 7651f97e..cb54d10f 100644 --- a/freebsd/sys/dev/usb/usb_dynamic.c +++ b/freebsd/sys/dev/usb/usb_dynamic.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,33 +26,33 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include /* function prototypes */ static usb_handle_req_t usb_temp_get_desc_w; diff --git a/freebsd/sys/dev/usb/usb_dynamic.h b/freebsd/sys/dev/usb/usb_dynamic.h index 32fc8362..56849420 100644 --- a/freebsd/sys/dev/usb/usb_dynamic.h +++ b/freebsd/sys/dev/usb/usb_dynamic.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_DYNAMIC_HH_ -#define _USB_DYNAMIC_HH_ +#ifndef _USB_DYNAMIC_H_ +#define _USB_DYNAMIC_H_ /* prototypes */ @@ -58,4 +58,4 @@ void usb_temp_unload(void *); void usb_quirk_unload(void *); void usb_bus_unload(void *); -#endif /* _USB_DYNAMIC_HH_ */ +#endif /* _USB_DYNAMIC_H_ */ diff --git a/freebsd/sys/dev/usb/usb_endian.h b/freebsd/sys/dev/usb/usb_endian.h index 54c965d7..29479f13 100644 --- a/freebsd/sys/dev/usb/usb_endian.h +++ b/freebsd/sys/dev/usb/usb_endian.h @@ -24,11 +24,11 @@ * SUCH DAMAGE. */ -#ifndef _USB_ENDIAN_HH_ -#define _USB_ENDIAN_HH_ +#ifndef _USB_ENDIAN_H_ +#define _USB_ENDIAN_H_ -#include -#include +#include +#include /* * Declare the basic USB record types. USB records have an alignment @@ -116,4 +116,4 @@ typedef uint8_t uQWord[8]; (w)[7] = (uint8_t)(b7); \ } while (0) -#endif /* _USB_ENDIAN_HH_ */ +#endif /* _USB_ENDIAN_H_ */ diff --git a/freebsd/sys/dev/usb/usb_error.c b/freebsd/sys/dev/usb/usb_error.c index b9798a15..4505490d 100644 --- a/freebsd/sys/dev/usb/usb_error.c +++ b/freebsd/sys/dev/usb/usb_error.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,28 +26,28 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include static const char* usb_errstr_table[USB_ERR_MAX] = { [USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION", diff --git a/freebsd/sys/dev/usb/usb_freebsd.h b/freebsd/sys/dev/usb/usb_freebsd.h index ed0f0356..3045ec32 100644 --- a/freebsd/sys/dev/usb/usb_freebsd.h +++ b/freebsd/sys/dev/usb/usb_freebsd.h @@ -28,8 +28,8 @@ * Including this file is mandatory for all USB related c-files in the kernel. */ -#ifndef _USB_FREEBSD_HH_ -#define _USB_FREEBSD_HH_ +#ifndef _USB_FREEBSD_H_ +#define _USB_FREEBSD_H_ /* Default USB configuration */ #ifndef __rtems__ @@ -66,4 +66,4 @@ typedef uint32_t usb_size_t; /* bytes */ typedef uint32_t usb_ticks_t; /* system defined */ typedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */ -#endif /* _USB_FREEBSD_HH_ */ +#endif /* _USB_FREEBSD_H_ */ diff --git a/freebsd/sys/dev/usb/usb_generic.c b/freebsd/sys/dev/usb/usb_generic.c index 89217a93..60b24794 100644 --- a/freebsd/sys/dev/usb/usb_generic.c +++ b/freebsd/sys/dev/usb/usb_generic.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,50 +26,50 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define USB_DEBUG_VAR ugen_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #if USB_HAVE_UGEN diff --git a/freebsd/sys/dev/usb/usb_generic.h b/freebsd/sys/dev/usb/usb_generic.h index 17506001..835ec72a 100644 --- a/freebsd/sys/dev/usb/usb_generic.h +++ b/freebsd/sys/dev/usb/usb_generic.h @@ -24,10 +24,10 @@ * SUCH DAMAGE. */ -#ifndef _USB_GENERIC_HH_ -#define _USB_GENERIC_HH_ +#ifndef _USB_GENERIC_H_ +#define _USB_GENERIC_H_ extern struct usb_fifo_methods usb_ugen_methods; int ugen_do_request(struct usb_fifo *f, struct usb_ctl_request *ur); -#endif /* _USB_GENERIC_HH_ */ +#endif /* _USB_GENERIC_H_ */ diff --git a/freebsd/sys/dev/usb/usb_handle_request.c b/freebsd/sys/dev/usb/usb_handle_request.c index 40428d8b..97d30394 100644 --- a/freebsd/sys/dev/usb/usb_handle_request.c +++ b/freebsd/sys/dev/usb/usb_handle_request.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,44 +26,44 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include /* function prototypes */ diff --git a/freebsd/sys/dev/usb/usb_hid.c b/freebsd/sys/dev/usb/usb_hid.c index b1780aff..e99cdb0b 100644 --- a/freebsd/sys/dev/usb/usb_hid.c +++ b/freebsd/sys/dev/usb/usb_hid.c @@ -1,9 +1,9 @@ -#include +#include /* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -42,38 +42,38 @@ __FBSDID("$FreeBSD$"); * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static void hid_clear_local(struct hid_item *); static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize); diff --git a/freebsd/sys/dev/usb/usb_hub.c b/freebsd/sys/dev/usb/usb_hub.c index 4f34f25e..c20bde30 100644 --- a/freebsd/sys/dev/usb/usb_hub.c +++ b/freebsd/sys/dev/usb/usb_hub.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -32,46 +32,46 @@ * USB spec: http://www.usb.org/developers/docs/usbspec.zip */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #define USB_DEBUG_VAR uhub_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define UHUB_INTR_INTERVAL 250 /* ms */ #define UHUB_N_TRANSFER 1 diff --git a/freebsd/sys/dev/usb/usb_hub.h b/freebsd/sys/dev/usb/usb_hub.h index 6f4637da..0f595997 100644 --- a/freebsd/sys/dev/usb/usb_hub.h +++ b/freebsd/sys/dev/usb/usb_hub.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_HUB_HH_ -#define _USB_HUB_HH_ +#ifndef _USB_HUB_H_ +#define _USB_HUB_H_ /* * The following structure defines an USB port. @@ -80,4 +80,4 @@ void usb_bus_powerd(struct usb_bus *bus); void uhub_root_intr(struct usb_bus *, const uint8_t *, uint8_t); usb_error_t uhub_query_info(struct usb_device *, uint8_t *, uint8_t *); -#endif /* _USB_HUB_HH_ */ +#endif /* _USB_HUB_H_ */ diff --git a/freebsd/sys/dev/usb/usb_ioctl.h b/freebsd/sys/dev/usb/usb_ioctl.h index 99e21f09..f9018e28 100644 --- a/freebsd/sys/dev/usb/usb_ioctl.h +++ b/freebsd/sys/dev/usb/usb_ioctl.h @@ -26,15 +26,15 @@ * SUCH DAMAGE. */ -#ifndef _USB_IOCTL_HH_ -#define _USB_IOCTL_HH_ +#ifndef _USB_IOCTL_H_ +#define _USB_IOCTL_H_ -#include +#include /* Building "kdump" depends on these includes */ -#include -#include +#include +#include #define USB_DEVICE_NAME "usbctl" #define USB_DEVICE_DIR "usb" @@ -269,4 +269,4 @@ struct usb_gen_quirk { #define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk) #define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk) -#endif /* _USB_IOCTL_HH_ */ +#endif /* _USB_IOCTL_H_ */ diff --git a/freebsd/sys/dev/usb/usb_lookup.c b/freebsd/sys/dev/usb/usb_lookup.c index c730b6ba..b7ce2522 100644 --- a/freebsd/sys/dev/usb/usb_lookup.c +++ b/freebsd/sys/dev/usb/usb_lookup.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,28 +26,28 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include /*------------------------------------------------------------------------* * usbd_lookup_id_by_info diff --git a/freebsd/sys/dev/usb/usb_mbuf.c b/freebsd/sys/dev/usb/usb_mbuf.c index 5aa99df4..f2649679 100644 --- a/freebsd/sys/dev/usb/usb_mbuf.c +++ b/freebsd/sys/dev/usb/usb_mbuf.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,30 +26,30 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include /*------------------------------------------------------------------------* * usb_alloc_mbufs - allocate mbufs to an usbd interface queue diff --git a/freebsd/sys/dev/usb/usb_mbuf.h b/freebsd/sys/dev/usb/usb_mbuf.h index 44dba71b..3b331ffc 100644 --- a/freebsd/sys/dev/usb/usb_mbuf.h +++ b/freebsd/sys/dev/usb/usb_mbuf.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_MBUF_HH_ -#define _USB_MBUF_HH_ +#ifndef _USB_MBUF_H_ +#define _USB_MBUF_H_ /* * The following structure defines a minimum re-implementation of the @@ -87,4 +87,4 @@ struct usb_mbuf { void *usb_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, usb_size_t block_size, uint16_t nblocks); -#endif /* _USB_MBUF_HH_ */ +#endif /* _USB_MBUF_H_ */ diff --git a/freebsd/sys/dev/usb/usb_msctest.c b/freebsd/sys/dev/usb/usb_msctest.c index 0b773e29..77f199be 100644 --- a/freebsd/sys/dev/usb/usb_msctest.c +++ b/freebsd/sys/dev/usb/usb_msctest.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -34,42 +34,42 @@ * mass storage quirks for not supported SCSI commands! */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include enum { ST_COMMAND, diff --git a/freebsd/sys/dev/usb/usb_msctest.h b/freebsd/sys/dev/usb/usb_msctest.h index 6ba2c3fd..807d5f5d 100644 --- a/freebsd/sys/dev/usb/usb_msctest.h +++ b/freebsd/sys/dev/usb/usb_msctest.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_MSCTEST_HH_ -#define _USB_MSCTEST_HH_ +#ifndef _USB_MSCTEST_H_ +#define _USB_MSCTEST_H_ enum { MSC_EJECT_STOPUNIT, @@ -41,4 +41,4 @@ int usb_iface_is_cdrom(struct usb_device *udev, usb_error_t usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method); -#endif /* _USB_MSCTEST_HH_ */ +#endif /* _USB_MSCTEST_H_ */ diff --git a/freebsd/sys/dev/usb/usb_parse.c b/freebsd/sys/dev/usb/usb_parse.c index 8681a94a..6b055db7 100644 --- a/freebsd/sys/dev/usb/usb_parse.c +++ b/freebsd/sys/dev/usb/usb_parse.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,29 +26,29 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include /*------------------------------------------------------------------------* diff --git a/freebsd/sys/dev/usb/usb_process.c b/freebsd/sys/dev/usb/usb_process.c index cfaa5ee6..67ddf693 100644 --- a/freebsd/sys/dev/usb/usb_process.c +++ b/freebsd/sys/dev/usb/usb_process.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -28,36 +28,36 @@ #define USB_DEBUG_VAR usb_proc_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include #if (__FreeBSD_version < 700000) #define thread_lock(td) mtx_lock_spin(&sched_lock) diff --git a/freebsd/sys/dev/usb/usb_process.h b/freebsd/sys/dev/usb/usb_process.h index 75c86ece..f9a3c38d 100644 --- a/freebsd/sys/dev/usb/usb_process.h +++ b/freebsd/sys/dev/usb/usb_process.h @@ -24,10 +24,10 @@ * SUCH DAMAGE. */ -#ifndef _USB_PROCESS_HH_ -#define _USB_PROCESS_HH_ +#ifndef _USB_PROCESS_H_ +#define _USB_PROCESS_H_ -#include +#include /* defines */ #define USB_PRI_HIGH PI_NET @@ -81,4 +81,4 @@ void usb_proc_free(struct usb_process *up); void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1); void usb_proc_rewakeup(struct usb_process *up); -#endif /* _USB_PROCESS_HH_ */ +#endif /* _USB_PROCESS_H_ */ diff --git a/freebsd/sys/dev/usb/usb_request.c b/freebsd/sys/dev/usb/usb_request.c index 61dafd7d..8d17c202 100644 --- a/freebsd/sys/dev/usb/usb_request.c +++ b/freebsd/sys/dev/usb/usb_request.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -28,47 +28,47 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #ifdef USB_DEBUG static int usb_pr_poll_delay = USB_PORT_RESET_DELAY; diff --git a/freebsd/sys/dev/usb/usb_request.h b/freebsd/sys/dev/usb/usb_request.h index 0cf882dc..12f373d5 100644 --- a/freebsd/sys/dev/usb/usb_request.h +++ b/freebsd/sys/dev/usb/usb_request.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_REQUEST_HH_ -#define _USB_REQUEST_HH_ +#ifndef _USB_REQUEST_H_ +#define _USB_REQUEST_H_ struct usb_process; @@ -86,4 +86,4 @@ usb_error_t usbd_req_set_hub_u2_timeout(struct usb_device *udev, usb_error_t usbd_req_set_hub_depth(struct usb_device *udev, struct mtx *mtx, uint16_t depth); -#endif /* _USB_REQUEST_HH_ */ +#endif /* _USB_REQUEST_H_ */ diff --git a/freebsd/sys/dev/usb/usb_transfer.c b/freebsd/sys/dev/usb/usb_transfer.c index caf3d31b..17a492e5 100644 --- a/freebsd/sys/dev/usb/usb_transfer.c +++ b/freebsd/sys/dev/usb/usb_transfer.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,44 +26,44 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #define USB_DEBUG_VAR usb_debug -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef __rtems__ -#include +#include #endif /* __rtems__ */ struct usb_std_packet_size { diff --git a/freebsd/sys/dev/usb/usb_transfer.h b/freebsd/sys/dev/usb/usb_transfer.h index eb2abd0c..71157ca7 100644 --- a/freebsd/sys/dev/usb/usb_transfer.h +++ b/freebsd/sys/dev/usb/usb_transfer.h @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#ifndef _USB_TRANSFER_HH_ -#define _USB_TRANSFER_HH_ +#ifndef _USB_TRANSFER_H_ +#define _USB_TRANSFER_H_ /* * The following structure defines the messages that is used to signal @@ -137,4 +137,4 @@ void usbd_transfer_timeout_ms(struct usb_xfer *xfer, usb_timeout_t usbd_get_dma_delay(struct usb_device *udev); void usbd_transfer_power_ref(struct usb_xfer *xfer, int val); -#endif /* _USB_TRANSFER_HH_ */ +#endif /* _USB_TRANSFER_H_ */ diff --git a/freebsd/sys/dev/usb/usb_util.c b/freebsd/sys/dev/usb/usb_util.c index 3bd1f8c4..14c0476a 100644 --- a/freebsd/sys/dev/usb/usb_util.c +++ b/freebsd/sys/dev/usb/usb_util.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /*- @@ -26,39 +26,39 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include /*------------------------------------------------------------------------* * device_delete_all_children - delete all children of a device diff --git a/freebsd/sys/dev/usb/usb_util.h b/freebsd/sys/dev/usb/usb_util.h index 9e001088..35abeddd 100644 --- a/freebsd/sys/dev/usb/usb_util.h +++ b/freebsd/sys/dev/usb/usb_util.h @@ -24,12 +24,12 @@ * SUCH DAMAGE. */ -#ifndef _USB_UTIL_HH_ -#define _USB_UTIL_HH_ +#ifndef _USB_UTIL_H_ +#define _USB_UTIL_H_ int device_delete_all_children(device_t dev); uint8_t usb_make_str_desc(void *ptr, uint16_t max_len, const char *s); void usb_printbcd(char *p, uint16_t p_len, uint16_t bcd); void usb_trim_spaces(char *p); -#endif /* _USB_UTIL_HH_ */ +#endif /* _USB_UTIL_H_ */ diff --git a/freebsd/sys/dev/usb/usbdi.h b/freebsd/sys/dev/usb/usbdi.h index a3f0630f..1c2d412b 100644 --- a/freebsd/sys/dev/usb/usbdi.h +++ b/freebsd/sys/dev/usb/usbdi.h @@ -23,8 +23,8 @@ * * $FreeBSD$ */ -#ifndef _USB_USBDI_HH_ -#define _USB_USBDI_HH_ +#ifndef _USB_USBDI_H_ +#define _USB_USBDI_H_ struct usb_fifo; struct usb_xfer; @@ -101,7 +101,7 @@ typedef void (usb_fifo_filter_t)(struct usb_fifo *fifo, struct usb_mbuf *m); /* USB events */ -#include +#include typedef void (*usb_dev_configured_t)(void *, struct usb_device *, struct usb_attach_arg *); EVENTHANDLER_DECLARE(usb_dev_configured, usb_dev_configured_t); @@ -559,4 +559,4 @@ void usb_fifo_set_close_zlp(struct usb_fifo *, uint8_t); void usb_fifo_set_write_defrag(struct usb_fifo *, uint8_t); void usb_fifo_free(struct usb_fifo *f); #endif /* _KERNEL */ -#endif /* _USB_USBDI_HH_ */ +#endif /* _USB_USBDI_H_ */ diff --git a/freebsd/sys/dev/usb/usbdi_util.h b/freebsd/sys/dev/usb/usbdi_util.h index 32931e52..1e450f8f 100644 --- a/freebsd/sys/dev/usb/usbdi_util.h +++ b/freebsd/sys/dev/usb/usbdi_util.h @@ -23,8 +23,8 @@ * * $FreeBSD$ */ -#ifndef _USB_USBDI_UTIL_HH_ -#define _USB_USBDI_UTIL_HH_ +#ifndef _USB_USBDI_UTIL_H_ +#define _USB_USBDI_UTIL_H_ struct cv; @@ -88,4 +88,4 @@ const char *usb_get_manufacturer(struct usb_device *); const char *usb_get_product(struct usb_device *); const char *usb_get_serial(struct usb_device *); -#endif /* _USB_USBDI_UTIL_HH_ */ +#endif /* _USB_USBDI_UTIL_H_ */ diff --git a/freebsd/sys/dev/usb/usbhid.h b/freebsd/sys/dev/usb/usbhid.h index 192a2359..c07454f7 100644 --- a/freebsd/sys/dev/usb/usbhid.h +++ b/freebsd/sys/dev/usb/usbhid.h @@ -26,10 +26,10 @@ * SUCH DAMAGE. */ -#ifndef _USB_HID_HH_ -#define _USB_HID_HH_ +#ifndef _USB_HID_H_ +#define _USB_HID_H_ -#include +#include #define UR_GET_HID_DESCRIPTOR 0x06 #define UDESC_HID 0x21 @@ -241,4 +241,4 @@ usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx, void **descp, uint16_t *sizep, struct malloc_type *mem, uint8_t iface_index); #endif /* _KERNEL */ -#endif /* _USB_HID_HH_ */ +#endif /* _USB_HID_H_ */ diff --git a/freebsd/sys/fs/devfs/devfs_int.h b/freebsd/sys/fs/devfs/devfs_int.h index 723cbc22..aa06e374 100644 --- a/freebsd/sys/fs/devfs/devfs_int.h +++ b/freebsd/sys/fs/devfs/devfs_int.h @@ -30,10 +30,10 @@ * by kern/kern_conf.c and fs/devfs/... */ -#ifndef _FS_DEVFS_DEVFS_INT_HH_ -#define _FS_DEVFS_DEVFS_INT_HH_ +#ifndef _FS_DEVFS_DEVFS_INT_H_ +#define _FS_DEVFS_DEVFS_INT_H_ -#include +#include #ifdef _KERNEL @@ -87,4 +87,4 @@ extern TAILQ_HEAD(cdev_priv_list, cdev_priv) cdevp_list; #endif /* _KERNEL */ -#endif /* !_FS_DEVFS_DEVFS_INT_HH_ */ +#endif /* !_FS_DEVFS_DEVFS_INT_H_ */ diff --git a/freebsd/sys/h8300/h8300/in_cksum.c b/freebsd/sys/h8300/h8300/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/h8300/h8300/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/h8300/h8300/legacy.c b/freebsd/sys/h8300/h8300/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/h8300/h8300/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/h8300/include/machine/in_cksum.h b/freebsd/sys/h8300/include/machine/in_cksum.h index 25634a6e..37d88e2e 100644 --- a/freebsd/sys/h8300/include/machine/in_cksum.h +++ b/freebsd/sys/h8300/include/machine/in_cksum.h @@ -29,15 +29,16 @@ * from tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg * $FreeBSD$ */ -#ifndef _MACHINE_IN_CKSUM_HH_ -#define _MACHINE_IN_CKSUM_HH_ 1 +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 -#include +#include -#define in_cksum(m, len) in_cksum_skip(m, len, 0) +#define in_cksum(m, len) in_cksum_skip(m, len, 0) /* * It it useful to have an Internet checksum routine which is inlineable @@ -57,20 +58,20 @@ in_cksum_update(struct ip *ip) #else -#define in_cksum_update(ip) \ - do { \ - int __tmpsum; \ - __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ } while(0) #endif #ifdef _KERNEL u_int in_cksum_hdr(const struct ip *ip); -u_short in_addword(u_short sum, u_short b); -u_short in_pseudo(u_int sum, u_int b, u_int c); -u_short in_cksum_skip(struct mbuf *m, int len, int skip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); #endif -#endif /* _MACHINE_IN_CKSUM_HH_ */ +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/h8300/include/machine/legacyvar.h b/freebsd/sys/h8300/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/h8300/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/h8300/include/machine/pci_cfgreg.h b/freebsd/sys/h8300/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/h8300/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/h8300/pci/pci_bus.c b/freebsd/sys/h8300/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/h8300/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/i386/i386/in_cksum.c b/freebsd/sys/i386/i386/in_cksum.c index 0f663989..77102b14 100644 --- a/freebsd/sys/i386/i386/in_cksum.c +++ b/freebsd/sys/i386/i386/in_cksum.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990 The Regents of the University of California. @@ -32,18 +32,18 @@ * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include /* * Checksum routine for Internet Protocol family headers. diff --git a/freebsd/sys/i386/i386/legacy.c b/freebsd/sys/i386/i386/legacy.c index 24021809..2547990c 100644 --- a/freebsd/sys/i386/i386/legacy.c +++ b/freebsd/sys/i386/i386/legacy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1998 Massachusetts Institute of Technology @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -37,27 +37,27 @@ __FBSDID("$FreeBSD$"); * support ACPI or when ACPI support is not present in the kernel. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ #ifdef DEV_MCA -#include +#include #endif -#include -#include +#include +#include static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); struct legacy_device { diff --git a/freebsd/sys/i386/include/machine/cpufunc.h b/freebsd/sys/i386/include/machine/cpufunc.h index 093e38a4..fd8f2ddc 100644 --- a/freebsd/sys/i386/include/machine/cpufunc.h +++ b/freebsd/sys/i386/include/machine/cpufunc.h @@ -35,10 +35,10 @@ * used in preference to this. */ -#ifndef _MACHINE_CPUFUNC_HH_ -#define _MACHINE_CPUFUNC_HH_ +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ -#ifndef _SYS_CDEFS_HH_ +#ifndef _SYS_CDEFS_H_ #error this file needs sys/cdefs.h as a prerequisite #endif @@ -758,4 +758,4 @@ int rdmsr_safe(u_int msr, uint64_t *val); int wrmsr_safe(u_int msr, uint64_t newval); #endif -#endif /* !_MACHINE_CPUFUNC_HH_ */ +#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/freebsd/sys/i386/include/machine/in_cksum.h b/freebsd/sys/i386/include/machine/in_cksum.h index c121f46d..c692f69a 100644 --- a/freebsd/sys/i386/include/machine/in_cksum.h +++ b/freebsd/sys/i386/include/machine/in_cksum.h @@ -25,147 +25,118 @@ * 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. - */ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR 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 tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp - * from: FreeBSD: src/sys/alpha/include/in_cksum.h,v 1.5 2000/05/06 - * * $FreeBSD$ */ -#ifndef _MACHINE_IN_CKSUM_HH_ -#define _MACHINE_IN_CKSUM_HH_ 1 +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#ifndef _SYS_CDEFS_H_ +#error this file needs sys/cdefs.h as a prerequisite +#endif + +/* + * MP safe (alfred) + */ + +#include -#include +#define in_cksum(m, len) in_cksum_skip(m, len, 0) -#define in_cksum(m, len) in_cksum_skip(m, len, 0) +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#if defined(__GNUCLIKE_ASM) && !defined(__INTEL_COMPILER) +static __inline u_int +in_cksum_hdr(const struct ip *ip) +{ + u_int sum = 0; + + __asm( + "addl %1, %0\n" + "adcl %2, %0\n" + "adcl %3, %0\n" + "adcl %4, %0\n" + "adcl %5, %0\n" + "adcl $0, %0" + : "+r" (sum) + : "g" (((const u_int32_t *)ip)[0]), + "g" (((const u_int32_t *)ip)[1]), + "g" (((const u_int32_t *)ip)[2]), + "g" (((const u_int32_t *)ip)[3]), + "g" (((const u_int32_t *)ip)[4]) + : "cc" + ); + sum = (sum & 0xffff) + (sum >> 16); + if (sum > 0xffff) + sum -= 0xffff; + + return ~sum & 0xffff; +} static __inline void in_cksum_update(struct ip *ip) { - int __tmp; - - __tmp = (int)ip->ip_sum + 1; - ip->ip_sum = __tmp + (__tmp >> 16); + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); } static __inline u_short in_addword(u_short sum, u_short b) { - u_long __ret, __tmp; - __asm( - "sll %2, 16, %0\n" - "sll %3, 16, %1\n" - "addcc %0, %1, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - : "=&r" (__ret), "=&r" (__tmp) : "r" (sum), "r" (b) : "cc"); - return (__ret); + "addw %1, %0\n" + "adcw $0, %0" + : "+r" (sum) + : "g" (b) + : "cc" + ); + return (sum); } static __inline u_short in_pseudo(u_int sum, u_int b, u_int c) { - u_long __tmp; - __asm( - "addcc %0, %3, %0\n" - "addccc %0, %4, %0\n" - "addc %0, 0, %0\n" - "sll %0, 16, %1\n" - "addcc %0, %1, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - : "=r" (sum), "=&r" (__tmp) : "0" (sum), "r" (b), "r" (c) : "cc"); + "addl %1, %0\n" + "adcl %2, %0\n" + "adcl $0, %0" + : "+r" (sum) + : "g" (b), + "g" (c) + : "cc" + ); + sum = (sum & 0xffff) + (sum >> 16); + if (sum > 0xffff) + sum -= 0xffff; return (sum); } -static __inline u_int -in_cksum_hdr(struct ip *ip) -{ - u_long __ret, __tmp1, __tmp2, __tmp3, __tmp4; +#else +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) - /* - * Use 32-bit memory accesses and additions - addition with carry only - * works for 32 bits, and fixing up alignment issues for 64 is probably - * more trouble than it's worth. - * This may read outside of the ip header, but does not cross a page - * boundary in doing so, so that should be OK. - * Actually, this specialized implementation might be overkill - using - * a generic implementation for both in_cksum_skip and in_cksum_hdr - * should not be too much more expensive. - */ -#define __LD_ADD(addr, tmp, sum, offs, mod) \ - "lduw [" #addr " + " #offs "], " #tmp "\n" \ - "add" # mod " " #sum ", " #tmp ", " #sum "\n" - - __asm( - "and %5, 3, %3\n" - "andn %5, 3, %1\n" - "brz,pt %3, 0f\n" - " lduw [%1], %0\n" - "mov 4, %4\n" - "sub %4, %3, %4\n" - "sll %4, 3, %4\n" /* fix up unaligned buffers */ - "mov 1, %2\n" - "sll %2, %4, %4\n" - "sub %4, 1, %4\n" - "lduw [%1 + 20], %2\n" - "andn %2, %4, %2\n" - "and %0, %4, %0\n" - "or %0, %2, %0\n" - "0:\n" - __LD_ADD(%1, %2, %0, 4, cc) - __LD_ADD(%1, %2, %0, 8, ccc) - __LD_ADD(%1, %2, %0, 12, ccc) - __LD_ADD(%1, %2, %0, 16, ccc) - "addc %0, 0, %0\n" /* reduce */ - "1:\n" - "sll %0, 16, %2\n" - "addcc %0, %2, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - "andcc %3, 1, %3\n" /* need to byte-swap? */ - "clr %3\n" - "bne,a,pn %%xcc, 1b\n" - " sll %0, 8, %0\n" - "not %0\n" - "sll %0, 16, %0\n" - "srl %0, 16, %0\n" - : "=&r" (__ret), "=r" (__tmp1), "=&r" (__tmp2), "=&r" (__tmp3), - "=&r" (__tmp4) : "1" (ip) : "cc"); -#undef __LD_ADD - return (__ret); -} +#endif #ifdef _KERNEL -u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER) +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); #endif +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif /* _KERNEL */ -#endif /* _MACHINE_IN_CKSUM_HH_ */ +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/i386/include/machine/legacyvar.h b/freebsd/sys/i386/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/i386/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/i386/include/machine/md_var.h b/freebsd/sys/i386/include/machine/md_var.h index 43bd0491..168ee629 100644 --- a/freebsd/sys/i386/include/machine/md_var.h +++ b/freebsd/sys/i386/include/machine/md_var.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_MD_VAR_HH_ -#define _MACHINE_MD_VAR_HH_ +#ifndef _MACHINE_MD_VAR_H_ +#define _MACHINE_MD_VAR_H_ /* * Miscellaneous machine-dependent declarations. @@ -103,4 +103,4 @@ void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); int user_dbreg_trap(void); void minidumpsys(struct dumperinfo *); -#endif /* !_MACHINE_MD_VAR_HH_ */ +#endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/freebsd/sys/i386/include/machine/pci_cfgreg.h b/freebsd/sys/i386/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/i386/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/i386/include/machine/specialreg.h b/freebsd/sys/i386/include/machine/specialreg.h index 4cbd0ec2..823f2ec3 100644 --- a/freebsd/sys/i386/include/machine/specialreg.h +++ b/freebsd/sys/i386/include/machine/specialreg.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_SPECIALREG_HH_ -#define _MACHINE_SPECIALREG_HH_ +#ifndef _MACHINE_SPECIALREG_H_ +#define _MACHINE_SPECIALREG_H_ /* * Bits in 386 special registers: @@ -593,4 +593,4 @@ #define VIA_CRYPT_CWLO_KEY192 0x0000040c /* 192bit, 12 rds */ #define VIA_CRYPT_CWLO_KEY256 0x0000080e /* 256bit, 15 rds */ -#endif /* !_MACHINE_SPECIALREG_HH_ */ +#endif /* !_MACHINE_SPECIALREG_H_ */ diff --git a/freebsd/sys/i386/pci/pci_bus.c b/freebsd/sys/i386/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/i386/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/ioccom.h b/freebsd/sys/ioccom.h deleted file mode 100644 index b8c9921e..00000000 --- a/freebsd/sys/ioccom.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)ioccom.h 8.2 (Berkeley) 3/28/94 - * $FreeBSD$ - */ - -#ifndef _SYS_IOCCOM_HH_ -#define _SYS_IOCCOM_HH_ - -/* - * Ioctl's have the command encoded in the lower word, and the size of - * any in or out parameters in the upper word. The high 3 bits of the - * upper word are used to encode the in/out status of the parameter. - */ -#define IOCPARM_SHIFT 13 /* number of bits for ioctl size */ -#define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */ -#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) -#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) -#define IOCGROUP(x) (((x) >> 8) & 0xff) - -#define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) -#define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN) - -#define _IOC(inout,group,num,len) ((unsigned long) \ - ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num))) -#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) -#define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int)) -#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) -#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) -/* this should be _IORW, but stdio got there first */ -#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) - -#ifdef _KERNEL - -#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ - defined(COMPAT_FREEBSD4) || defined(COMPAT_43) -#define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x)) -#endif - -#else - -#include - -__BEGIN_DECLS -int ioctl(int, unsigned long, ...); -__END_DECLS - -#endif - -#endif /* !_SYS_IOCCOM_HH_ */ diff --git a/freebsd/sys/isa/isavar.h b/freebsd/sys/isa/isavar.h index c27961d2..cb20402c 100644 --- a/freebsd/sys/isa/isavar.h +++ b/freebsd/sys/isa/isavar.h @@ -26,17 +26,17 @@ * $FreeBSD$ */ -#ifndef _ISA_ISAVAR_HH_ -#define _ISA_ISAVAR_HH_ +#ifndef _ISA_ISAVAR_H_ +#define _ISA_ISAVAR_H_ struct isa_config; struct isa_pnp_id; typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include +#include #ifdef _KERNEL @@ -189,7 +189,7 @@ void isa_hint_device_unit(device_t bus, device_t child, const char *name, int isab_attach(device_t dev); #ifdef PC98 -#include +#include /* * Allocate discontinuous resources for ISA bus. @@ -203,4 +203,4 @@ isa_load_resourcev(struct resource *re, bus_addr_t *res, bus_size_t count); #endif /* _KERNEL */ -#endif /* !_ISA_ISAVAR_HH_ */ +#endif /* !_ISA_ISAVAR_H_ */ diff --git a/freebsd/sys/isa/pnpvar.h b/freebsd/sys/isa/pnpvar.h index 8636ee5e..291c8130 100644 --- a/freebsd/sys/isa/pnpvar.h +++ b/freebsd/sys/isa/pnpvar.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _ISA_PNPVAR_HH_ -#define _ISA_PNPVAR_HH_ +#ifndef _ISA_PNPVAR_H_ +#define _ISA_PNPVAR_H_ #ifdef _KERNEL @@ -63,4 +63,4 @@ void pnp_check_quirks(uint32_t vendor_id, uint32_t logical_id, int ldn, #endif /* _KERNEL */ -#endif /* !_ISA_PNPVAR_HH_ */ +#endif /* !_ISA_PNPVAR_H_ */ diff --git a/freebsd/sys/kern/init_main.c b/freebsd/sys/kern/init_main.c index 0225a246..aee02576 100644 --- a/freebsd/sys/kern/init_main.c +++ b/freebsd/sys/kern/init_main.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1995 Terrence R. Lambert @@ -43,53 +43,53 @@ * @(#)init_main.c 8.9 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include void mi_startup(void); /* Should be elsewhere */ diff --git a/freebsd/sys/kern/kern_descrip.c b/freebsd/sys/kern/kern_descrip.c index 0ba063f5..0a1f3954 100644 --- a/freebsd/sys/kern/kern_descrip.c +++ b/freebsd/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -36,55 +36,55 @@ * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef KTRACE -#include +#include #endif -#include +#include -#include +#include -#include +#include static MALLOC_DEFINE(M_FILEDESC, "filedesc", "Open file descriptor table"); static MALLOC_DEFINE(M_FILEDESC_TO_LEADER, "filedesc_to_leader", @@ -267,7 +267,7 @@ fdunused(struct filedesc *fdp, int fd) /* * System calls on descriptors. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getdtablesize_args { int dummy; }; @@ -291,7 +291,7 @@ getdtablesize(struct thread *td, struct getdtablesize_args *uap) * Note: keep in mind that a potential race condition exists when closing * descriptors from a shared descriptor table (via rfork). */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct dup2_args { u_int from; u_int to; @@ -309,7 +309,7 @@ dup2(struct thread *td, struct dup2_args *uap) /* * Duplicate a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct dup_args { u_int fd; }; @@ -325,7 +325,7 @@ dup(struct thread *td, struct dup_args *uap) /* * The file control system call. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fcntl_args { int fd; int cmd; @@ -1102,7 +1102,7 @@ fgetown(sigiop) /* * Close a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct close_args { int fd; }; @@ -1179,7 +1179,7 @@ kern_close(td, fd) /* * Close open file descriptors. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct closefrom_args { int lowfd; }; @@ -1216,7 +1216,7 @@ closefrom(struct thread *td, struct closefrom_args *uap) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ofstat_args { int fd; struct ostat *sb; @@ -1242,7 +1242,7 @@ ofstat(struct thread *td, struct ofstat_args *uap) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fstat_args { int fd; struct stat *sb; @@ -1286,7 +1286,7 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct nfstat_args { int fd; struct nstat *sb; @@ -1311,7 +1311,7 @@ nfstat(struct thread *td, struct nfstat_args *uap) /* * Return pathconf information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fpathconf_args { int fd; int name; @@ -2378,7 +2378,7 @@ _fdrop(struct file *fp, struct thread *td) * Just attempt to get a record lock of the requested type on the entire file * (l_whence = SEEK_SET, l_start = 0, l_len = 0). */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct flock_args { int fd; int how; @@ -3422,8 +3422,6 @@ fdopen(struct cdev *dev, int mode, int type, struct thread *td) { /* -#include - /*- * Copyright (c) 1982, 1986, 1989, 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -3460,55 +3458,55 @@ fdopen(struct cdev *dev, int mode, int type, struct thread *td) * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef KTRACE -#include +#include #endif -#include +#include -#include +#include -#include +#include static MALLOC_DEFINE(M_FILEDESC, "filedesc", "Open file descriptor table"); static MALLOC_DEFINE(M_FILEDESC_TO_LEADER, "filedesc_to_leader", @@ -3691,7 +3689,7 @@ fdunused(struct filedesc *fdp, int fd) /* * System calls on descriptors. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getdtablesize_args { int dummy; }; @@ -3715,7 +3713,7 @@ getdtablesize(struct thread *td, struct getdtablesize_args *uap) * Note: keep in mind that a potential race condition exists when closing * descriptors from a shared descriptor table (via rfork). */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct dup2_args { u_int from; u_int to; @@ -3733,7 +3731,7 @@ dup2(struct thread *td, struct dup2_args *uap) /* * Duplicate a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct dup_args { u_int fd; }; @@ -3749,7 +3747,7 @@ dup(struct thread *td, struct dup_args *uap) /* * The file control system call. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fcntl_args { int fd; int cmd; @@ -4526,7 +4524,7 @@ fgetown(sigiop) /* * Close a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct close_args { int fd; }; @@ -4603,7 +4601,7 @@ kern_close(td, fd) /* * Close open file descriptors. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct closefrom_args { int lowfd; }; @@ -4640,7 +4638,7 @@ closefrom(struct thread *td, struct closefrom_args *uap) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ofstat_args { int fd; struct ostat *sb; @@ -4666,7 +4664,7 @@ ofstat(struct thread *td, struct ofstat_args *uap) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fstat_args { int fd; struct stat *sb; @@ -4710,7 +4708,7 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp) /* * Return status information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct nfstat_args { int fd; struct nstat *sb; @@ -4735,7 +4733,7 @@ nfstat(struct thread *td, struct nfstat_args *uap) /* * Return pathconf information about a file descriptor. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct fpathconf_args { int fd; int name; @@ -5802,7 +5800,7 @@ _fdrop(struct file *fp, struct thread *td) * Just attempt to get a record lock of the requested type on the entire file * (l_whence = SEEK_SET, l_start = 0, l_len = 0). */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct flock_args { int fd; int how; diff --git a/freebsd/sys/kern/kern_environment.c b/freebsd/sys/kern/kern_environment.c index faee420d..14549ac1 100644 --- a/freebsd/sys/kern/kern_environment.c +++ b/freebsd/sys/kern/kern_environment.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998 Michael Smith @@ -36,25 +36,25 @@ * the kernel. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include static MALLOC_DEFINE(M_KENV, "kenv", "kernel environment"); diff --git a/freebsd/sys/kern/kern_event.c b/freebsd/sys/kern/kern_event.c index 401f859e..439c22d3 100644 --- a/freebsd/sys/kern/kern_event.c +++ b/freebsd/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon @@ -28,46 +28,46 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef KTRACE -#include +#include #endif #ifndef __rtems__ -##include +##include #endif /* __rtems__ */ static MALLOC_DEFINE(M_KQUEUE, "kqueue", "memory for kqueue system"); @@ -702,7 +702,7 @@ done2: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct kevent_args { int fd; const struct kevent *changelist; diff --git a/freebsd/sys/kern/kern_intr.c b/freebsd/sys/kern/kern_intr.c index 982d5e82..bc252c13 100644 --- a/freebsd/sys/kern/kern_intr.c +++ b/freebsd/sys/kern/kern_intr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997, Stefan Esser @@ -26,41 +26,41 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include -#include +#include +#include #else /* __rtems__ */ #ifdef INTR_FILTER #error INTR_FILTER is currently not suppported with RTEMS @@ -68,8 +68,8 @@ __FBSDID("$FreeBSD$"); #define RTEMSBSD_SWI_WAKEUP_EVENT RTEMS_EVENT_31 #endif /* __rtems__ */ #ifdef DDB -#include -#include +#include +#include #endif /* diff --git a/freebsd/sys/kern/kern_linker.c b/freebsd/sys/kern/kern_linker.c index 15141f22..d2318552 100644 --- a/freebsd/sys/kern/kern_linker.c +++ b/freebsd/sys/kern/kern_linker.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997-2000 Doug Rabson @@ -26,42 +26,42 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include #ifdef HWPMC_HOOKS -#include +#include #endif #ifndef __rtems__ diff --git a/freebsd/sys/kern/kern_mbuf.c b/freebsd/sys/kern/kern_mbuf.c index cca38078..90212bf6 100644 --- a/freebsd/sys/kern/kern_mbuf.c +++ b/freebsd/sys/kern/kern_mbuf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004, 2005, @@ -27,33 +27,31 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef __rtems__ -#include -#include -#include -#include -#endif -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include /* * In FreeBSD, Mbufs and Mbuf Clusters are allocated from UMA diff --git a/freebsd/sys/kern/kern_mib.c b/freebsd/sys/kern/kern_mib.c index 0acf89e5..2acfaddb 100644 --- a/freebsd/sys/kern/kern_mib.c +++ b/freebsd/sys/kern/kern_mib.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,29 +37,29 @@ * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #ifndef __rtems__ -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifndef __rtems__ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif -#include +#include #ifdef __rtems__ char machine[] = "SET ME"; @@ -513,27 +513,27 @@ SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD, SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD, 0, 0, "Min Maximum number of types supported for timezone names"); -#include +#include SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD, 0, sizeof(struct vnode), "sizeof(struct vnode)"); SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD, 0, sizeof(struct proc), "sizeof(struct proc)"); -#include -#include +#include +#include SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD, 0, sizeof(struct bio), "sizeof(struct bio)"); SYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD, 0, sizeof(struct buf), "sizeof(struct buf)"); -#include +#include SYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD, 0, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)"); /* XXX compatibility, remove for 6.0 */ -#include -#include +#include +#include SYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW, &__elfN(fallback_brand), sizeof(__elfN(fallback_brand)), "compatibility for kern.fallback_elf_brand"); diff --git a/freebsd/sys/kern/kern_module.c b/freebsd/sys/kern/kern_module.c index 0476efef..8351c626 100644 --- a/freebsd/sys/kern/kern_module.c +++ b/freebsd/sys/kern/kern_module.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997 Doug Rabson @@ -26,25 +26,25 @@ * SUCH DAMAGE. */ -#include +#include -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static MALLOC_DEFINE(M_MODULE, "module", "module data structures"); @@ -474,11 +474,11 @@ modfind(struct thread *td, struct modfind_args *uap) MODULE_VERSION(kernel, __FreeBSD_version); #ifdef COMPAT_FREEBSD32 -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include typedef union modspecific32 { int intval; diff --git a/freebsd/sys/kern/kern_mtxpool.c b/freebsd/sys/kern/kern_mtxpool.c index b2c0267a..b5a0465b 100644 --- a/freebsd/sys/kern/kern_mtxpool.c +++ b/freebsd/sys/kern/kern_mtxpool.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Matthew Dillon. All Rights Reserved. @@ -45,17 +45,17 @@ * - possible L1 cache mastersip contention between cpus. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include static MALLOC_DEFINE(M_MTXPOOL, "mtx_pool", "mutex pool"); diff --git a/freebsd/sys/kern/kern_ntptime.c b/freebsd/sys/kern/kern_ntptime.c index 33aa4908..c49b82dd 100644 --- a/freebsd/sys/kern/kern_ntptime.c +++ b/freebsd/sys/kern/kern_ntptime.c @@ -1,4 +1,4 @@ -#include +#include /*- *********************************************************************** @@ -32,26 +32,26 @@ * confusing and/or plain wrong in that context. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * Single-precision macros for 64-bit machines @@ -266,7 +266,7 @@ ntp_gettime1(struct ntptimeval *ntvp) * See the timex.h header file for synopsis and API description. Note that * the TAI offset is returned in the ntvtimeval.tai structure member. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ntp_gettime_args { struct ntptimeval *ntvp; }; @@ -315,7 +315,7 @@ SYSCTL_OPAQUE(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD, &time_freq, sizeof * the timex.constant structure member has a dual purpose to set the time * constant and to set the TAI offset. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ntp_adjtime_args { struct timex *tp; }; @@ -924,7 +924,7 @@ hardpps(tsp, nsec) } #endif /* PPS_SYNC */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct adjtime_args { struct timeval *delta; struct timeval *olddelta; diff --git a/freebsd/sys/kern/kern_proc.c b/freebsd/sys/kern/kern_proc.c index a646aa35..30d78f08 100644 --- a/freebsd/sys/kern/kern_proc.c +++ b/freebsd/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -31,65 +31,65 @@ * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include #ifndef __rtems__ -#include -#include +#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #endif /* __rtems__ */ -#include -#include -#include +#include +#include +#include #ifdef KTRACE -#include -#include +#include +#include #endif #ifdef DDB -#include +#include #endif #ifndef __rtems__ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef COMPAT_FREEBSD32 -#include -#include +#include +#include #endif #endif /* __rtems__ */ @@ -652,9 +652,9 @@ sess_release(struct session *s) } } -#include +#include #ifdef DDB -#include +#include DB_SHOW_COMMAND(pgrpdump, pgrpdump) { diff --git a/freebsd/sys/kern/kern_prot.c b/freebsd/sys/kern/kern_prot.c index e969dfa7..f9ea3f1e 100644 --- a/freebsd/sys/kern/kern_prot.c +++ b/freebsd/sys/kern/kern_prot.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 @@ -43,45 +43,45 @@ * System calls related to processes and protection */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #ifndef __rtems__ -#include -#include +#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include +#include +#include #endif -#include -#include +#include +#include static MALLOC_DEFINE(M_CRED, "cred", "credentials"); @@ -92,7 +92,7 @@ static void crextend(struct ucred *cr, int n); static void crsetgroups_locked(struct ucred *cr, int ngrp, gid_t *groups); -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getpid_args { int dummy; }; @@ -112,7 +112,7 @@ getpid(struct thread *td, struct getpid_args *uap) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getppid_args { int dummy; }; @@ -132,7 +132,7 @@ getppid(struct thread *td, struct getppid_args *uap) /* * Get process group ID; note that POSIX getpgrp takes no parameter. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getpgrp_args { int dummy; }; @@ -149,7 +149,7 @@ getpgrp(struct thread *td, struct getpgrp_args *uap) } /* Get an arbitary pid's process group id */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getpgid_args { pid_t pid; }; @@ -181,7 +181,7 @@ getpgid(struct thread *td, struct getpgid_args *uap) /* * Get an arbitary pid's session id. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getsid_args { pid_t pid; }; @@ -210,7 +210,7 @@ getsid(struct thread *td, struct getsid_args *uap) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getuid_args { int dummy; }; @@ -227,7 +227,7 @@ getuid(struct thread *td, struct getuid_args *uap) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct geteuid_args { int dummy; }; @@ -241,7 +241,7 @@ geteuid(struct thread *td, struct geteuid_args *uap) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getgid_args { int dummy; }; @@ -263,7 +263,7 @@ getgid(struct thread *td, struct getgid_args *uap) * via getgroups. This syscall exists because it is somewhat painful to do * correctly in a library function. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getegid_args { int dummy; }; @@ -277,7 +277,7 @@ getegid(struct thread *td, struct getegid_args *uap) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getgroups_args { u_int gidsetsize; gid_t *gidset; @@ -327,7 +327,7 @@ kern_getgroups(struct thread *td, u_int *ngrp, gid_t *groups) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setsid_args { int dummy; }; @@ -384,7 +384,7 @@ setsid(register struct thread *td, struct setsid_args *uap) * there must exist some pid in same session having pgid (EPERM) * pid must not be session leader (EPERM) */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setpgid_args { int pid; /* target process id */ int pgid; /* target pgrp id */ @@ -485,7 +485,7 @@ done: */ #define POSIX_APPENDIX_B_4_2_2 -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setuid_args { uid_t uid; }; @@ -596,7 +596,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct seteuid_args { uid_t euid; }; @@ -652,7 +652,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setgid_args { gid_t gid; }; @@ -750,7 +750,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setegid_args { gid_t egid; }; @@ -796,7 +796,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setgroups_args { u_int gidsetsize; gid_t *gidset; @@ -869,7 +869,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setreuid_args { uid_t ruid; uid_t euid; @@ -936,7 +936,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setregid_args { gid_t rgid; gid_t egid; @@ -1000,7 +1000,7 @@ fail: * setresuid(ruid, euid, suid) is like setreuid except control over the saved * uid is explicit. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setresuid_args { uid_t ruid; uid_t euid; @@ -1079,7 +1079,7 @@ fail: * setresgid(rgid, egid, sgid) is like setregid except control over the saved * gid is explicit. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setresgid_args { gid_t rgid; gid_t egid; @@ -1146,7 +1146,7 @@ fail: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getresuid_args { uid_t *ruid; uid_t *euid; @@ -1173,7 +1173,7 @@ getresuid(register struct thread *td, struct getresuid_args *uap) return (error1 ? error1 : error2 ? error2 : error3); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getresgid_args { gid_t *rgid; gid_t *egid; @@ -1200,7 +1200,7 @@ getresgid(register struct thread *td, struct getresgid_args *uap) return (error1 ? error1 : error2 ? error2 : error3); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct issetugid_args { int dummy; }; @@ -2062,7 +2062,7 @@ crsetgroups(struct ucred *cr, int ngrp, gid_t *groups) /* * Get login name, if available. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getlogin_args { char *namebuf; u_int namelen; @@ -2090,7 +2090,7 @@ getlogin(struct thread *td, struct getlogin_args *uap) /* * Set login name. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setlogin_args { char *namebuf; }; diff --git a/freebsd/sys/kern/kern_resource.c b/freebsd/sys/kern/kern_resource.c index 939a1d24..fcfd2fb1 100644 --- a/freebsd/sys/kern/kern_resource.c +++ b/freebsd/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -36,36 +36,36 @@ * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include static MALLOC_DEFINE(M_PLIMIT, "plimit", "plimit structures"); @@ -86,7 +86,7 @@ static void ruxagg_locked(struct rusage_ext *rux, struct thread *td); /* * Resource controls and accounting. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getpriority_args { int which; int who; @@ -171,7 +171,7 @@ getpriority(td, uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setpriority_args { int which; int who; @@ -279,7 +279,7 @@ donice(struct thread *td, struct proc *p, int n) /* * Set realtime priority for LWP. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct rtprio_thread_args { int function; lwpid_t lwpid; @@ -363,7 +363,7 @@ rtprio_thread(struct thread *td, struct rtprio_thread_args *uap) /* * Set realtime priority. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct rtprio_args { int function; pid_t pid; @@ -534,7 +534,7 @@ pri_to_rtp(struct thread *td, struct rtprio *rtp) } #if defined(COMPAT_43) -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct osetrlimit_args { u_int which; struct orlimit *rlp; @@ -557,7 +557,7 @@ osetrlimit(td, uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ogetrlimit_args { u_int which; struct orlimit *rlp; @@ -596,7 +596,7 @@ ogetrlimit(td, uap) } #endif /* COMPAT_43 */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct __setrlimit_args { u_int which; struct rlimit *rlp; @@ -774,7 +774,7 @@ kern_setrlimit(td, which, limp) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct __getrlimit_args { u_int which; struct rlimit *rlp; @@ -924,7 +924,7 @@ calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up, sp->tv_usec = su % 1000000; } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getrusage_args { int who; struct rusage *rusage; diff --git a/freebsd/sys/kern/kern_subr.c b/freebsd/sys/kern/kern_subr.c index 9a28a7d9..663a656e 100644 --- a/freebsd/sys/kern/kern_subr.c +++ b/freebsd/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -36,38 +36,36 @@ * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif -#ifndef __rtems__ -#include -#include -#include -#endif +#include +#include +#include #ifdef __rtems__ -#include +#include #endif #ifdef ZERO_COPY_SOCKETS -#include -#include +#include +#include #endif #ifndef __rtems__ diff --git a/freebsd/sys/kern/kern_sysctl.c b/freebsd/sys/kern/kern_sysctl.c index 72da1f6d..27ac8ce7 100644 --- a/freebsd/sys/kern/kern_sysctl.c +++ b/freebsd/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -41,35 +41,35 @@ /* FIXME */ #undef sysctl #endif /* __rtems__ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef KTRACE -#include +#include #endif -#include +#include -#include +#include #ifndef __rtems__ -#include -#include +#include +#include #endif #ifdef __rtems__ @@ -1456,7 +1456,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) } #ifndef __rtems__ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct sysctl_args { int *name; u_int namelen; diff --git a/freebsd/sys/kern/kern_tc.c b/freebsd/sys/kern/kern_tc.c index 1671145b..effbe4c5 100644 --- a/freebsd/sys/kern/kern_tc.c +++ b/freebsd/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -#include +#include /*- * ---------------------------------------------------------------------------- @@ -9,19 +9,19 @@ * ---------------------------------------------------------------------------- */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /* * A large step happens on boot. This constant detects such steps. diff --git a/freebsd/sys/kern/kern_time.c b/freebsd/sys/kern/kern_time.c index 8c760b48..46b47868 100644 --- a/freebsd/sys/kern/kern_time.c +++ b/freebsd/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,36 +31,36 @@ * @(#)kern_time.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif /* __rtems__ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #define MAX_CLOCKS (CLOCK_MONOTONIC+1) @@ -171,7 +171,7 @@ settime(struct thread *td, struct timeval *tv) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct clock_gettime_args { clockid_t clock_id; struct timespec *tp; @@ -258,7 +258,7 @@ kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats) } #endif -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct clock_settime_args { clockid_t clock_id; const struct timespec *tp; @@ -296,7 +296,7 @@ kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats) } #endif -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct clock_getres_args { clockid_t clock_id; struct timespec *tp; @@ -401,7 +401,7 @@ kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt) } } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct nanosleep_args { struct timespec *rqtp; struct timespec *rmtp; @@ -432,7 +432,7 @@ nanosleep(struct thread *td, struct nanosleep_args *uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct gettimeofday_args { struct timeval *tp; struct timezone *tzp; @@ -458,7 +458,7 @@ gettimeofday(struct thread *td, struct gettimeofday_args *uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct settimeofday_args { struct timeval *tv; struct timezone *tzp; @@ -531,7 +531,7 @@ kern_settimeofday(struct thread *td, struct timeval *tv, struct timezone *tzp) * .it_interval. Rather, we compute the next time in absolute time the timer * should go off. */ -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct getitimer_args { u_int which; struct itimerval *itv; @@ -583,7 +583,7 @@ kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setitimer_args { u_int which; struct itimerval *itv, *oitv; @@ -934,7 +934,7 @@ itimer_leave(struct itimer *it) wakeup(it); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ktimer_create_args { clockid_t clock_id; struct sigevent * evp; @@ -1075,7 +1075,7 @@ out: return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ktimer_delete_args { int timerid; }; @@ -1137,7 +1137,7 @@ kern_timer_delete(struct thread *td, int timerid) return (0); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ktimer_settime_args { int timerid; int flags; @@ -1180,7 +1180,7 @@ ktimer_settime(struct thread *td, struct ktimer_settime_args *uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct ktimer_gettime_args { int timerid; struct itimerspec * value; @@ -1212,7 +1212,7 @@ ktimer_gettime(struct thread *td, struct ktimer_gettime_args *uap) return (error); } -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct timer_getoverrun_args { int timerid; }; diff --git a/freebsd/sys/kern/kern_timeout.c b/freebsd/sys/kern/kern_timeout.c index 536ca3f3..67924d08 100644 --- a/freebsd/sys/kern/kern_timeout.c +++ b/freebsd/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -36,27 +36,27 @@ * From: @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef __rtems__ int ncallout = 16; diff --git a/freebsd/sys/kern/subr_bufring.c b/freebsd/sys/kern/subr_bufring.c index 8ec8b9d7..6cc2ec6a 100644 --- a/freebsd/sys/kern/subr_bufring.c +++ b/freebsd/sys/kern/subr_bufring.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007, 2008 Kip Macy @@ -26,16 +26,16 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct buf_ring * diff --git a/freebsd/sys/kern/subr_bus.c b/freebsd/sys/kern/subr_bus.c index 9edbe777..51717b49 100644 --- a/freebsd/sys/kern/subr_bus.c +++ b/freebsd/sys/kern/subr_bus.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1997,1998,2003 Doug Rabson @@ -26,38 +26,38 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); SYSCTL_NODE(, OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); diff --git a/freebsd/sys/kern/subr_eventhandler.c b/freebsd/sys/kern/subr_eventhandler.c index af6c6295..258dc0bf 100644 --- a/freebsd/sys/kern/subr_eventhandler.c +++ b/freebsd/sys/kern/subr_eventhandler.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1999 Michael Smith @@ -26,17 +26,17 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include static MALLOC_DEFINE(M_EVENTHANDLER, "eventhandler", "Event handler records"); diff --git a/freebsd/sys/kern/subr_hints.c b/freebsd/sys/kern/subr_hints.c index dbd120e6..36133218 100644 --- a/freebsd/sys/kern/subr_hints.c +++ b/freebsd/sys/kern/subr_hints.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000,2001 Peter Wemm @@ -26,14 +26,14 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * Access functions for device resources. diff --git a/freebsd/sys/kern/subr_kobj.c b/freebsd/sys/kern/subr_kobj.c index 779fd905..e12a1f36 100644 --- a/freebsd/sys/kern/subr_kobj.c +++ b/freebsd/sys/kern/subr_kobj.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000,2003 Doug Rabson @@ -26,22 +26,22 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifndef TEST -#include +#include #endif #ifdef TEST -#include +#include #endif static MALLOC_DEFINE(M_KOBJ, "kobj", "Kernel object structures"); diff --git a/freebsd/sys/kern/subr_module.c b/freebsd/sys/kern/subr_module.c index 95d4e196..a6c9d1f5 100644 --- a/freebsd/sys/kern/subr_module.c +++ b/freebsd/sys/kern/subr_module.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998 Michael Smith @@ -26,12 +26,12 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include /* * Preloaded module support diff --git a/freebsd/sys/kern/subr_rman.c b/freebsd/sys/kern/subr_rman.c index 8561c0a4..c3c87e44 100644 --- a/freebsd/sys/kern/subr_rman.c +++ b/freebsd/sys/kern/subr_rman.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1998 Massachusetts Institute of Technology @@ -57,25 +57,25 @@ * permitted. */ -#include +#include -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include /* XXX debugging */ -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /* XXX debugging */ +#include +#include +#include #ifdef DDB -#include +#include #endif /* diff --git a/freebsd/sys/kern/subr_sbuf.c b/freebsd/sys/kern/subr_sbuf.c index 3c7b5a20..165d17a3 100644 --- a/freebsd/sys/kern/subr_sbuf.c +++ b/freebsd/sys/kern/subr_sbuf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000-2008 Poul-Henning Kamp @@ -28,27 +28,27 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #ifdef _KERNEL -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #else /* _KERNEL */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif /* _KERNEL */ -#include +#include #ifdef _KERNEL static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); diff --git a/freebsd/sys/kern/subr_unit.c b/freebsd/sys/kern/subr_unit.c index 939c03f1..1719ede8 100644 --- a/freebsd/sys/kern/subr_unit.c +++ b/freebsd/sys/kern/subr_unit.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004 Poul-Henning Kamp @@ -69,19 +69,19 @@ * N is the number of the highest unit allocated. */ -#include -#include -#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * In theory it would be smarter to allocate the individual blocks @@ -100,9 +100,9 @@ MTX_SYSINIT(unit, &unitmtx, "unit# allocation", MTX_DEF); #else /* ...USERLAND */ -#include -#include -#include +#include +#include +#include #define KASSERT(cond, arg) \ do { \ diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c index c90d632b..bc6130b6 100644 --- a/freebsd/sys/kern/sys_generic.c +++ b/freebsd/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -36,52 +36,52 @@ * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif -#include +#include #ifdef KTRACE -#include +#include #endif -#include +#include #ifdef __rtems__ typedef long fd_mask; -#include -#include -#include +#include +#include +#include #endif /* __rtems__ */ static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer"); @@ -169,7 +169,6 @@ read(td, uap) error = kern_readv(td, uap->fd, &auio); return(error); } -#endif /* * Positioned read system call @@ -204,7 +203,6 @@ pread(td, uap) return(error); } -#ifndef __rtems__ int freebsd6_pread(td, uap) struct thread *td; @@ -824,6 +822,7 @@ kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex, error = kern_select(td, nd, in, ou, ex, tvp, abi_nfdbits); return (error); } +#endif /* __rtems__ */ #ifndef _SYS_SYSPROTO_H_ struct select_args { @@ -1009,6 +1008,7 @@ done: return (error); } +#ifndef __rtems__ /* * Convert a select bit set to poll flags. * @@ -1074,6 +1074,7 @@ selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events) return (n); } +#endif /* __rtems__ */ /* * Traverse the list of fds attached to this thread's seltd and check for @@ -1082,6 +1083,7 @@ selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events) static int selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits) { +#ifndef __rtems__ struct filedesc *fdp; struct selinfo *si; struct seltd *stp; @@ -1113,6 +1115,9 @@ selrescan(struct thread *td, fd_mask **ibits, fd_mask **obits) stp->st_flags = 0; td->td_retval[0] = n; return (0); +#else /* __rtems__ */ + return (ENOMEM); +#endif /* __rtems__ */ } /* @@ -1125,6 +1130,7 @@ selscan(td, ibits, obits, nfd) fd_mask **ibits, **obits; int nfd; { +#ifndef __rtems__ struct filedesc *fdp; struct file *fp; fd_mask bit; @@ -1152,8 +1158,10 @@ selscan(td, ibits, obits, nfd) td->td_retval[0] = n; return (0); -} +#else /* __rtems__ */ + return (ENOMEM); #endif /* __rtems__ */ +} #ifndef _SYS_SYSPROTO_H_ struct poll_args { diff --git a/freebsd/sys/kern/uipc_accf.c b/freebsd/sys/kern/uipc_accf.c index fd482e64..5fa31bc5 100644 --- a/freebsd/sys/kern/uipc_accf.c +++ b/freebsd/sys/kern/uipc_accf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000 Paycounter, Inc. @@ -28,26 +28,26 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #define ACCEPT_FILTER_MOD -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static struct mtx accept_filter_mtx; MTX_SYSINIT(accept_filter, &accept_filter_mtx, "accept_filter_mtx", diff --git a/freebsd/sys/kern/uipc_domain.c b/freebsd/sys/kern/uipc_domain.c index 30eff27c..1b2be102 100644 --- a/freebsd/sys/kern/uipc_domain.c +++ b/freebsd/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -31,24 +31,24 @@ * @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include /* * System initialization diff --git a/freebsd/sys/kern/uipc_mbuf.c b/freebsd/sys/kern/uipc_mbuf.c index 8e57835c..43255aab 100644 --- a/freebsd/sys/kern/uipc_mbuf.c +++ b/freebsd/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1991, 1993 @@ -31,24 +31,24 @@ * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include int max_linkhdr; int max_protohdr; diff --git a/freebsd/sys/kern/uipc_mbuf2.c b/freebsd/sys/kern/uipc_mbuf2.c index babdf020..960a4206 100644 --- a/freebsd/sys/kern/uipc_mbuf2.c +++ b/freebsd/sys/kern/uipc_mbuf2.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: uipc_mbuf2.c,v 1.31 2001/11/28 11:08:53 itojun Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ @@ -62,20 +62,20 @@ * @(#)uipc_mbuf.c 8.4 (Berkeley) 2/14/95 */ -#include +#include __FBSDID("$FreeBSD$"); /*#define PULLDOWN_DEBUG*/ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include static MALLOC_DEFINE(M_PACKET_TAGS, MBUF_TAG_MEM_NAME, "packet-attached information"); diff --git a/freebsd/sys/kern/uipc_sockbuf.c b/freebsd/sys/kern/uipc_sockbuf.c index 3e331ee0..e711827e 100644 --- a/freebsd/sys/kern/uipc_sockbuf.c +++ b/freebsd/sys/kern/uipc_sockbuf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -31,25 +31,25 @@ * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include /* for aio_swake proto */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include /* for aio_swake proto */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * Function pointer set by the AIO routines so that the socket buffer code diff --git a/freebsd/sys/kern/uipc_socket.c b/freebsd/sys/kern/uipc_socket.c index a0ff9f53..fdea2601 100644 --- a/freebsd/sys/kern/uipc_socket.c +++ b/freebsd/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -96,52 +96,52 @@ * these interfaces are not preferred, and should be avoided. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for struct knote */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for struct knote */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include #ifdef COMPAT_FREEBSD32 -#include -#include -#include +#include +#include +#include #endif static int soreceive_rcvoob(struct socket *so, struct uio *uio, @@ -820,12 +820,12 @@ struct so_zerocopy_stats{ int found_ifp; }; struct so_zerocopy_stats so_zerocp_stats = {0,0,0}; -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * sosend_copyin() is only used if zero copy sockets are enabled. Otherwise diff --git a/freebsd/sys/libkern/arc4random.c b/freebsd/sys/libkern/arc4random.c index a43218c1..80b463f5 100644 --- a/freebsd/sys/libkern/arc4random.c +++ b/freebsd/sys/libkern/arc4random.c @@ -1,4 +1,4 @@ -#include +#include /*- * THE BEER-WARE LICENSE @@ -10,17 +10,17 @@ * Dan Moschuk */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define ARC4_RESEED_BYTES 65536 #define ARC4_RESEED_SECONDS 300 diff --git a/freebsd/sys/libkern/fls.c b/freebsd/sys/libkern/fls.c index e350c535..4b780b9d 100644 --- a/freebsd/sys/libkern/fls.c +++ b/freebsd/sys/libkern/fls.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990, 1993 @@ -29,10 +29,10 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include /* * Find Last Set bit diff --git a/freebsd/sys/libkern/inet_ntoa.c b/freebsd/sys/libkern/inet_ntoa.c index 89da6a42..288e71d7 100644 --- a/freebsd/sys/libkern/inet_ntoa.c +++ b/freebsd/sys/libkern/inet_ntoa.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1994, 1995 Massachusetts Institute of Technology @@ -29,13 +29,13 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include +#include char * inet_ntoa(struct in_addr ina) diff --git a/freebsd/sys/libkern/random.c b/freebsd/sys/libkern/random.c index 87cc9591..f5e30c34 100644 --- a/freebsd/sys/libkern/random.c +++ b/freebsd/sys/libkern/random.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1992, 1993 @@ -31,10 +31,10 @@ * @(#)random.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #define NSHUFF 50 /* to drop some "seed -> 1st value" linearity */ diff --git a/freebsd/sys/lm32/include/machine/in_cksum.h b/freebsd/sys/lm32/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/lm32/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/lm32/include/machine/legacyvar.h b/freebsd/sys/lm32/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/lm32/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/lm32/include/machine/pci_cfgreg.h b/freebsd/sys/lm32/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/lm32/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/lm32/lm32/in_cksum.c b/freebsd/sys/lm32/lm32/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/lm32/lm32/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/lm32/lm32/legacy.c b/freebsd/sys/lm32/lm32/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/lm32/lm32/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/lm32/pci/pci_bus.c b/freebsd/sys/lm32/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/lm32/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/m32c/include/machine/in_cksum.h b/freebsd/sys/m32c/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/m32c/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/m32c/include/machine/legacyvar.h b/freebsd/sys/m32c/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/m32c/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/m32c/include/machine/pci_cfgreg.h b/freebsd/sys/m32c/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/m32c/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/m32c/m32c/in_cksum.c b/freebsd/sys/m32c/m32c/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/m32c/m32c/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/m32c/m32c/legacy.c b/freebsd/sys/m32c/m32c/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/m32c/m32c/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/m32c/pci/pci_bus.c b/freebsd/sys/m32c/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/m32c/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/m32r/include/machine/in_cksum.h b/freebsd/sys/m32r/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/m32r/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/m32r/include/machine/legacyvar.h b/freebsd/sys/m32r/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/m32r/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/m32r/include/machine/pci_cfgreg.h b/freebsd/sys/m32r/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/m32r/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/m32r/m32r/in_cksum.c b/freebsd/sys/m32r/m32r/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/m32r/m32r/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/m32r/m32r/legacy.c b/freebsd/sys/m32r/m32r/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/m32r/m32r/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/m32r/pci/pci_bus.c b/freebsd/sys/m32r/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/m32r/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/m68k/include/machine/in_cksum.h b/freebsd/sys/m68k/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/m68k/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/m68k/include/machine/legacyvar.h b/freebsd/sys/m68k/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/m68k/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/m68k/include/machine/pci_cfgreg.h b/freebsd/sys/m68k/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/m68k/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/m68k/m68k/in_cksum.c b/freebsd/sys/m68k/m68k/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/m68k/m68k/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/m68k/m68k/legacy.c b/freebsd/sys/m68k/m68k/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/m68k/m68k/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/m68k/pci/pci_bus.c b/freebsd/sys/m68k/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/m68k/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/mips/include/machine/cpufunc.h b/freebsd/sys/mips/include/machine/cpufunc.h index f693dcba..d32e4920 100644 --- a/freebsd/sys/mips/include/machine/cpufunc.h +++ b/freebsd/sys/mips/include/machine/cpufunc.h @@ -56,11 +56,11 @@ * $FreeBSD$ */ -#ifndef _MACHINE_CPUFUNC_HH_ -#define _MACHINE_CPUFUNC_HH_ +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ -#include -#include +#include +#include /* * These functions are required by user-land atomi ops @@ -407,4 +407,4 @@ void outsw(uint16_t *, const uint16_t *,int); void outsl(uint32_t *, const uint32_t *,int); u_int loadandclear(volatile u_int *addr); -#endif /* !_MACHINE_CPUFUNC_HH_ */ +#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/freebsd/sys/mips/include/machine/cpuregs.h b/freebsd/sys/mips/include/machine/cpuregs.h index db6450ff..456c545c 100644 --- a/freebsd/sys/mips/include/machine/cpuregs.h +++ b/freebsd/sys/mips/include/machine/cpuregs.h @@ -55,8 +55,8 @@ * $FreeBSD$ */ -#ifndef _MIPS_CPUREGS_HH_ -#define _MIPS_CPUREGS_HH_ +#ifndef _MIPS_CPUREGS_H_ +#define _MIPS_CPUREGS_H_ /* * Address space. @@ -975,13 +975,13 @@ #define MIPS_R3TOSH 0x22 /* Toshiba R3000 based FPU ISA I */ #ifdef ENABLE_MIPS_TX3900 -#include +#include #endif #ifdef MIPS3_5900 -#include +#include #endif #ifdef MIPS64_SB1 -#include +#include #endif -#endif /* _MIPS_CPUREGS_HH_ */ +#endif /* _MIPS_CPUREGS_H_ */ diff --git a/freebsd/sys/mips/include/machine/in_cksum.h b/freebsd/sys/mips/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/mips/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/mips/include/machine/legacyvar.h b/freebsd/sys/mips/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/mips/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/mips/include/machine/pci_cfgreg.h b/freebsd/sys/mips/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/mips/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/mips/mips/in_cksum.c b/freebsd/sys/mips/mips/in_cksum.c index a519c729..c6f7b568 100644 --- a/freebsd/sys/mips/mips/in_cksum.c +++ b/freebsd/sys/mips/mips/in_cksum.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1988, 1992, 1993 @@ -37,16 +37,16 @@ * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * Checksum routine for Internet Protocol family headers diff --git a/freebsd/sys/mips/mips/legacy.c b/freebsd/sys/mips/mips/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/mips/mips/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/mips/pci/pci_bus.c b/freebsd/sys/mips/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/mips/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/mman.h b/freebsd/sys/mman.h deleted file mode 100644 index dc4243f0..00000000 --- a/freebsd/sys/mman.h +++ /dev/null @@ -1,238 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)mman.h 8.2 (Berkeley) 1/9/95 - * $FreeBSD$ - */ - -#ifndef _SYS_MMAN_HH_ -#define _SYS_MMAN_HH_ - -#include -#include - -#if __BSD_VISIBLE -/* - * Inheritance for minherit() - */ -#define INHERIT_SHARE 0 -#define INHERIT_COPY 1 -#define INHERIT_NONE 2 -#endif - -/* - * Protections are chosen from these bits, or-ed together - */ -#define PROT_NONE 0x00 /* no permissions */ -#define PROT_READ 0x01 /* pages can be read */ -#define PROT_WRITE 0x02 /* pages can be written */ -#define PROT_EXEC 0x04 /* pages can be executed */ - -/* - * Flags contain sharing type and options. - * Sharing types; choose one. - */ -#define MAP_SHARED 0x0001 /* share changes */ -#define MAP_PRIVATE 0x0002 /* changes are private */ -#if __BSD_VISIBLE -#define MAP_COPY MAP_PRIVATE /* Obsolete */ -#endif - -/* - * Other flags - */ -#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ - -#if __BSD_VISIBLE -#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ -#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ -#define MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */ -#define MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */ -#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ -#define MAP_STACK 0x0400 /* region grows down, like a stack */ -#define MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */ - -/* - * Mapping type - */ -#define MAP_FILE 0x0000 /* map from file (default) */ -#define MAP_ANON 0x1000 /* allocated from memory, swap space */ - -/* - * Extended flags - */ -#define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ -#endif /* __BSD_VISIBLE */ - -#if __POSIX_VISIBLE >= 199309 -/* - * Process memory locking - */ -#define MCL_CURRENT 0x0001 /* Lock only current memory */ -#define MCL_FUTURE 0x0002 /* Lock all future memory as well */ -#endif - -/* - * Error return from mmap() - */ -#define MAP_FAILED ((void *)-1) - -/* - * msync() flags - */ -#define MS_SYNC 0x0000 /* msync synchronously */ -#define MS_ASYNC 0x0001 /* return immediately */ -#define MS_INVALIDATE 0x0002 /* invalidate all cached data */ - -/* - * Advice to madvise - */ -#define _MADV_NORMAL 0 /* no further special treatment */ -#define _MADV_RANDOM 1 /* expect random page references */ -#define _MADV_SEQUENTIAL 2 /* expect sequential page references */ -#define _MADV_WILLNEED 3 /* will need these pages */ -#define _MADV_DONTNEED 4 /* dont need these pages */ - -#if __BSD_VISIBLE -#define MADV_NORMAL _MADV_NORMAL -#define MADV_RANDOM _MADV_RANDOM -#define MADV_SEQUENTIAL _MADV_SEQUENTIAL -#define MADV_WILLNEED _MADV_WILLNEED -#define MADV_DONTNEED _MADV_DONTNEED -#define MADV_FREE 5 /* dont need these pages, and junk contents */ -#define MADV_NOSYNC 6 /* try to avoid flushes to physical media */ -#define MADV_AUTOSYNC 7 /* revert to default flushing strategy */ -#define MADV_NOCORE 8 /* do not include these pages in a core file */ -#define MADV_CORE 9 /* revert to including pages in a core file */ -#define MADV_PROTECT 10 /* protect process from pageout kill */ - -/* - * Return bits from mincore - */ -#define MINCORE_INCORE 0x1 /* Page is incore */ -#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */ -#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ -#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ -#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ -#define MINCORE_SUPER 0x20 /* Page is a "super" page */ - -/* - * Anonymous object constant for shm_open(). - */ -#define SHM_ANON ((char *)1) -#endif /* __BSD_VISIBLE */ - -/* - * XXX missing POSIX_TYPED_MEM_* macros and - * posix_typed_mem_info structure. - */ -#if __POSIX_VISIBLE >= 200112 -#define POSIX_MADV_NORMAL _MADV_NORMAL -#define POSIX_MADV_RANDOM _MADV_RANDOM -#define POSIX_MADV_SEQUENTIAL _MADV_SEQUENTIAL -#define POSIX_MADV_WILLNEED _MADV_WILLNEED -#define POSIX_MADV_DONTNEED _MADV_DONTNEED -#endif - -#ifndef _MODE_T_DECLARED -typedef __mode_t mode_t; -#define _MODE_T_DECLARED -#endif - -#ifndef _OFF_T_DECLARED -typedef __off_t off_t; -#define _OFF_T_DECLARED -#endif - -#ifndef _SIZE_T_DECLARED -typedef __size_t size_t; -#define _SIZE_T_DECLARED -#endif - -#ifdef _KERNEL -#include - -struct shmfd { - size_t shm_size; - vm_object_t shm_object; - int shm_refs; - uid_t shm_uid; - gid_t shm_gid; - mode_t shm_mode; - - /* - * Values maintained solely to make this a better-behaved file - * descriptor for fstat() to run on. - */ - struct timespec shm_atime; - struct timespec shm_mtime; - struct timespec shm_ctime; - struct timespec shm_birthtime; - - struct label *shm_label; /* MAC label */ -}; - -int shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, - vm_object_t *obj); - -#else /* !_KERNEL */ - -__BEGIN_DECLS -/* - * XXX not yet implemented: posix_mem_offset(), posix_typed_mem_get_info(), - * posix_typed_mem_open(). - */ -#if __BSD_VISIBLE -int getpagesizes(size_t *, int); -int madvise(void *, size_t, int); -int mincore(const void *, size_t, char *); -int minherit(void *, size_t, int); -#endif -int mlock(const void *, size_t); -#ifndef _MMAP_DECLARED -#define _MMAP_DECLARED -void * mmap(void *, size_t, int, int, int, off_t); -#endif -int mprotect(const void *, size_t, int); -int msync(void *, size_t, int); -int munlock(const void *, size_t); -int munmap(void *, size_t); -#if __POSIX_VISIBLE >= 200112 -int posix_madvise(void *, size_t, int); -#endif -#if __POSIX_VISIBLE >= 199309 -int mlockall(int); -int munlockall(void); -int shm_open(const char *, int, mode_t); -int shm_unlink(const char *); -#endif -__END_DECLS - -#endif /* !_KERNEL */ - -#endif /* !_SYS_MMAN_HH_ */ diff --git a/freebsd/sys/net/bpf.c b/freebsd/sys/net/bpf.c index 684c7343..d9223313 100644 --- a/freebsd/sys/net/bpf.c +++ b/freebsd/sys/net/bpf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990, 1991, 1993 @@ -36,55 +36,55 @@ * @(#)bpf.c 8.4 (Berkeley) 1/9/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifdef BPF_JITTER -#include +#include #endif -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include -#include +#include MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); @@ -93,8 +93,8 @@ MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); #define PRINET 26 /* interruptible */ #ifdef COMPAT_FREEBSD32 -#include -#include +#include +#include #define BPF_ALIGNMENT32 sizeof(int32_t) #define BPF_WORDALIGN32(x) (((x)+(BPF_ALIGNMENT32-1))&~(BPF_ALIGNMENT32-1)) diff --git a/freebsd/sys/net/bpf.h b/freebsd/sys/net/bpf.h index d9dd4289..726483a5 100644 --- a/freebsd/sys/net/bpf.h +++ b/freebsd/sys/net/bpf.h @@ -37,8 +37,8 @@ * $FreeBSD$ */ -#ifndef _NET_BPF_HH_ -#define _NET_BPF_HH_ +#ifndef _NET_BPF_H_ +#define _NET_BPF_H_ /* BSD style release date */ #define BPF_RELEASE 199606 @@ -971,4 +971,4 @@ bpf_peers_present(struct bpf_if *bpf) */ #define BPF_MEMWORDS 16 -#endif /* _NET_BPF_HH_ */ +#endif /* _NET_BPF_H_ */ diff --git a/freebsd/sys/net/bpf_buffer.c b/freebsd/sys/net/bpf_buffer.c index 623b4f8a..7ebfb0a8 100644 --- a/freebsd/sys/net/bpf_buffer.c +++ b/freebsd/sys/net/bpf_buffer.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007 Seccuris Inc. @@ -63,23 +63,23 @@ * @(#)bpf.c 8.4 (Berkeley) 1/9/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include /* * Implement historical kernel memory buffering model for BPF: two malloc(9) diff --git a/freebsd/sys/net/bpf_buffer.h b/freebsd/sys/net/bpf_buffer.h index 545ddb22..82d0310b 100644 --- a/freebsd/sys/net/bpf_buffer.h +++ b/freebsd/sys/net/bpf_buffer.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _NET_BPF_BUFFER_HH_ -#define _NET_BPF_BUFFER_HH_ +#ifndef _NET_BPF_BUFFER_H_ +#define _NET_BPF_BUFFER_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -47,4 +47,4 @@ int bpf_buffer_ioctl_sblen(struct bpf_d *d, u_int *i); int bpf_buffer_uiomove(struct bpf_d *d, caddr_t buf, u_int len, struct uio *uio); -#endif /* !_NET_BPF_BUFFER_HH_ */ +#endif /* !_NET_BPF_BUFFER_H_ */ diff --git a/freebsd/sys/net/bpf_filter.c b/freebsd/sys/net/bpf_filter.c index 3452cc4a..e796cf79 100644 --- a/freebsd/sys/net/bpf_filter.c +++ b/freebsd/sys/net/bpf_filter.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990, 1991, 1993 @@ -36,13 +36,13 @@ * @(#)bpf_filter.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include #if !defined(_KERNEL) || defined(sun) -#include +#include #endif #ifndef __i386__ @@ -65,11 +65,11 @@ __FBSDID("$FreeBSD$"); #endif #ifdef _KERNEL -#include +#include #else -#include +#include #endif -#include +#include #ifdef _KERNEL #define MINDEX(m, k) \ { \ diff --git a/freebsd/sys/net/bpf_jitter.c b/freebsd/sys/net/bpf_jitter.c index bb373725..02c0b34f 100644 --- a/freebsd/sys/net/bpf_jitter.c +++ b/freebsd/sys/net/bpf_jitter.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 2002-2003 NetGroup, Politecnico di Torino (Italy) @@ -31,25 +31,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifdef _KERNEL -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif -#include -#include +#include +#include bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, int *); diff --git a/freebsd/sys/net/bpf_jitter.h b/freebsd/sys/net/bpf_jitter.h index c0dd7e04..04491b01 100644 --- a/freebsd/sys/net/bpf_jitter.h +++ b/freebsd/sys/net/bpf_jitter.h @@ -31,8 +31,8 @@ * $FreeBSD$ */ -#ifndef _NET_BPF_JITTER_HH_ -#define _NET_BPF_JITTER_HH_ +#ifndef _NET_BPF_JITTER_H_ +#define _NET_BPF_JITTER_H_ #ifdef _KERNEL MALLOC_DECLARE(M_BPFJIT); @@ -81,4 +81,4 @@ bpf_jit_filter *bpf_jitter(struct bpf_insn *fp, int nins); */ void bpf_destroy_jit_filter(bpf_jit_filter *filter); -#endif /* _NET_BPF_JITTER_HH_ */ +#endif /* _NET_BPF_JITTER_H_ */ diff --git a/freebsd/sys/net/bpf_zerocopy.h b/freebsd/sys/net/bpf_zerocopy.h index 455bd41c..c541a15d 100644 --- a/freebsd/sys/net/bpf_zerocopy.h +++ b/freebsd/sys/net/bpf_zerocopy.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _NET_BPF_ZEROCOPY_HH_ -#define _NET_BPF_ZEROCOPY_HH_ +#ifndef _NET_BPF_ZEROCOPY_H_ +#define _NET_BPF_ZEROCOPY_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -53,4 +53,4 @@ int bpf_zerocopy_ioctl_rotzbuf(struct thread *td, struct bpf_d *d, int bpf_zerocopy_ioctl_setzbuf(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz); -#endif /* !_NET_BPF_ZEROCOPY_HH_ */ +#endif /* !_NET_BPF_ZEROCOPY_H_ */ diff --git a/freebsd/sys/net/bpfdesc.h b/freebsd/sys/net/bpfdesc.h index d28ecca2..03cb20dd 100644 --- a/freebsd/sys/net/bpfdesc.h +++ b/freebsd/sys/net/bpfdesc.h @@ -36,14 +36,14 @@ * $FreeBSD$ */ -#ifndef _NET_BPFDESC_HH_ -#define _NET_BPFDESC_HH_ +#ifndef _NET_BPFDESC_H_ +#define _NET_BPFDESC_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * Descriptor associated with each open bpf file. diff --git a/freebsd/sys/net/bridgestp.c b/freebsd/sys/net/bridgestp.c index 2191be26..cc7f4e6f 100644 --- a/freebsd/sys/net/bridgestp.c +++ b/freebsd/sys/net/bridgestp.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: bridgestp.c,v 1.5 2003/11/28 08:56:48 keihan Exp $ */ @@ -36,34 +36,34 @@ * ISO/IEC 802.1D-2004, June 9, 2004. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef BRIDGESTP_DEBUG #define DPRINTF(fmt, arg...) printf("bstp: " fmt, ##arg) diff --git a/freebsd/sys/net/bridgestp.h b/freebsd/sys/net/bridgestp.h index 91328900..74086fce 100644 --- a/freebsd/sys/net/bridgestp.h +++ b/freebsd/sys/net/bridgestp.h @@ -74,8 +74,8 @@ * Data structure and control definitions for STP interfaces. */ -#include -#include +#include +#include /* STP port states */ #define BSTP_IFSTATE_DISABLED 0 diff --git a/freebsd/sys/net/ethernet.h b/freebsd/sys/net/ethernet.h index 17d022b2..ae7341ee 100644 --- a/freebsd/sys/net/ethernet.h +++ b/freebsd/sys/net/ethernet.h @@ -1,2 +1,405 @@ -#include -#include +/* + * Fundamental constants relating to ethernet. + * + * $FreeBSD$ + * + */ + +#ifndef _NET_ETHERNET_H_ +#define _NET_ETHERNET_H_ + +/* + * Some basic Ethernet constants. + */ +#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ +#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ +#define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) +#define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */ +#define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */ +#define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */ + +#define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */ +/* + * Mbuf adjust factor to force 32-bit alignment of IP header. + * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a + * receive so the upper layers get the IP header properly aligned + * past the 14-byte Ethernet header. + */ +#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ + +/* + * Compute the maximum frame size based on ethertype (i.e. possible + * encapsulation) and whether or not an FCS is present. + */ +#define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ + ((ifp)->if_mtu + ETHER_HDR_LEN + \ + ((hasfcs) ? ETHER_CRC_LEN : 0) + \ + (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0)) + +/* + * Ethernet-specific mbuf flags. + */ +#define M_HASFCS M_PROTO5 /* FCS included at end of frame */ + +/* + * Ethernet CRC32 polynomials (big- and little-endian verions). + */ +#define ETHER_CRC_POLY_LE 0xedb88320 +#define ETHER_CRC_POLY_BE 0x04c11db6 + +/* + * A macro to validate a length with + */ +#define ETHER_IS_VALID_LEN(foo) \ + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) + +/* + * Structure of a 10Mb/s Ethernet header. + */ +struct ether_header { + u_char ether_dhost[ETHER_ADDR_LEN]; + u_char ether_shost[ETHER_ADDR_LEN]; + u_short ether_type; +} __packed; + +/* + * Structure of a 48-bit Ethernet address. + */ +struct ether_addr { + u_char octet[ETHER_ADDR_LEN]; +} __packed; + +#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ + +/* + * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. + * However, there are some conflicts. + */ + +#define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ + /* 0x0101 .. 0x1FF Experimental */ +#define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ +#define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ +#define ETHERTYPE_SPRITE 0x0500 /* ??? */ + /* 0x0400 Nixdorf */ +#define ETHERTYPE_NS 0x0600 /* XNS */ +#define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ +#define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ +#define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#define ETHERTYPE_X75 0x0801 /* X.75 Internet */ +#define ETHERTYPE_NBS 0x0802 /* NBS Internet */ +#define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ +#define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ +#define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ +#define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ +#define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ +#define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ + /* 0x081C Symbolics Private */ + /* 0x0888 - 0x088A Xyplex */ +#define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ +#define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ +#define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ +#define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ +#define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ +#define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ + +/* 0x1000 - 0x100F Berkeley Trailer */ +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ +#define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ +#define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ +#define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ + + /* The following 3C0x types + are unregistered: */ +#define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ +#define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ +#define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ +#define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect response not registered */ +#define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ +#define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ +#define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ +#define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ +#define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ +#define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ +#define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete NetBIOS name not registered */ +#define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ +#define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ +#define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ + +#define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ +#define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ +#define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ +#define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ +#define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ +#define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ +#define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ +#define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ +#define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ +#define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ +#define ETHERTYPE_LAT 0x6004 /* DEC LAT */ +#define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ +#define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ +#define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ +#define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ +#define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ + /* 0x6010 - 0x6014 3Com Corporation */ +#define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ +#define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ +#define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ +#define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ +#define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ +#define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ +#define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ +#define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ +#define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ + /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ +#define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ +#define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ +#define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ +#define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ +#define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ +#define ETHERTYPE_HP 0x8005 /* HP Probe */ +#define ETHERTYPE_NESTAR 0x8006 /* Nestar */ +#define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ +#define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ +#define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ +#define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ +#define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ +#define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ +#define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ +#define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ +#define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ +#define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ +#define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ +#define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ +#define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ +#define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ +#define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ +#define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ +#define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ +#define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ +#define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ +#define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ +#define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ +#define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ + /* 0x8042 DEC Unassigned */ +#define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ + /* 0x8046 - 0x8047 AT&T */ +#define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ +#define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ +#define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ +#define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ +#define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ +#define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ +#define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ + /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ +#define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ +#define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ +#define ETHERTYPE_ATT 0x8069 /* AT&T */ +#define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ +#define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ +#define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ + /* 0x806E - 0x8077 Landmark Graphics Corp. */ +#define ETHERTYPE_MATRA 0x807A /* Matra */ +#define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ +#define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ + /* 0x807D - 0x807F Vitalink Communications */ +#define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ + /* 0x8081 - 0x8083 Counterpoint Computers */ + /* 0x8088 - 0x808A Xyplex */ +#define ETHERTYPE_ATALK 0x809B /* AppleTalk */ +#define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ +#define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ + /* 0x809C - 0x809E Datability */ +#define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ + /* 0x80A3 Nixdorf */ + /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ + /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ + /* 0x80C4 - 0x80C5 Banyan Systems */ +#define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ +#define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ + /* 0x80C8 - 0x80CC Intergraph Corporation */ + /* 0x80CD - 0x80CE Harris Corporation */ + /* 0x80CF - 0x80D2 Taylor Instrument */ + /* 0x80D3 - 0x80D4 Rosemount Corporation */ +#define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ +#define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ + /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ + /* 0x80E0 - 0x80E3 Allen-Bradley */ + /* 0x80E4 - 0x80F0 Datability */ +#define ETHERTYPE_RETIX 0x80F2 /* Retix */ +#define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ + /* 0x80F4 - 0x80F5 Kinetics */ +#define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ + /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ +#define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ +#define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ + /* 0x8107 - 0x8109 Symbolics Private */ +#define ETHERTYPE_TALARIS 0x812B /* Talaris */ +#define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ +#define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ +#define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ + /* 0x8132 - 0x8137 Bridge Communications */ +#define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ +#define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ + /* 0x8139 - 0x813D KTI */ +#define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ +#define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ +#define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ +#define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ +#define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ +#define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ +#define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ +#define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ + /* 0x814D - 0x814E BIIN */ +#define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ +#define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ + /* 0x8151 - 0x8153 Qualcomm */ + /* 0x815C - 0x815E Computer Protocol Pty Ltd */ + /* 0x8164 - 0x8166 Charles River Data Systems */ +#define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ +#define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ +#define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ +#define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ + /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ + /* 0x8184 - 0x818C SGI prop. */ +#define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ +#define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ + /* 0x819A - 0x81A3 RAD Network Devices */ + /* 0x81B7 - 0x81B9 Xyplex */ + /* 0x81CC - 0x81D5 Apricot Computers */ + /* 0x81D6 - 0x81DD Artisoft Lantastic */ + /* 0x81E6 - 0x81EF Polygon */ + /* 0x81F0 - 0x81F2 Comsat Labs */ + /* 0x81F3 - 0x81F5 SAIC */ + /* 0x81F6 - 0x81F8 VG Analytical */ + /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ + /* 0x8221 - 0x8222 Ascom Banking Systems */ + /* 0x823E - 0x8240 Advanced Encryption Systems */ + /* 0x8263 - 0x826A Charles River Data Systems */ + /* 0x827F - 0x8282 Athena Programming */ + /* 0x829A - 0x829B Inst Ind Info Tech */ + /* 0x829C - 0x82AB Taurus Controls */ + /* 0x82AC - 0x8693 Walker Richer & Quinn */ +#define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ +#define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ +#define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ + /* 0x8694 - 0x869D Idea Courier */ + /* 0x869E - 0x86A1 Computer Network Tech */ + /* 0x86A3 - 0x86AC Gateway Communications */ +#define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ +#define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ +#define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ +#define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ + /* 0x86E0 - 0x86EF Landis & Gyr Powers */ + /* 0x8700 - 0x8710 Motorola */ +#define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ +#define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ + /* 0x873B - 0x873C Control Technology Inc. Proprietary */ +#define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ +#define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ +#define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ +#define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ +#define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ +#define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ +#define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ +#define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ +#define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ +#define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ +#define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ +#define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ +#define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ +#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ +#define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ +#define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ +#define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ +#define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ +#define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ +#define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ +#define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ +#define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ + /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ + +#define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ + +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) +#define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) +#define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) +/* + * The ETHER_BPF_MTAP macro should be used by drivers which support hardware + * offload for VLAN tag processing. It will check the mbuf to see if it has + * M_VLANTAG set, and if it does, will pass the packet along to + * ether_vlan_mtap. This function will re-insert VLAN tags for the duration + * of the tap, so they show up properly for network analyzers. + */ +#define ETHER_BPF_MTAP(_ifp, _m) do { \ + if (bpf_peers_present((_ifp)->if_bpf)) { \ + M_ASSERTVALID(_m); \ + if (((_m)->m_flags & M_VLANTAG) != 0) \ + ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \ + else \ + bpf_mtap((_ifp)->if_bpf, (_m)); \ + } \ +} while (0) + +#ifdef _KERNEL + +struct ifnet; +struct mbuf; +struct route; +struct sockaddr; +struct bpf_if; + +extern uint32_t ether_crc32_le(const uint8_t *, size_t); +extern uint32_t ether_crc32_be(const uint8_t *, size_t); +extern void ether_demux(struct ifnet *, struct mbuf *); +extern void ether_ifattach(struct ifnet *, const u_int8_t *); +extern void ether_ifdetach(struct ifnet *); +extern int ether_ioctl(struct ifnet *, u_long, caddr_t); +extern int ether_output(struct ifnet *, + struct mbuf *, struct sockaddr *, struct route *); +extern int ether_output_frame(struct ifnet *, struct mbuf *); +extern char *ether_sprintf(const u_int8_t *); +void ether_vlan_mtap(struct bpf_if *, struct mbuf *, + void *, u_int); +struct mbuf *ether_vlanencap(struct mbuf *, uint16_t); + +#else /* _KERNEL */ + +#include + +/* + * Ethernet address conversion/parsing routines. + */ +__BEGIN_DECLS +struct ether_addr *ether_aton(const char *); +struct ether_addr *ether_aton_r(const char *, struct ether_addr *); +int ether_hostton(const char *, struct ether_addr *); +int ether_line(const char *, struct ether_addr *, char *); +char *ether_ntoa(const struct ether_addr *); +char *ether_ntoa_r(const struct ether_addr *, char *); +int ether_ntohost(char *, const struct ether_addr *); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_NET_ETHERNET_H_ */ diff --git a/freebsd/sys/net/fddi.h b/freebsd/sys/net/fddi.h index 03deabff..71e3b6fb 100644 --- a/freebsd/sys/net/fddi.h +++ b/freebsd/sys/net/fddi.h @@ -36,8 +36,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IF_FDDI_HH_ -#define _NETINET_IF_FDDI_HH_ +#ifndef _NETINET_IF_FDDI_H_ +#define _NETINET_IF_FDDI_H_ #define FDDIIPMTU 4352 #define FDDIMTU 4470 @@ -102,4 +102,4 @@ void fddi_ifdetach(struct ifnet *, int); int fddi_ioctl(struct ifnet *, u_long, caddr_t); #endif /* _KERNEL */ -#endif /* _NET_FDDI_HH_ */ +#endif /* _NET_FDDI_H_ */ diff --git a/freebsd/sys/net/firewire.h b/freebsd/sys/net/firewire.h index 5411dbf8..bab71a58 100644 --- a/freebsd/sys/net/firewire.h +++ b/freebsd/sys/net/firewire.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _NET_FIREWIRE_HH_ -#define _NET_FIREWIRE_HH_ +#ifndef _NET_FIREWIRE_H_ +#define _NET_FIREWIRE_H_ #define FW_ENCAP_UNFRAG 0 #define FW_ENCAP_FIRST 1 @@ -139,4 +139,4 @@ extern int firewire_ioctl(struct ifnet *, u_long, caddr_t); #endif /* !_KERNEL */ -#endif /* !_NET_FIREWIRE_HH_ */ +#endif /* !_NET_FIREWIRE_H_ */ diff --git a/freebsd/sys/net/flowtable.h b/freebsd/sys/net/flowtable.h index c4a09659..6e79a3cf 100644 --- a/freebsd/sys/net/flowtable.h +++ b/freebsd/sys/net/flowtable.h @@ -29,8 +29,8 @@ $FreeBSD$ ***************************************************************************/ -#ifndef _NET_FLOWTABLE_HH_ -#define _NET_FLOWTABLE_HH_ +#ifndef _NET_FLOWTABLE_H_ +#define _NET_FLOWTABLE_H_ #ifdef _KERNEL diff --git a/freebsd/sys/net/ieee8023ad_lacp.c b/freebsd/sys/net/ieee8023ad_lacp.c index 75c0d9ea..6e06ffe5 100644 --- a/freebsd/sys/net/ieee8023ad_lacp.c +++ b/freebsd/sys/net/ieee8023ad_lacp.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: ieee8023ad_lacp.c,v 1.3 2005/12/11 12:24:54 christos Exp $ */ @@ -29,29 +29,29 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include /* hz */ -#include /* for net/if.h */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include /* hz */ +#include /* for net/if.h */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include /* * actor system priority and port priority. diff --git a/freebsd/sys/net/if.c b/freebsd/sys/net/if.c index 33d9ed9d..e52f3963 100644 --- a/freebsd/sys/net/if.c +++ b/freebsd/sys/net/if.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1980, 1986, 1993 @@ -32,66 +32,66 @@ * $FreeBSD$ */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) /*XXX*/ -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif #endif #ifdef INET -#include +#include #endif -#include +#include #ifdef COMPAT_FREEBSD32 -#include -#include +#include +#include #endif struct ifindex_entry { @@ -1820,7 +1820,7 @@ done: return (ifa); } -#include +#include /* * Default action when installing a route with a Link Level gateway. diff --git a/freebsd/sys/net/if.h b/freebsd/sys/net/if.h index 6fbbb34a..865513bb 100644 --- a/freebsd/sys/net/if.h +++ b/freebsd/sys/net/if.h @@ -1,2 +1,470 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NET_IF_H_ +#define _NET_IF_H_ + +#include + +#ifdef _KERNEL +#include +#endif + +#if __BSD_VISIBLE + +#ifdef __rtems__ +#include +#else +#ifndef _KERNEL +/* + * does not depend on on most other systems. This + * helps userland compatibility. (struct timeval ifi_lastchange) + */ +#include +#endif +#endif /* __rtems__ */ + +struct ifnet; +#endif + +/* + * Length of interface external name, including terminating '\0'. + * Note: this is the same size as a generic device's external name. + */ +#define IF_NAMESIZE 16 +#if __BSD_VISIBLE +#define IFNAMSIZ IF_NAMESIZE +#define IF_MAXUNIT 0x7fff /* historical value */ +#endif +#if __BSD_VISIBLE + +/* + * Structure used to query names of interface cloners. + */ + +struct if_clonereq { + int ifcr_total; /* total cloners (out) */ + int ifcr_count; /* room for this many in user buffer */ + char *ifcr_buffer; /* buffer for cloner names */ +}; + +/* + * Structure describing information about an interface + * which may be of interest to management entities. + */ +struct if_data { + /* generic interface information */ + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + u_char ifi_link_state; /* current link state */ + u_char ifi_spare_char1; /* spare byte */ + u_char ifi_spare_char2; /* spare byte */ + u_char ifi_datalen; /* length of this data struct */ + u_long ifi_mtu; /* maximum transmission unit */ + u_long ifi_metric; /* routing metric (external only) */ + u_long ifi_baudrate; /* linespeed */ + /* volatile statistics */ + u_long ifi_ipackets; /* packets received on interface */ + u_long ifi_ierrors; /* input errors on interface */ + u_long ifi_opackets; /* packets sent on interface */ + u_long ifi_oerrors; /* output errors on interface */ + u_long ifi_collisions; /* collisions on csma interfaces */ + u_long ifi_ibytes; /* total number of octets received */ + u_long ifi_obytes; /* total number of octets sent */ + u_long ifi_imcasts; /* packets received via multicast */ + u_long ifi_omcasts; /* packets sent via multicast */ + u_long ifi_iqdrops; /* dropped on input, this interface */ + u_long ifi_noproto; /* destined for unsupported protocol */ + u_long ifi_hwassist; /* HW offload capabilities, see IFCAP */ + time_t ifi_epoch; /* uptime at attach or stat reset */ + struct timeval ifi_lastchange; /* time of last administrative change */ +}; + +/*- + * Interface flags are of two types: network stack owned flags, and driver + * owned flags. Historically, these values were stored in the same ifnet + * flags field, but with the advent of fine-grained locking, they have been + * broken out such that the network stack is responsible for synchronizing + * the stack-owned fields, and the device driver the device-owned fields. + * Both halves can perform lockless reads of the other half's field, subject + * to accepting the involved races. + * + * Both sets of flags come from the same number space, and should not be + * permitted to conflict, as they are exposed to user space via a single + * field. + * + * The following symbols identify read and write requirements for fields: + * + * (i) if_flags field set by device driver before attach, read-only there + * after. + * (n) if_flags field written only by the network stack, read by either the + * stack or driver. + * (d) if_drv_flags field written only by the device driver, read by either + * the stack or driver. + */ +#define IFF_UP 0x1 /* (n) interface is up */ +#define IFF_BROADCAST 0x2 /* (i) broadcast address valid */ +#define IFF_DEBUG 0x4 /* (n) turn on debugging */ +#define IFF_LOOPBACK 0x8 /* (i) is a loopback net */ +#define IFF_POINTOPOINT 0x10 /* (i) is a point-to-point link */ +#define IFF_SMART 0x20 /* (i) interface manages own routes */ +#define IFF_DRV_RUNNING 0x40 /* (d) resources allocated */ +#define IFF_NOARP 0x80 /* (n) no address resolution protocol */ +#define IFF_PROMISC 0x100 /* (n) receive all packets */ +#define IFF_ALLMULTI 0x200 /* (n) receive all multicast packets */ +#define IFF_DRV_OACTIVE 0x400 /* (d) tx hardware queue is full */ +#define IFF_SIMPLEX 0x800 /* (i) can't hear own transmissions */ +#define IFF_LINK0 0x1000 /* per link layer defined bit */ +#define IFF_LINK1 0x2000 /* per link layer defined bit */ +#define IFF_LINK2 0x4000 /* per link layer defined bit */ +#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ +#define IFF_MULTICAST 0x8000 /* (i) supports multicast */ +/* 0x10000 */ +#define IFF_PPROMISC 0x20000 /* (n) user-requested promisc mode */ +#define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ +#define IFF_STATICARP 0x80000 /* (n) static ARP */ +#define IFF_DYING 0x200000 /* (n) interface is winding down */ +#define IFF_RENAMING 0x400000 /* (n) interface is being renamed */ + +/* + * Old names for driver flags so that user space tools can continue to use + * the old (portable) names. + */ +#ifndef _KERNEL +#define IFF_RUNNING IFF_DRV_RUNNING +#define IFF_OACTIVE IFF_DRV_OACTIVE +#endif + +/* flags set internally only: */ +#define IFF_CANTCHANGE \ + (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\ + IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\ + IFF_DYING) + +/* + * Values for if_link_state. + */ +#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ +#define LINK_STATE_DOWN 1 /* link is down */ +#define LINK_STATE_UP 2 /* link is up */ + +/* + * Some convenience macros used for setting ifi_baudrate. + * XXX 1000 vs. 1024? --thorpej@netbsd.org + */ +#define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */ +#define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ +#define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ + +/* + * Capabilities that interfaces can advertise. + * + * struct ifnet.if_capabilities + * contains the optional features & capabilities a particular interface + * supports (not only the driver but also the detected hw revision). + * Capabilities are defined by IFCAP_* below. + * struct ifnet.if_capenable + * contains the enabled (either by default or through ifconfig) optional + * features & capabilities on this interface. + * Capabilities are defined by IFCAP_* below. + * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above + * contains the enabled optional feature & capabilites that can be used + * individually per packet and are specified in the mbuf pkthdr.csum_flags + * field. IFCAP_* and CSUM_* do not match one to one and CSUM_* may be + * more detailed or differenciated than IFCAP_*. + * Hwassist features are defined CSUM_* in sys/mbuf.h + */ +#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ +#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ +#define IFCAP_NETCONS 0x00004 /* can be a network console */ +#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */ +#define IFCAP_VLAN_HWTAGGING 0x00010 /* hardware VLAN tag support */ +#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */ +#define IFCAP_POLLING 0x00040 /* driver supports polling */ +#define IFCAP_VLAN_HWCSUM 0x00080 /* can do IFCAP_HWCSUM on VLANs */ +#define IFCAP_TSO4 0x00100 /* can do TCP Segmentation Offload */ +#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */ +#define IFCAP_LRO 0x00400 /* can do Large Receive Offload */ +#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */ +#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */ +#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */ +#define IFCAP_TOE4 0x04000 /* interface can offload TCP */ +#define IFCAP_TOE6 0x08000 /* interface can offload TCP6 */ +#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ +#define IFCAP_POLLING_NOCOUNT 0x20000 /* polling ticks cannot be fragmented */ +#define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ +#define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ + +#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) +#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) +#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) +#define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) + +#define IFQ_MAXLEN 50 +#define IFNET_SLOWHZ 1 /* granularity is 1 second */ + +/* + * Message format for use in obtaining information about interfaces + * from getkerninfo and the routing socket + */ +struct if_msghdr { + u_short ifm_msglen; /* to skip over non-understood messages */ + u_char ifm_version; /* future binary compatibility */ + u_char ifm_type; /* message type */ + int ifm_addrs; /* like rtm_addrs */ + int ifm_flags; /* value of if_flags */ + u_short ifm_index; /* index for associated ifp */ + struct if_data ifm_data;/* statistics and other data about if */ +}; + +/* + * Message format for use in obtaining information about interface addresses + * from getkerninfo and the routing socket + */ +struct ifa_msghdr { + u_short ifam_msglen; /* to skip over non-understood messages */ + u_char ifam_version; /* future binary compatibility */ + u_char ifam_type; /* message type */ + int ifam_addrs; /* like rtm_addrs */ + int ifam_flags; /* value of ifa_flags */ + u_short ifam_index; /* index for associated ifp */ + int ifam_metric; /* value of ifa_metric */ +}; + +/* + * Message format for use in obtaining information about multicast addresses + * from the routing socket + */ +struct ifma_msghdr { + u_short ifmam_msglen; /* to skip over non-understood messages */ + u_char ifmam_version; /* future binary compatibility */ + u_char ifmam_type; /* message type */ + int ifmam_addrs; /* like rtm_addrs */ + int ifmam_flags; /* value of ifa_flags */ + u_short ifmam_index; /* index for associated ifp */ +}; + +/* + * Message format announcing the arrival or departure of a network interface. + */ +struct if_announcemsghdr { + u_short ifan_msglen; /* to skip over non-understood messages */ + u_char ifan_version; /* future binary compatibility */ + u_char ifan_type; /* message type */ + u_short ifan_index; /* index for associated ifp */ + char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_short ifan_what; /* what type of announcement */ +}; + +#define IFAN_ARRIVAL 0 /* interface arrival */ +#define IFAN_DEPARTURE 1 /* interface departure */ + +/* + * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests + */ +struct ifreq_buffer { + size_t length; + void *buffer; +}; + +/* + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + */ +struct ifreq { + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct ifreq_buffer ifru_buffer; + short ifru_flags[2]; + short ifru_index; + int ifru_jid; + int ifru_metric; + int ifru_mtu; + int ifru_phys; + int ifru_media; + caddr_t ifru_data; + int ifru_cap[2]; + } ifr_ifru; +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_buffer ifr_ifru.ifru_buffer /* user supplied buffer with its length */ +#define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */ +#define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */ +#define ifr_jid ifr_ifru.ifru_jid /* jail/vnet */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_phys ifr_ifru.ifru_phys /* physical wire */ +#define ifr_media ifr_ifru.ifru_media /* physical media */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ +#define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ +#define ifr_index ifr_ifru.ifru_index /* interface index */ +}; + +#define _SIZEOF_ADDR_IFREQ(ifr) \ + ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ + (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ + (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) + +struct ifaliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr ifra_addr; + struct sockaddr ifra_broadaddr; + struct sockaddr ifra_mask; +}; + +struct ifmediareq { + char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int ifm_current; /* current media options */ + int ifm_mask; /* don't care mask */ + int ifm_status; /* media status */ + int ifm_active; /* active options */ + int ifm_count; /* # entries in ifm_ulist array */ + int *ifm_ulist; /* media words */ +}; + +struct ifdrv { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + unsigned long ifd_cmd; + size_t ifd_len; + void *ifd_data; +}; + +/* + * Structure used to retrieve aux status data from interfaces. + * Kernel suppliers to this interface should respect the formatting + * needed by ifconfig(8): each line starts with a TAB and ends with + * a newline. The canonical example to copy and paste is in if_tun.c. + */ + +#define IFSTATMAX 800 /* 10 lines of text */ +struct ifstat { + char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + char ascii[IFSTATMAX + 1]; +}; + +/* + * Structure used in SIOCGIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible). + */ +struct ifconf { + int ifc_len; /* size of associated buffer */ + union { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ +}; + +/* + * interface groups + */ + +#define IFG_ALL "all" /* group contains all interfaces */ +/* XXX: will we implement this? */ +#define IFG_EGRESS "egress" /* if(s) default route(s) point to */ + +struct ifg_req { + union { + char ifgrqu_group[IFNAMSIZ]; + char ifgrqu_member[IFNAMSIZ]; + } ifgrq_ifgrqu; +#define ifgrq_group ifgrq_ifgrqu.ifgrqu_group +#define ifgrq_member ifgrq_ifgrqu.ifgrqu_member +}; + +/* + * Used to lookup groups for an interface + */ +struct ifgroupreq { + char ifgr_name[IFNAMSIZ]; + u_int ifgr_len; + union { + char ifgru_group[IFNAMSIZ]; + struct ifg_req *ifgru_groups; + } ifgr_ifgru; +#define ifgr_group ifgr_ifgru.ifgru_group +#define ifgr_groups ifgr_ifgru.ifgru_groups +}; + +/* + * Structure for SIOC[AGD]LIFADDR + */ +struct if_laddrreq { + char iflr_name[IFNAMSIZ]; + u_int flags; +#define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ + u_int prefixlen; /* in/out */ + struct sockaddr_storage addr; /* in/out */ + struct sockaddr_storage dstaddr; /* out */ +}; + +#endif /* __BSD_VISIBLE */ + +#ifdef _KERNEL +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_IFADDR); +MALLOC_DECLARE(M_IFMADDR); +#endif +#endif + +#ifndef _KERNEL +struct if_nameindex { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "le0", ... */ +}; + +__BEGIN_DECLS +void if_freenameindex(struct if_nameindex *); +char *if_indextoname(unsigned int, char *); +struct if_nameindex *if_nameindex(void); +unsigned int if_nametoindex(const char *); +__END_DECLS +#endif + +#ifdef _KERNEL +/* XXX - this should go away soon. */ +#include +#endif + +#endif /* !_NET_IF_H_ */ diff --git a/freebsd/sys/net/if_arc.h b/freebsd/sys/net/if_arc.h index 6be5d4e1..88a72403 100644 --- a/freebsd/sys/net/if_arc.h +++ b/freebsd/sys/net/if_arc.h @@ -33,8 +33,8 @@ * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 */ -#ifndef _NET_IF_ARC_HH_ -#define _NET_IF_ARC_HH_ +#ifndef _NET_IF_ARC_H_ +#define _NET_IF_ARC_H_ /* * Arcnet address - 1 octets @@ -140,4 +140,4 @@ void arc_frag_init(struct ifnet *); struct mbuf * arc_frag_next(struct ifnet *); #endif -#endif /* _NET_IF_ARC_HH_ */ +#endif /* _NET_IF_ARC_H_ */ diff --git a/freebsd/sys/net/if_arcsubr.c b/freebsd/sys/net/if_arcsubr.c index 8cd53a6d..dc75b445 100644 --- a/freebsd/sys/net/if_arcsubr.c +++ b/freebsd/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_arcsubr.c,v 1.36 2001/06/14 05:44:23 itojun Exp $ */ /* $FreeBSD$ */ @@ -40,47 +40,47 @@ * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 * */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif #define ARCNET_ALLOW_BROKEN_ARP diff --git a/freebsd/sys/net/if_arp.h b/freebsd/sys/net/if_arp.h index 2ad9fffb..2bb63582 100644 --- a/freebsd/sys/net/if_arp.h +++ b/freebsd/sys/net/if_arp.h @@ -1,2 +1,138 @@ -#include -#include +/*- + * Copyright (c) 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NET_IF_ARP_H_ +#define _NET_IF_ARP_H_ + +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arphdr { + u_short ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware format */ +#define ARPHRD_IEEE802 6 /* token-ring hardware format */ +#define ARPHRD_ARCNET 7 /* arcnet hardware format */ +#define ARPHRD_FRELAY 15 /* frame relay hardware format */ +#define ARPHRD_IEEE1394 24 /* firewire hardware format */ + u_short ar_pro; /* format of protocol address */ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ +#define ARPOP_REVREPLY 4 /* response giving protocol address */ +#define ARPOP_INVREQUEST 8 /* request to identify peer */ +#define ARPOP_INVREPLY 9 /* response identifying peer */ +/* + * The remaining fields are variable in size, + * according to the sizes above. + */ +#ifdef COMMENT_ONLY + u_char ar_sha[]; /* sender hardware address */ + u_char ar_spa[]; /* sender protocol address */ + u_char ar_tha[]; /* target hardware address */ + u_char ar_tpa[]; /* target protocol address */ +#endif +}; + +#define ar_sha(ap) (((caddr_t)((ap)+1)) + 0) +#define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln) +#define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln) +#define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln) + +#define arphdr_len2(ar_hln, ar_pln) \ + (sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln)) +#define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln)) + +/* + * ARP ioctl request + */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ +}; +/* arp_flags and at_flags field values */ +#define ATF_INUSE 0x01 /* entry in use */ +#define ATF_COM 0x02 /* completed entry (enaddr valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry (respond for other host) */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ + +#ifdef _KERNEL +/* + * Structure shared between the ethernet driver modules and + * the address resolution code. + */ +struct arpcom { + struct ifnet *ac_ifp; /* network-visible interface */ + void *ac_netgraph; /* ng_ether(4) netgraph node info */ +}; +#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) +#define AC2IFP(ac) ((ac)->ac_ifp) + +#endif /* _KERNEL */ + +struct arpstat { + /* Normal things that happen: */ + u_long txrequests; /* # of ARP requests sent by this host. */ + u_long txreplies; /* # of ARP replies sent by this host. */ + u_long rxrequests; /* # of ARP requests received by this host. */ + u_long rxreplies; /* # of ARP replies received by this host. */ + u_long received; /* # of ARP packets received by this host. */ + + u_long arp_spares[4]; /* For either the upper or lower half. */ + /* Abnormal event and error counting: */ + u_long dropped; /* # of packets dropped waiting for a reply. */ + u_long timeouts; /* # of times with entries removed */ + /* due to timeout. */ + u_long dupips; /* # of duplicate IPs detected. */ +}; + +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ +#define ARPSTAT_ADD(name, val) V_arpstat.name += (val) +#define ARPSTAT_SUB(name, val) V_arpstat.name -= (val) +#define ARPSTAT_INC(name) ARPSTAT_ADD(name, 1) +#define ARPSTAT_DEC(name) ARPSTAT_SUB(name, 1) + +#endif /* !_NET_IF_ARP_H_ */ diff --git a/freebsd/sys/net/if_atmsubr.c b/freebsd/sys/net/if_atmsubr.c index 7daa347f..747bc936 100644 --- a/freebsd/sys/net/if_atmsubr.c +++ b/freebsd/sys/net/if_atmsubr.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_atmsubr.c,v 1.10 1997/03/11 23:19:51 chuck Exp $ */ @@ -36,42 +36,42 @@ * if_atmsubr.c */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* XXX: for ETHERTYPE_* */ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include /* XXX: for ETHERTYPE_* */ #if defined(INET) || defined(INET6) -#include +#include #endif #ifdef NATM -#include +#include #endif -#include +#include /* * Netgraph interface functions. diff --git a/freebsd/sys/net/if_bridge.c b/freebsd/sys/net/if_bridge.c index de7aea04..5c15a78f 100644 --- a/freebsd/sys/net/if_bridge.c +++ b/freebsd/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_bridge.c,v 1.31 2005/06/01 19:45:34 jdc Exp $ */ @@ -76,64 +76,64 @@ * consider heterogenous bridges). */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include /* for net/if.h */ -#include -#include /* string functions */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include /* for struct arpcom */ -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include /* for net/if.h */ +#include +#include /* string functions */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* for struct arpcom */ +#include +#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif #if defined(INET) || defined(INET6) -#include +#include #endif -#include -#include /* for struct arpcom */ -#include -#include -#include -#include - -#include -#include -#include +#include +#include /* for struct arpcom */ +#include +#include +#include +#include + +#include +#include +#include /* * Size of the route hash table. Must be a power of two. diff --git a/freebsd/sys/net/if_bridgevar.h b/freebsd/sys/net/if_bridgevar.h index 642cc98d..3210c03b 100644 --- a/freebsd/sys/net/if_bridgevar.h +++ b/freebsd/sys/net/if_bridgevar.h @@ -74,9 +74,9 @@ * Data structure and control definitions for bridge interfaces. */ -#include -#include -#include +#include +#include +#include /* * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the diff --git a/freebsd/sys/net/if_clone.c b/freebsd/sys/net/if_clone.c index aca1276f..af0a9ea4 100644 --- a/freebsd/sys/net/if_clone.c +++ b/freebsd/sys/net/if_clone.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1980, 1986, 1993 @@ -32,26 +32,26 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #if 0 -#include +#include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static void if_clone_free(struct if_clone *ifc); static int if_clone_createif(struct if_clone *ifc, char *name, size_t len, diff --git a/freebsd/sys/net/if_clone.h b/freebsd/sys/net/if_clone.h index 67de320b..f125f8b5 100644 --- a/freebsd/sys/net/if_clone.h +++ b/freebsd/sys/net/if_clone.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_CLONE_HH_ -#define _NET_IF_CLONE_HH_ +#ifndef _NET_IF_CLONE_H_ +#define _NET_IF_CLONE_H_ #ifdef _KERNEL @@ -113,4 +113,4 @@ int ifc_simple_destroy(struct if_clone *, struct ifnet *); #endif /* _KERNEL */ -#endif /* !_NET_IF_CLONE_HH_ */ +#endif /* !_NET_IF_CLONE_H_ */ diff --git a/freebsd/sys/net/if_dead.c b/freebsd/sys/net/if_dead.c index dcceaf25..c6453c37 100644 --- a/freebsd/sys/net/if_dead.c +++ b/freebsd/sys/net/if_dead.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 Robert N. M. Watson @@ -33,15 +33,15 @@ * returned. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include static int ifdead_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, diff --git a/freebsd/sys/net/if_disc.c b/freebsd/sys/net/if_disc.c index 09918bb4..54336eb8 100644 --- a/freebsd/sys/net/if_disc.c +++ b/freebsd/sys/net/if_disc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -37,23 +37,23 @@ * (Based on the loopback.) */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include #ifdef TINY_DSMTU #define DSMTU (1024+512) diff --git a/freebsd/sys/net/if_dl.h b/freebsd/sys/net/if_dl.h index ad29f1de..8d88623d 100644 --- a/freebsd/sys/net/if_dl.h +++ b/freebsd/sys/net/if_dl.h @@ -1,2 +1,82 @@ -#include -#include +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if_dl.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NET_IF_DL_H_ +#define _NET_IF_DL_H_ + +/* + * A Link-Level Sockaddr may specify the interface in one of two + * ways: either by means of a system-provided index number (computed + * anew and possibly differently on every reboot), or by a human-readable + * string such as "il0" (for managerial convenience). + * + * Census taking actions, such as something akin to SIOCGCONF would return + * both the index and the human name. + * + * High volume transactions (such as giving a link-level ``from'' address + * in a recvfrom or recvmsg call) may be likely only to provide the indexed + * form, (which requires fewer copy operations and less space). + * + * The form and interpretation of the link-level address is purely a matter + * of convention between the device driver and its consumers; however, it is + * expected that all drivers for an interface of a given if_type will agree. + */ + +/* + * Structure of a Link-Level sockaddr: + */ +struct sockaddr_dl { + u_char sdl_len; /* Total length of sockaddr */ + u_char sdl_family; /* AF_LINK */ + u_short sdl_index; /* if != 0, system given index for interface */ + u_char sdl_type; /* interface type */ + u_char sdl_nlen; /* interface name length, no trailing 0 reqd. */ + u_char sdl_alen; /* link level address length */ + u_char sdl_slen; /* link layer selector length */ + char sdl_data[46]; /* minimum work area, can be larger; + contains both if name and ll address */ +}; + +#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +void link_addr(const char *, struct sockaddr_dl *); +char *link_ntoa(const struct sockaddr_dl *); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif diff --git a/freebsd/sys/net/if_edsc.c b/freebsd/sys/net/if_edsc.c index 89618ce5..71160354 100644 --- a/freebsd/sys/net/if_edsc.c +++ b/freebsd/sys/net/if_edsc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -37,21 +37,21 @@ * Mimics an Ethernet device so that VLANs can be attached to it etc. */ -#include /* types, important constants */ -#include /* SYSINIT for load-time initializations */ -#include /* malloc(9) */ -#include /* module(9) */ -#include /* mbuf(9) */ -#include /* struct ifreq */ -#include /* socket ioctl's */ -/* #include if you need printf(9) or other all-purpose globals */ - -#include /* bpf(9) */ -#include /* Ethernet related constants and types */ -#include /* basic part of ifnet(9) */ -#include /* network interface cloning */ -#include /* IFT_ETHER and friends */ -#include /* kernel-only part of ifnet(9) */ +#include /* types, important constants */ +#include /* SYSINIT for load-time initializations */ +#include /* malloc(9) */ +#include /* module(9) */ +#include /* mbuf(9) */ +#include /* struct ifreq */ +#include /* socket ioctl's */ +/* #include if you need printf(9) or other all-purpose globals */ + +#include /* bpf(9) */ +#include /* Ethernet related constants and types */ +#include /* basic part of ifnet(9) */ +#include /* network interface cloning */ +#include /* IFT_ETHER and friends */ +#include /* kernel-only part of ifnet(9) */ /* * Software configuration of an interface specific to this device type. diff --git a/freebsd/sys/net/if_ef.c b/freebsd/sys/net/if_ef.c index 8114806c..ced792c3 100644 --- a/freebsd/sys/net/if_ef.c +++ b/freebsd/sys/net/if_ef.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1999, 2000 Boris Popov @@ -28,39 +28,39 @@ * $FreeBSD$ */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include +#include +#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif /* If none of the supported layers is enabled explicitly enable them all */ diff --git a/freebsd/sys/net/if_enc.c b/freebsd/sys/net/if_enc.c index 6bbb6ceb..017d707c 100644 --- a/freebsd/sys/net/if_enc.c +++ b/freebsd/sys/net/if_enc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2006 The FreeBSD Project. @@ -29,42 +29,42 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include -#include -#include +#include +#include +#include #define ENCMTU (1024+512) diff --git a/freebsd/sys/net/if_epair.c b/freebsd/sys/net/if_epair.c index 65baeab8..e49ac84e 100644 --- a/freebsd/sys/net/if_epair.c +++ b/freebsd/sys/net/if_epair.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 The FreeBSD Foundation @@ -49,29 +49,29 @@ * For now let the user handle that case. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #define EPAIRNAME "epair" diff --git a/freebsd/sys/net/if_ethersubr.c b/freebsd/sys/net/if_ethersubr.c index d87ebbd0..02a5d002 100644 --- a/freebsd/sys/net/if_ethersubr.c +++ b/freebsd/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1989, 1993 @@ -32,57 +32,57 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif int (*ef_inputp)(struct ifnet*, struct ether_header *eh, struct mbuf *m); @@ -90,9 +90,9 @@ int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, int *hlen); #ifdef NETATALK -#include -#include -#include +#include +#include +#include #define llc_snap_org_code llc_un.type_snap.org_code #define llc_snap_ether_type llc_un.type_snap.ether_type @@ -101,7 +101,7 @@ extern u_char at_org_code[3]; extern u_char aarp_org_code[3]; #endif /* NETATALK */ -#include +#include #ifdef CTASSERT CTASSERT(sizeof (struct ether_header) == ETHER_ADDR_LEN * 2 + 2); diff --git a/freebsd/sys/net/if_faith.c b/freebsd/sys/net/if_faith.c index c8989922..d99e16ea 100644 --- a/freebsd/sys/net/if_faith.c +++ b/freebsd/sys/net/if_faith.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: if_faith.c,v 1.23 2001/12/17 13:55:29 sumikawa Exp $ */ @@ -41,44 +41,44 @@ /* * Loopback interface driver for protocol testing and timing. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef INET6 #ifndef INET -#include +#include #endif -#include -#include -#include +#include +#include +#include #endif #define FAITHNAME "faith" diff --git a/freebsd/sys/net/if_fddisubr.c b/freebsd/sys/net/if_fddisubr.c index fc9f27e1..ba4db83f 100644 --- a/freebsd/sys/net/if_fddisubr.c +++ b/freebsd/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1995, 1996 @@ -38,60 +38,60 @@ * $FreeBSD$ */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif #ifdef DECNET -#include +#include #endif #ifdef NETATALK -#include -#include -#include +#include +#include +#include extern u_char at_org_code[ 3 ]; extern u_char aarp_org_code[ 3 ]; #endif /* NETATALK */ -#include +#include static const u_char fddibroadcastaddr[FDDI_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; diff --git a/freebsd/sys/net/if_fwsubr.c b/freebsd/sys/net/if_fwsubr.c index d084bea4..a9931419 100644 --- a/freebsd/sys/net/if_fwsubr.c +++ b/freebsd/sys/net/if_fwsubr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004 Doug Rabson @@ -32,38 +32,38 @@ * $FreeBSD$ */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif -#include +#include MALLOC_DEFINE(M_FWCOM, "fw_com", "firewire interface internals"); diff --git a/freebsd/sys/net/if_gif.c b/freebsd/sys/net/if_gif.c index be67500a..b6c6111c 100644 --- a/freebsd/sys/net/if_gif.c +++ b/freebsd/sys/net/if_gif.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: if_gif.c,v 1.87 2001/10/19 08:50:27 itojun Exp $ */ @@ -32,62 +32,62 @@ * SUCH DAMAGE. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #ifdef INET -#include -#include -#include +#include +#include +#include #endif /* INET */ #ifdef INET6 #ifndef INET -#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif /* INET6 */ -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #define GIFNAME "gif" diff --git a/freebsd/sys/net/if_gif.h b/freebsd/sys/net/if_gif.h index 14f06fd6..a2f214c5 100644 --- a/freebsd/sys/net/if_gif.h +++ b/freebsd/sys/net/if_gif.h @@ -34,15 +34,15 @@ * if_gif.h */ -#ifndef _NET_IF_GIF_HH_ -#define _NET_IF_GIF_HH_ +#ifndef _NET_IF_GIF_H_ +#define _NET_IF_GIF_H_ #ifdef _KERNEL -#include -#include +#include +#include -#include +#include /* xxx sigh, why route have struct route instead of pointer? */ struct encaptab; @@ -127,4 +127,4 @@ int gif_encapcheck(const struct mbuf *, int, int, void *); #define GIF_SEND_REVETHIP 0x0010 #define GIF_OPTMASK (GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP) -#endif /* _NET_IF_GIF_HH_ */ +#endif /* _NET_IF_GIF_H_ */ diff --git a/freebsd/sys/net/if_gre.c b/freebsd/sys/net/if_gre.c index 4a42029b..09e53e94 100644 --- a/freebsd/sys/net/if_gre.c +++ b/freebsd/sys/net/if_gre.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */ /* $FreeBSD$ */ @@ -50,45 +50,45 @@ * Also supported: IP in IP encaps (proto 55) as of RFC 2004 */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #else #error "Huh? if_gre without inet?" #endif -#include +#include -#include +#include /* * It is not easy to calculate the right value for a GRE MTU. diff --git a/freebsd/sys/net/if_gre.h b/freebsd/sys/net/if_gre.h index ff9c63cf..7ac11fce 100644 --- a/freebsd/sys/net/if_gre.h +++ b/freebsd/sys/net/if_gre.h @@ -40,9 +40,9 @@ #ifndef _NET_IF_GRE_H #define _NET_IF_GRE_H -#include +#include #ifdef _KERNEL -#include +#include /* * Version of the WCCP, need to be configured manually since diff --git a/freebsd/sys/net/if_iso88025subr.c b/freebsd/sys/net/if_iso88025subr.c index 87d3eb87..6a39956e 100644 --- a/freebsd/sys/net/if_iso88025subr.c +++ b/freebsd/sys/net/if_iso88025subr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998, Larry Lile @@ -42,47 +42,47 @@ * */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif -#include +#include static const u_char iso88025_broadcastaddr[ISO88025_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; diff --git a/freebsd/sys/net/if_lagg.c b/freebsd/sys/net/if_lagg.c index 47c72ca2..a1c90cdf 100644 --- a/freebsd/sys/net/if_lagg.c +++ b/freebsd/sys/net/if_lagg.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: if_trunk.c,v 1.30 2007/01/31 06:20:19 reyk Exp $ */ @@ -19,55 +19,55 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif -#include -#include -#include +#include +#include +#include /* Special flags we should propagate to the lagg ports. */ static struct { diff --git a/freebsd/sys/net/if_llatbl.c b/freebsd/sys/net/if_llatbl.c index b9f78a71..3ffcc21a 100644 --- a/freebsd/sys/net/if_llatbl.c +++ b/freebsd/sys/net/if_llatbl.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. @@ -26,41 +26,41 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef DDB -#include +#include #endif -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables"); diff --git a/freebsd/sys/net/if_llatbl.h b/freebsd/sys/net/if_llatbl.h index 9e12362b..a4d02ab0 100644 --- a/freebsd/sys/net/if_llatbl.h +++ b/freebsd/sys/net/if_llatbl.h @@ -24,14 +24,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#ifndef _NET_IF_LLATBL_HH_ -#define _NET_IF_LLATBL_HH_ +#ifndef _NET_IF_LLATBL_H_ +#define _NET_IF_LLATBL_H_ -#include -#include +#include +#include struct ifnet; struct sysctl_req; @@ -205,4 +205,4 @@ lla_lookup(struct lltable *llt, u_int flags, const struct sockaddr *l3addr) } int lla_rt_output(struct rt_msghdr *, struct rt_addrinfo *); -#endif /* _NET_IF_LLATBL_HH_ */ +#endif /* _NET_IF_LLATBL_H_ */ diff --git a/freebsd/sys/net/if_llc.h b/freebsd/sys/net/if_llc.h index b72f21bc..0d96372e 100644 --- a/freebsd/sys/net/if_llc.h +++ b/freebsd/sys/net/if_llc.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_LLC_HH_ -#define _NET_IF_LLC_HH_ +#ifndef _NET_IF_LLC_H_ +#define _NET_IF_LLC_H_ /* * IEEE 802.2 Link Level Control headers, for use in conjunction with @@ -158,4 +158,4 @@ CTASSERT(sizeof (struct llc) == LLC_SNAPFRAMELEN); #define LLC_SNAP_LSAP 0xaa #define LLC_ISO_LSAP 0xfe -#endif /* _NET_IF_LLC_HH_ */ +#endif /* _NET_IF_LLC_H_ */ diff --git a/freebsd/sys/net/if_loop.c b/freebsd/sys/net/if_loop.c index d80bfdad..3b36ab05 100644 --- a/freebsd/sys/net/if_loop.c +++ b/freebsd/sys/net/if_loop.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -36,54 +36,54 @@ * Loopback interface driver for protocol testing and timing. */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include +#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif #ifdef INET6 #ifndef INET -#include +#include #endif -#include -#include +#include +#include #endif #ifdef NETATALK -#include -#include +#include +#include #endif -#include +#include #ifdef TINY_LOMTU #define LOMTU (1024+512) diff --git a/freebsd/sys/net/if_media.c b/freebsd/sys/net/if_media.c index 3da5090a..46b57b42 100644 --- a/freebsd/sys/net/if_media.c +++ b/freebsd/sys/net/if_media.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_media.c,v 1.1 1997/03/17 02:55:15 thorpej Exp $ */ /* $FreeBSD$ */ @@ -48,16 +48,16 @@ * to implement this interface. */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include /* * Compile-time options: diff --git a/freebsd/sys/net/if_media.h b/freebsd/sys/net/if_media.h index 26a3c417..337ad685 100644 --- a/freebsd/sys/net/if_media.h +++ b/freebsd/sys/net/if_media.h @@ -35,8 +35,8 @@ * SUCH DAMAGE. */ -#ifndef _NET_IF_MEDIA_HH_ -#define _NET_IF_MEDIA_HH_ +#ifndef _NET_IF_MEDIA_H_ +#define _NET_IF_MEDIA_H_ /* * Prototypes and definitions for BSD/OS-compatible network interface @@ -52,7 +52,7 @@ #ifdef _KERNEL -#include +#include /* * Driver callbacks for media status and change requests. @@ -689,4 +689,4 @@ struct ifmedia_status_description { { 0, 0, 0, \ { NULL, NULL } } \ } -#endif /* _NET_IF_MEDIA_HH_ */ +#endif /* _NET_IF_MEDIA_H_ */ diff --git a/freebsd/sys/net/if_mib.c b/freebsd/sys/net/if_mib.c index ddc75df3..fe9d0e23 100644 --- a/freebsd/sys/net/if_mib.c +++ b/freebsd/sys/net/if_mib.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1996 Massachusetts Institute of Technology @@ -31,15 +31,15 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include /* * A sysctl(3) MIB for generic interface information. This information diff --git a/freebsd/sys/net/if_sppp.h b/freebsd/sys/net/if_sppp.h index ed406b55..97f94b39 100644 --- a/freebsd/sys/net/if_sppp.h +++ b/freebsd/sys/net/if_sppp.h @@ -20,8 +20,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_SPPP_HH_ -#define _NET_IF_SPPP_HH_ 1 +#ifndef _NET_IF_SPPP_H_ +#define _NET_IF_SPPP_H_ 1 #define IDX_LCP 0 /* idx into state table */ @@ -231,4 +231,4 @@ void sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, #endif -#endif /* _NET_IF_SPPP_HH_ */ +#endif /* _NET_IF_SPPP_H_ */ diff --git a/freebsd/sys/net/if_spppfr.c b/freebsd/sys/net/if_spppfr.c index fa912363..be080a7d 100644 --- a/freebsd/sys/net/if_spppfr.c +++ b/freebsd/sys/net/if_spppfr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Synchronous Frame Relay link level subroutines. @@ -25,12 +25,12 @@ * $FreeBSD$ */ -#include +#include #if defined(__FreeBSD__) && __FreeBSD__ >= 3 -#include -#include -#include +#include +#include +#include #endif #ifdef NetBSD1_3 @@ -41,57 +41,57 @@ # endif #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if defined(__FreeBSD__) && __FreeBSD__ >= 3 -#include +#include #endif -#include -#include +#include +#include #if defined (__OpenBSD__) -#include +#include #else -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined (__NetBSD__) || defined (__OpenBSD__) -#include /* XXX for softnet */ +#include /* XXX for softnet */ #endif -#include +#include -#include +#include #ifdef INET -#include -#include +#include +#include #endif #if defined (__FreeBSD__) || defined (__OpenBSD__) -# include +# include #else -# include +# include #endif #ifdef IPX -#include -#include +#include +#include #endif -#include +#include /* * Frame Relay. diff --git a/freebsd/sys/net/if_spppsubr.c b/freebsd/sys/net/if_spppsubr.c index 235ef7c0..d5f3487a 100644 --- a/freebsd/sys/net/if_spppsubr.c +++ b/freebsd/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -#include +#include /* * Synchronous PPP/Cisco/Frame Relay link level subroutines. @@ -23,55 +23,55 @@ * $FreeBSD$ */ -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include +#include #ifdef INET -#include -#include +#include +#include #endif #ifdef INET6 -#include +#include #endif -#include +#include #ifdef IPX -#include -#include +#include +#include #endif -#include +#include #define IOCTL_CMD_T u_long #define MAXALIVECNT 3 /* max. alive packets */ diff --git a/freebsd/sys/net/if_stf.c b/freebsd/sys/net/if_stf.c index 1cf5c408..104536fd 100644 --- a/freebsd/sys/net/if_stf.c +++ b/freebsd/sys/net/if_stf.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: if_stf.c,v 1.73 2001/12/03 11:08:30 keiichi Exp $ */ @@ -76,51 +76,51 @@ * Note that there is no way to be 100% secure. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +#include SYSCTL_DECL(_net_link); SYSCTL_NODE(_net_link, IFT_STF, stf, CTLFLAG_RW, 0, "6to4 Interface"); diff --git a/freebsd/sys/net/if_stf.h b/freebsd/sys/net/if_stf.h index 64fd30ee..cbaf6703 100644 --- a/freebsd/sys/net/if_stf.h +++ b/freebsd/sys/net/if_stf.h @@ -30,9 +30,9 @@ * SUCH DAMAGE. */ -#ifndef _NET_IF_STF_HH_ -#define _NET_IF_STF_HH_ +#ifndef _NET_IF_STF_H_ +#define _NET_IF_STF_H_ void in_stf_input(struct mbuf *, int); -#endif /* _NET_IF_STF_HH_ */ +#endif /* _NET_IF_STF_H_ */ diff --git a/freebsd/sys/net/if_tap.c b/freebsd/sys/net/if_tap.c index 206302bb..9e27b809 100644 --- a/freebsd/sys/net/if_tap.c +++ b/freebsd/sys/net/if_tap.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1999-2000 by Maksim Yevmenkin @@ -37,42 +37,42 @@ * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $ */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include #define CDEV_NAME "tap" diff --git a/freebsd/sys/net/if_tap.h b/freebsd/sys/net/if_tap.h index e611884b..91feb2fe 100644 --- a/freebsd/sys/net/if_tap.h +++ b/freebsd/sys/net/if_tap.h @@ -35,8 +35,8 @@ * $Id: if_tap.h,v 0.7 2000/07/12 04:12:51 max Exp $ */ -#ifndef _NET_IF_TAP_HH_ -#define _NET_IF_TAP_HH_ +#ifndef _NET_IF_TAP_H_ +#define _NET_IF_TAP_H_ /* refer to if_tapvar.h for the softc stuff */ @@ -71,4 +71,4 @@ struct tapinfo { #define VMIO_SIOCBRIDGE _IO('V', 6) #define VMIO_SIOCNETIF _IO('V', 7) -#endif /* !_NET_IF_TAP_HH_ */ +#endif /* !_NET_IF_TAP_H_ */ diff --git a/freebsd/sys/net/if_tapvar.h b/freebsd/sys/net/if_tapvar.h index 4a26fd87..21bac505 100644 --- a/freebsd/sys/net/if_tapvar.h +++ b/freebsd/sys/net/if_tapvar.h @@ -38,8 +38,8 @@ * $Id: if_tapvar.h,v 0.6 2000/07/11 02:16:08 max Exp $ */ -#ifndef _NET_IF_TAPVAR_HH_ -#define _NET_IF_TAPVAR_HH_ +#ifndef _NET_IF_TAPVAR_H_ +#define _NET_IF_TAPVAR_H_ /* * tap_mtx locks tap_flags, tap_pid. tap_next locked with global tapmtx. @@ -66,4 +66,4 @@ struct tap_softc { struct mtx tap_mtx; /* per-softc mutex */ }; -#endif /* !_NET_IF_TAPVAR_HH_ */ +#endif /* !_NET_IF_TAPVAR_H_ */ diff --git a/freebsd/sys/net/if_tun.c b/freebsd/sys/net/if_tun.c index 7f90fa51..a6b86600 100644 --- a/freebsd/sys/net/if_tun.c +++ b/freebsd/sys/net/if_tun.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */ @@ -18,50 +18,50 @@ * $FreeBSD$ */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET -#include +#include #endif -#include -#include +#include +#include -#include -#include +#include +#include -#include +#include /* * tun_list is protected by global tunmtx. Other mutable fields are diff --git a/freebsd/sys/net/if_tun.h b/freebsd/sys/net/if_tun.h index 29718cda..382881cb 100644 --- a/freebsd/sys/net/if_tun.h +++ b/freebsd/sys/net/if_tun.h @@ -16,8 +16,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_TUN_HH_ -#define _NET_IF_TUN_HH_ +#ifndef _NET_IF_TUN_H_ +#define _NET_IF_TUN_H_ /* Refer to if_tunvar.h for the softc stuff */ @@ -45,4 +45,4 @@ struct tuninfo { #define TUNSIFHEAD _IOW('t', 96, int) #define TUNGIFHEAD _IOR('t', 97, int) -#endif /* !_NET_IF_TUN_HH_ */ +#endif /* !_NET_IF_TUN_H_ */ diff --git a/freebsd/sys/net/if_types.h b/freebsd/sys/net/if_types.h index 1d4f2b2a..b2d3a159 100644 --- a/freebsd/sys/net/if_types.h +++ b/freebsd/sys/net/if_types.h @@ -1,2 +1,254 @@ -#include -#include +/*- + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if_types.h 8.3 (Berkeley) 4/28/95 + * $FreeBSD$ + * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $ + */ + +#ifndef _NET_IF_TYPES_H_ +#define _NET_IF_TYPES_H_ + +/* + * Interface types for benefit of parsing media address headers. + * This list is derived from the SNMP list of ifTypes, originally + * documented in RFC1573, now maintained as: + * + * http://www.iana.org/assignments/smi-numbers + */ + +#define IFT_OTHER 0x1 /* none of the following */ +#define IFT_1822 0x2 /* old-style arpanet imp */ +#define IFT_HDH1822 0x3 /* HDH arpanet imp */ +#define IFT_X25DDN 0x4 /* x25 to imp */ +#define IFT_X25 0x5 /* PDN X25 interface (RFC877) */ +#define IFT_ETHER 0x6 /* Ethernet CSMA/CD */ +#define IFT_ISO88023 0x7 /* CMSA/CD */ +#define IFT_ISO88024 0x8 /* Token Bus */ +#define IFT_ISO88025 0x9 /* Token Ring */ +#define IFT_ISO88026 0xa /* MAN */ +#define IFT_STARLAN 0xb +#define IFT_P10 0xc /* Proteon 10MBit ring */ +#define IFT_P80 0xd /* Proteon 80MBit ring */ +#define IFT_HY 0xe /* Hyperchannel */ +#define IFT_FDDI 0xf +#define IFT_LAPB 0x10 +#define IFT_SDLC 0x11 +#define IFT_T1 0x12 +#define IFT_CEPT 0x13 /* E1 - european T1 */ +#define IFT_ISDNBASIC 0x14 +#define IFT_ISDNPRIMARY 0x15 +#define IFT_PTPSERIAL 0x16 /* Proprietary PTP serial */ +#define IFT_PPP 0x17 /* RFC 1331 */ +#define IFT_LOOP 0x18 /* loopback */ +#define IFT_EON 0x19 /* ISO over IP */ +#define IFT_XETHER 0x1a /* obsolete 3MB experimental ethernet */ +#define IFT_NSIP 0x1b /* XNS over IP */ +#define IFT_SLIP 0x1c /* IP over generic TTY */ +#define IFT_ULTRA 0x1d /* Ultra Technologies */ +#define IFT_DS3 0x1e /* Generic T3 */ +#define IFT_SIP 0x1f /* SMDS */ +#define IFT_FRELAY 0x20 /* Frame Relay DTE only */ +#define IFT_RS232 0x21 +#define IFT_PARA 0x22 /* parallel-port */ +#define IFT_ARCNET 0x23 +#define IFT_ARCNETPLUS 0x24 +#define IFT_ATM 0x25 /* ATM cells */ +#define IFT_MIOX25 0x26 +#define IFT_SONET 0x27 /* SONET or SDH */ +#define IFT_X25PLE 0x28 +#define IFT_ISO88022LLC 0x29 +#define IFT_LOCALTALK 0x2a +#define IFT_SMDSDXI 0x2b +#define IFT_FRELAYDCE 0x2c /* Frame Relay DCE */ +#define IFT_V35 0x2d +#define IFT_HSSI 0x2e +#define IFT_HIPPI 0x2f +#define IFT_MODEM 0x30 /* Generic Modem */ +#define IFT_AAL5 0x31 /* AAL5 over ATM */ +#define IFT_SONETPATH 0x32 +#define IFT_SONETVT 0x33 +#define IFT_SMDSICIP 0x34 /* SMDS InterCarrier Interface */ +#define IFT_PROPVIRTUAL 0x35 /* Proprietary Virtual/internal */ +#define IFT_PROPMUX 0x36 /* Proprietary Multiplexing */ +#define IFT_IEEE80212 0x37 /* 100BaseVG */ +#define IFT_FIBRECHANNEL 0x38 /* Fibre Channel */ +#define IFT_HIPPIINTERFACE 0x39 /* HIPPI interfaces */ +#define IFT_FRAMERELAYINTERCONNECT 0x3a /* Obsolete, use either 0x20 or 0x2c */ +#define IFT_AFLANE8023 0x3b /* ATM Emulated LAN for 802.3 */ +#define IFT_AFLANE8025 0x3c /* ATM Emulated LAN for 802.5 */ +#define IFT_CCTEMUL 0x3d /* ATM Emulated circuit */ +#define IFT_FASTETHER 0x3e /* Fast Ethernet (100BaseT) */ +#define IFT_ISDN 0x3f /* ISDN and X.25 */ +#define IFT_V11 0x40 /* CCITT V.11/X.21 */ +#define IFT_V36 0x41 /* CCITT V.36 */ +#define IFT_G703AT64K 0x42 /* CCITT G703 at 64Kbps */ +#define IFT_G703AT2MB 0x43 /* Obsolete see DS1-MIB */ +#define IFT_QLLC 0x44 /* SNA QLLC */ +#define IFT_FASTETHERFX 0x45 /* Fast Ethernet (100BaseFX) */ +#define IFT_CHANNEL 0x46 /* channel */ +#define IFT_IEEE80211 0x47 /* radio spread spectrum */ +#define IFT_IBM370PARCHAN 0x48 /* IBM System 360/370 OEMI Channel */ +#define IFT_ESCON 0x49 /* IBM Enterprise Systems Connection */ +#define IFT_DLSW 0x4a /* Data Link Switching */ +#define IFT_ISDNS 0x4b /* ISDN S/T interface */ +#define IFT_ISDNU 0x4c /* ISDN U interface */ +#define IFT_LAPD 0x4d /* Link Access Protocol D */ +#define IFT_IPSWITCH 0x4e /* IP Switching Objects */ +#define IFT_RSRB 0x4f /* Remote Source Route Bridging */ +#define IFT_ATMLOGICAL 0x50 /* ATM Logical Port */ +#define IFT_DS0 0x51 /* Digital Signal Level 0 */ +#define IFT_DS0BUNDLE 0x52 /* group of ds0s on the same ds1 */ +#define IFT_BSC 0x53 /* Bisynchronous Protocol */ +#define IFT_ASYNC 0x54 /* Asynchronous Protocol */ +#define IFT_CNR 0x55 /* Combat Net Radio */ +#define IFT_ISO88025DTR 0x56 /* ISO 802.5r DTR */ +#define IFT_EPLRS 0x57 /* Ext Pos Loc Report Sys */ +#define IFT_ARAP 0x58 /* Appletalk Remote Access Protocol */ +#define IFT_PROPCNLS 0x59 /* Proprietary Connectionless Protocol*/ +#define IFT_HOSTPAD 0x5a /* CCITT-ITU X.29 PAD Protocol */ +#define IFT_TERMPAD 0x5b /* CCITT-ITU X.3 PAD Facility */ +#define IFT_FRAMERELAYMPI 0x5c /* Multiproto Interconnect over FR */ +#define IFT_X213 0x5d /* CCITT-ITU X213 */ +#define IFT_ADSL 0x5e /* Asymmetric Digital Subscriber Loop */ +#define IFT_RADSL 0x5f /* Rate-Adapt. Digital Subscriber Loop*/ +#define IFT_SDSL 0x60 /* Symmetric Digital Subscriber Loop */ +#define IFT_VDSL 0x61 /* Very H-Speed Digital Subscrib. Loop*/ +#define IFT_ISO88025CRFPINT 0x62 /* ISO 802.5 CRFP */ +#define IFT_MYRINET 0x63 /* Myricom Myrinet */ +#define IFT_VOICEEM 0x64 /* voice recEive and transMit */ +#define IFT_VOICEFXO 0x65 /* voice Foreign Exchange Office */ +#define IFT_VOICEFXS 0x66 /* voice Foreign Exchange Station */ +#define IFT_VOICEENCAP 0x67 /* voice encapsulation */ +#define IFT_VOICEOVERIP 0x68 /* voice over IP encapsulation */ +#define IFT_ATMDXI 0x69 /* ATM DXI */ +#define IFT_ATMFUNI 0x6a /* ATM FUNI */ +#define IFT_ATMIMA 0x6b /* ATM IMA */ +#define IFT_PPPMULTILINKBUNDLE 0x6c /* PPP Multilink Bundle */ +#define IFT_IPOVERCDLC 0x6d /* IBM ipOverCdlc */ +#define IFT_IPOVERCLAW 0x6e /* IBM Common Link Access to Workstn */ +#define IFT_STACKTOSTACK 0x6f /* IBM stackToStack */ +#define IFT_VIRTUALIPADDRESS 0x70 /* IBM VIPA */ +#define IFT_MPC 0x71 /* IBM multi-protocol channel support */ +#define IFT_IPOVERATM 0x72 /* IBM ipOverAtm */ +#define IFT_ISO88025FIBER 0x73 /* ISO 802.5j Fiber Token Ring */ +#define IFT_TDLC 0x74 /* IBM twinaxial data link control */ +#define IFT_GIGABITETHERNET 0x75 /* Gigabit Ethernet */ +#define IFT_HDLC 0x76 /* HDLC */ +#define IFT_LAPF 0x77 /* LAP F */ +#define IFT_V37 0x78 /* V.37 */ +#define IFT_X25MLP 0x79 /* Multi-Link Protocol */ +#define IFT_X25HUNTGROUP 0x7a /* X25 Hunt Group */ +#define IFT_TRANSPHDLC 0x7b /* Transp HDLC */ +#define IFT_INTERLEAVE 0x7c /* Interleave channel */ +#define IFT_FAST 0x7d /* Fast channel */ +#define IFT_IP 0x7e /* IP (for APPN HPR in IP networks) */ +#define IFT_DOCSCABLEMACLAYER 0x7f /* CATV Mac Layer */ +#define IFT_DOCSCABLEDOWNSTREAM 0x80 /* CATV Downstream interface */ +#define IFT_DOCSCABLEUPSTREAM 0x81 /* CATV Upstream interface */ +#define IFT_A12MPPSWITCH 0x82 /* Avalon Parallel Processor */ +#define IFT_TUNNEL 0x83 /* Encapsulation interface */ +#define IFT_COFFEE 0x84 /* coffee pot */ +#define IFT_CES 0x85 /* Circiut Emulation Service */ +#define IFT_ATMSUBINTERFACE 0x86 /* (x) ATM Sub Interface */ +#define IFT_L2VLAN 0x87 /* Layer 2 Virtual LAN using 802.1Q */ +#define IFT_L3IPVLAN 0x88 /* Layer 3 Virtual LAN - IP Protocol */ +#define IFT_L3IPXVLAN 0x89 /* Layer 3 Virtual LAN - IPX Prot. */ +#define IFT_DIGITALPOWERLINE 0x8a /* IP over Power Lines */ +#define IFT_MEDIAMAILOVERIP 0x8b /* (xxx) Multimedia Mail over IP */ +#define IFT_DTM 0x8c /* Dynamic synchronous Transfer Mode */ +#define IFT_DCN 0x8d /* Data Communications Network */ +#define IFT_IPFORWARD 0x8e /* IP Forwarding Interface */ +#define IFT_MSDSL 0x8f /* Multi-rate Symmetric DSL */ +#define IFT_IEEE1394 0x90 /* IEEE1394 High Performance SerialBus*/ +#define IFT_IFGSN 0x91 /* HIPPI-6400 */ +#define IFT_DVBRCCMACLAYER 0x92 /* DVB-RCC MAC Layer */ +#define IFT_DVBRCCDOWNSTREAM 0x93 /* DVB-RCC Downstream Channel */ +#define IFT_DVBRCCUPSTREAM 0x94 /* DVB-RCC Upstream Channel */ +#define IFT_ATMVIRTUAL 0x95 /* ATM Virtual Interface */ +#define IFT_MPLSTUNNEL 0x96 /* MPLS Tunnel Virtual Interface */ +#define IFT_SRP 0x97 /* Spatial Reuse Protocol */ +#define IFT_VOICEOVERATM 0x98 /* Voice over ATM */ +#define IFT_VOICEOVERFRAMERELAY 0x99 /* Voice Over Frame Relay */ +#define IFT_IDSL 0x9a /* Digital Subscriber Loop over ISDN */ +#define IFT_COMPOSITELINK 0x9b /* Avici Composite Link Interface */ +#define IFT_SS7SIGLINK 0x9c /* SS7 Signaling Link */ +#define IFT_PROPWIRELESSP2P 0x9d /* Prop. P2P wireless interface */ +#define IFT_FRFORWARD 0x9e /* Frame forward Interface */ +#define IFT_RFC1483 0x9f /* Multiprotocol over ATM AAL5 */ +#define IFT_USB 0xa0 /* USB Interface */ +#define IFT_IEEE8023ADLAG 0xa1 /* IEEE 802.3ad Link Aggregate*/ +#define IFT_BGPPOLICYACCOUNTING 0xa2 /* BGP Policy Accounting */ +#define IFT_FRF16MFRBUNDLE 0xa3 /* FRF.16 Multilik Frame Relay*/ +#define IFT_H323GATEKEEPER 0xa4 /* H323 Gatekeeper */ +#define IFT_H323PROXY 0xa5 /* H323 Voice and Video Proxy */ +#define IFT_MPLS 0xa6 /* MPLS */ +#define IFT_MFSIGLINK 0xa7 /* Multi-frequency signaling link */ +#define IFT_HDSL2 0xa8 /* High Bit-Rate DSL, 2nd gen. */ +#define IFT_SHDSL 0xa9 /* Multirate HDSL2 */ +#define IFT_DS1FDL 0xaa /* Facility Data Link (4Kbps) on a DS1*/ +#define IFT_POS 0xab /* Packet over SONET/SDH Interface */ +#define IFT_DVBASILN 0xac /* DVB-ASI Input */ +#define IFT_DVBASIOUT 0xad /* DVB-ASI Output */ +#define IFT_PLC 0xae /* Power Line Communications */ +#define IFT_NFAS 0xaf /* Non-Facility Associated Signaling */ +#define IFT_TR008 0xb0 /* TROO8 */ +#define IFT_GR303RDT 0xb1 /* Remote Digital Terminal */ +#define IFT_GR303IDT 0xb2 /* Integrated Digital Terminal */ +#define IFT_ISUP 0xb3 /* ISUP */ +#define IFT_PROPDOCSWIRELESSMACLAYER 0xb4 /* prop/Wireless MAC Layer */ +#define IFT_PROPDOCSWIRELESSDOWNSTREAM 0xb5 /* prop/Wireless Downstream */ +#define IFT_PROPDOCSWIRELESSUPSTREAM 0xb6 /* prop/Wireless Upstream */ +#define IFT_HIPERLAN2 0xb7 /* HIPERLAN Type 2 Radio Interface */ +#define IFT_PROPBWAP2MP 0xb8 /* PropBroadbandWirelessAccess P2MP*/ +#define IFT_SONETOVERHEADCHANNEL 0xb9 /* SONET Overhead Channel */ +#define IFT_DIGITALWRAPPEROVERHEADCHANNEL 0xba /* Digital Wrapper Overhead */ +#define IFT_AAL2 0xbb /* ATM adaptation layer 2 */ +#define IFT_RADIOMAC 0xbc /* MAC layer over radio links */ +#define IFT_ATMRADIO 0xbd /* ATM over radio links */ +#define IFT_IMT 0xbe /* Inter-Machine Trunks */ +#define IFT_MVL 0xbf /* Multiple Virtual Lines DSL */ +#define IFT_REACHDSL 0xc0 /* Long Reach DSL */ +#define IFT_FRDLCIENDPT 0xc1 /* Frame Relay DLCI End Point */ +#define IFT_ATMVCIENDPT 0xc2 /* ATM VCI End Point */ +#define IFT_OPTICALCHANNEL 0xc3 /* Optical Channel */ +#define IFT_OPTICALTRANSPORT 0xc4 /* Optical Transport */ +#define IFT_BRIDGE 0xd1 /* Transparent bridge interface */ + +#define IFT_STF 0xd7 /* 6to4 interface */ + +/* not based on IANA assignments */ +#define IFT_GIF 0xf0 +#define IFT_PVC 0xf1 +#define IFT_FAITH 0xf2 +#define IFT_ENC 0xf4 +#define IFT_PFLOG 0xf6 +#define IFT_PFSYNC 0xf7 +#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */ +#define IFT_IPXIP 0xf9 /* IPX over IP tunneling; no longer used. */ +#endif /* !_NET_IF_TYPES_H_ */ diff --git a/freebsd/sys/net/if_var.h b/freebsd/sys/net/if_var.h index 913d62a9..172ebe0e 100644 --- a/freebsd/sys/net/if_var.h +++ b/freebsd/sys/net/if_var.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_VAR_HH_ -#define _NET_IF_VAR_HH_ +#ifndef _NET_IF_VAR_H_ +#define _NET_IF_VAR_H_ /* * Structures defining a network interface, providing a packet @@ -74,24 +74,24 @@ struct route; struct vnet; #endif -#include /* get TAILQ macros */ +#include /* get TAILQ macros */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #endif /* _KERNEL */ -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ -#include +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ +#include #define IF_DUNIT_NONE -1 -#include +#include TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */ TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */ @@ -901,4 +901,4 @@ int ether_poll_deregister(struct ifnet *ifp); #endif /* _KERNEL */ -#endif /* !_NET_IF_VAR_HH_ */ +#endif /* !_NET_IF_VAR_H_ */ diff --git a/freebsd/sys/net/if_vlan.c b/freebsd/sys/net/if_vlan.c index 5ae5efd4..576243d9 100644 --- a/freebsd/sys/net/if_vlan.c +++ b/freebsd/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1998 Massachusetts Institute of Technology @@ -41,32 +41,32 @@ * and ask it to send them. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #define VLANNAME "vlan" #define VLAN_DEF_HWIDTH 4 diff --git a/freebsd/sys/net/if_vlan_var.h b/freebsd/sys/net/if_vlan_var.h index 045e2fa1..ec71df1a 100644 --- a/freebsd/sys/net/if_vlan_var.h +++ b/freebsd/sys/net/if_vlan_var.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _NET_IF_VLAN_VAR_HH_ -#define _NET_IF_VLAN_VAR_HH_ 1 +#ifndef _NET_IF_VLAN_VAR_H_ +#define _NET_IF_VLAN_VAR_H_ 1 struct ether_vlan_header { u_char evl_dhost[ETHER_ADDR_LEN]; @@ -134,4 +134,4 @@ struct vlanreq { extern void (*vlan_trunk_cap_p)(struct ifnet *); #endif /* _KERNEL */ -#endif /* _NET_IF_VLAN_VAR_HH_ */ +#endif /* _NET_IF_VLAN_VAR_H_ */ diff --git a/freebsd/sys/net/iso88025.h b/freebsd/sys/net/iso88025.h index 26e3ada6..6edd2e0b 100644 --- a/freebsd/sys/net/iso88025.h +++ b/freebsd/sys/net/iso88025.h @@ -40,8 +40,8 @@ * Fundamental constants relating to iso 802.5 */ -#ifndef _NET_ISO88025_HH_ -#define _NET_ISO88025_HH_ +#ifndef _NET_ISO88025_H_ +#define _NET_ISO88025_H_ /* * General ISO 802.5 definitions diff --git a/freebsd/sys/net/netisr.c b/freebsd/sys/net/netisr.c index 4d34953a..b82c1f0f 100644 --- a/freebsd/sys/net/netisr.c +++ b/freebsd/sys/net/netisr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Robert N. M. Watson @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -61,34 +61,34 @@ __FBSDID("$FreeBSD$"); * detail in netisr.h. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef DDB -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include /*- * Synchronize use and modification of the registered netisr data structures; diff --git a/freebsd/sys/net/netisr.h b/freebsd/sys/net/netisr.h index b755332a..72e7f17f 100644 --- a/freebsd/sys/net/netisr.h +++ b/freebsd/sys/net/netisr.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _NET_NETISR_HH_ -#define _NET_NETISR_HH_ +#ifndef _NET_NETISR_H_ +#define _NET_NETISR_H_ #ifdef _KERNEL /* @@ -153,4 +153,4 @@ void netisr_poll(void); void netisr_pollmore(void); #endif /* !_KERNEL */ -#endif /* !_NET_NETISR_HH_ */ +#endif /* !_NET_NETISR_H_ */ diff --git a/freebsd/sys/net/pfil.c b/freebsd/sys/net/pfil.c index 3a382bc5..a11986a9 100644 --- a/freebsd/sys/net/pfil.c +++ b/freebsd/sys/net/pfil.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $NetBSD: pfil.c,v 1.20 2001/11/12 23:49:46 lukem Exp $ */ @@ -31,23 +31,23 @@ * SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include static struct mtx pfil_global_lock; diff --git a/freebsd/sys/net/pfil.h b/freebsd/sys/net/pfil.h index 78ab0518..142da67d 100644 --- a/freebsd/sys/net/pfil.h +++ b/freebsd/sys/net/pfil.h @@ -29,15 +29,15 @@ * SUCH DAMAGE. */ -#ifndef _NET_PFIL_HH_ -#define _NET_PFIL_HH_ +#ifndef _NET_PFIL_H_ +#define _NET_PFIL_H_ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct mbuf; struct ifnet; @@ -114,4 +114,4 @@ pfil_hook_get(int dir, struct pfil_head *ph) return (NULL); } -#endif /* _NET_PFIL_HH_ */ +#endif /* _NET_PFIL_H_ */ diff --git a/freebsd/sys/net/pfkeyv2.h b/freebsd/sys/net/pfkeyv2.h index f8e088e1..c45f8b05 100644 --- a/freebsd/sys/net/pfkeyv2.h +++ b/freebsd/sys/net/pfkeyv2.h @@ -36,8 +36,8 @@ * sakane@ydc.co.jp */ -#ifndef _NET_PFKEYV2_HH_ -#define _NET_PFKEYV2_HH_ +#ifndef _NET_PFKEYV2_H_ +#define _NET_PFKEYV2_H_ /* This file defines structures and symbols for the PF_KEY Version 2 @@ -429,4 +429,4 @@ struct sadb_x_nat_t_frag { #endif /* __PFKEY_V2_H */ -#endif /* _NET_PFKEYV2_HH_ */ +#endif /* _NET_PFKEYV2_H_ */ diff --git a/freebsd/sys/net/ppp_defs.h b/freebsd/sys/net/ppp_defs.h index e0690e94..386a1763 100644 --- a/freebsd/sys/net/ppp_defs.h +++ b/freebsd/sys/net/ppp_defs.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _PPP_DEFS_HH_ -#define _PPP_DEFS_HH_ +#ifndef _PPP_DEFS_H_ +#define _PPP_DEFS_H_ /* * The basic PPP frame. @@ -155,4 +155,4 @@ struct ppp_idle { #endif #endif -#endif /* _PPP_DEFS_HH_ */ +#endif /* _PPP_DEFS_H_ */ diff --git a/freebsd/sys/net/radix.c b/freebsd/sys/net/radix.c index c1881acb..e0cdea30 100644 --- a/freebsd/sys/net/radix.c +++ b/freebsd/sys/net/radix.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1988, 1989, 1993 @@ -35,27 +35,27 @@ /* * Routines to build and maintain radix trees for routing lookups. */ -#include +#include #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif #else /* !_KERNEL */ -#include -#include -#include +#include +#include +#include #define log(x, arg...) fprintf(stderr, ## arg) #define panic(x) fprintf(stderr, "PANIC: %s", x), exit(1) #define min(a, b) ((a) < (b) ? (a) : (b) ) -#include +#include #endif /* !_KERNEL */ static int rn_walktree_from(struct radix_node_head *h, void *a, void *m, diff --git a/freebsd/sys/net/radix.h b/freebsd/sys/net/radix.h index ccd5f491..29659b54 100644 --- a/freebsd/sys/net/radix.h +++ b/freebsd/sys/net/radix.h @@ -30,13 +30,13 @@ * $FreeBSD$ */ -#ifndef _RADIX_HH_ -#define _RADIX_HH_ +#ifndef _RADIX_H_ +#define _RADIX_H_ #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #endif #ifdef MALLOC_DECLARE @@ -173,4 +173,4 @@ struct radix_node struct radix_node_head *head), *rn_match(void *, struct radix_node_head *); -#endif /* _RADIX_HH_ */ +#endif /* _RADIX_H_ */ diff --git a/freebsd/sys/net/radix_mpath.c b/freebsd/sys/net/radix_mpath.c index 3c348249..bb7b6fd4 100644 --- a/freebsd/sys/net/radix_mpath.c +++ b/freebsd/sys/net/radix_mpath.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: radix_mpath.c,v 1.17 2004/11/08 10:29:39 itojun Exp $ */ @@ -35,23 +35,23 @@ * PROPERTIES. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * give some jitter to hash, to avoid synchronization between routers diff --git a/freebsd/sys/net/radix_mpath.h b/freebsd/sys/net/radix_mpath.h index b6d8c16a..bcb210e3 100644 --- a/freebsd/sys/net/radix_mpath.h +++ b/freebsd/sys/net/radix_mpath.h @@ -34,8 +34,8 @@ */ /* $FreeBSD$ */ -#ifndef _NET_RADIX_MPATH_HH_ -#define _NET_RADIX_MPATH_HH_ +#ifndef _NET_RADIX_MPATH_H_ +#define _NET_RADIX_MPATH_H_ #ifdef _KERNEL /* @@ -60,4 +60,4 @@ int rn6_mpath_inithead(void **, int); #endif -#endif /* _NET_RADIX_MPATH_HH_ */ +#endif /* _NET_RADIX_MPATH_H_ */ diff --git a/freebsd/sys/net/raw_cb.c b/freebsd/sys/net/raw_cb.c index 2fd73dac..13f4b949 100644 --- a/freebsd/sys/net/raw_cb.c +++ b/freebsd/sys/net/raw_cb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1980, 1986, 1993 @@ -33,21 +33,21 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include /* * Routines to manage the raw protocol control blocks. diff --git a/freebsd/sys/net/raw_cb.h b/freebsd/sys/net/raw_cb.h index 278b4235..35b546c5 100644 --- a/freebsd/sys/net/raw_cb.h +++ b/freebsd/sys/net/raw_cb.h @@ -31,10 +31,10 @@ * $FreeBSD$ */ -#ifndef _NET_RAW_CB_HH_ -#define _NET_RAW_CB_HH_ +#ifndef _NET_RAW_CB_H_ +#define _NET_RAW_CB_H_ -#include +#include /* * Raw protocol interface control block. Used to tie a socket to the generic diff --git a/freebsd/sys/net/raw_usrreq.c b/freebsd/sys/net/raw_usrreq.c index bdf3369e..0723799f 100644 --- a/freebsd/sys/net/raw_usrreq.c +++ b/freebsd/sys/net/raw_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1980, 1986, 1993 @@ -33,23 +33,23 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include MTX_SYSINIT(rawcb_mtx, &rawcb_mtx, "rawcb", MTX_DEF); diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c index ee43c843..2dd2938c 100644 --- a/freebsd/sys/net/route.c +++ b/freebsd/sys/net/route.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1980, 1986, 1991, 1993 @@ -36,38 +36,38 @@ * Which is the new name for an in kernel routing (next hop) table. * ***********************************************************************/ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include -#include +#include +#include -#include +#include u_int rt_numfibs = RT_NUMFIBS; SYSCTL_INT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, ""); @@ -262,7 +262,7 @@ VNET_SYSUNINIT(vnet_route_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, vnet_route_uninit, 0); #endif -#ifndef _SYS_SYSPROTO_HH_ +#ifndef _SYS_SYSPROTO_H_ struct setfib_args { int fibnum; }; diff --git a/freebsd/sys/net/route.h b/freebsd/sys/net/route.h index 4375020f..4014b3f6 100644 --- a/freebsd/sys/net/route.h +++ b/freebsd/sys/net/route.h @@ -1,2 +1,446 @@ -#include -#include +/*- + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)route.h 8.4 (Berkeley) 1/9/95 + * $FreeBSD$ + */ + +#ifndef _NET_ROUTE_H_ +#define _NET_ROUTE_H_ + +/* + * Kernel resident routing tables. + * + * The routing tables are initialized when interface addresses + * are set by making entries for all directly connected interfaces. + */ + +/* + * A route consists of a destination address, a reference + * to a routing entry, and a reference to an llentry. + * These are often held by protocols in their control + * blocks, e.g. inpcb. + */ +struct route { + struct rtentry *ro_rt; + struct llentry *ro_lle; + struct sockaddr ro_dst; +}; + +/* + * These numbers are used by reliable protocols for determining + * retransmission behavior and are included in the routing structure. + */ +struct rt_metrics_lite { + u_long rmx_mtu; /* MTU for this path */ + u_long rmx_expire; /* lifetime for route, e.g. redirect */ + u_long rmx_pksent; /* packets sent using this route */ + u_long rmx_weight; /* absolute weight */ +}; + +struct rt_metrics { + u_long rmx_locks; /* Kernel must leave these values alone */ + u_long rmx_mtu; /* MTU for this path */ + u_long rmx_hopcount; /* max hops expected */ + u_long rmx_expire; /* lifetime for route, e.g. redirect */ + u_long rmx_recvpipe; /* inbound delay-bandwidth product */ + u_long rmx_sendpipe; /* outbound delay-bandwidth product */ + u_long rmx_ssthresh; /* outbound gateway buffer limit */ + u_long rmx_rtt; /* estimated round trip time */ + u_long rmx_rttvar; /* estimated rtt variance */ + u_long rmx_pksent; /* packets sent using this route */ + u_long rmx_weight; /* route weight */ + u_long rmx_filler[3]; /* will be used for T/TCP later */ +}; + +/* + * rmx_rtt and rmx_rttvar are stored as microseconds; + * RTTTOPRHZ(rtt) converts to a value suitable for use + * by a protocol slowtimo counter. + */ +#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */ +#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ)) + +/* MRT compile-time constants */ +#ifdef _KERNEL + #ifndef ROUTETABLES + #define RT_NUMFIBS 1 + #define RT_MAXFIBS 1 + #else + /* while we use 4 bits in the mbuf flags, we are limited to 16 */ + #define RT_MAXFIBS 16 + #if ROUTETABLES > RT_MAXFIBS + #define RT_NUMFIBS RT_MAXFIBS + #error "ROUTETABLES defined too big" + #else + #if ROUTETABLES == 0 + #define RT_NUMFIBS 1 + #else + #define RT_NUMFIBS ROUTETABLES + #endif + #endif + #endif +#endif + +extern u_int rt_numfibs; /* number fo usable routing tables */ +extern u_int tunnel_fib; /* tunnels use these */ +extern u_int fwd_fib; /* packets being forwarded use these routes */ +/* + * XXX kernel function pointer `rt_output' is visible to applications. + */ +struct mbuf; + +/* + * We distinguish between routes to hosts and routes to networks, + * preferring the former if available. For each route we infer + * the interface to use from the gateway address supplied when + * the route was entered. Routes that forward packets through + * gateways are marked so that the output routines know to address the + * gateway rather than the ultimate destination. + */ +#ifndef RNF_NORMAL +#include +#ifdef RADIX_MPATH +#include +#endif +#endif +struct rtentry { + struct radix_node rt_nodes[2]; /* tree glue, and other values */ + /* + * XXX struct rtentry must begin with a struct radix_node (or two!) + * because the code does some casts of a 'struct radix_node *' + * to a 'struct rtentry *' + */ +#define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key))) +#define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask))) + struct sockaddr *rt_gateway; /* value */ + int rt_flags; /* up/down?, host/net */ + int rt_refcnt; /* # held references */ + struct ifnet *rt_ifp; /* the answer: interface to use */ + struct ifaddr *rt_ifa; /* the answer: interface address to use */ + struct rt_metrics_lite rt_rmx; /* metrics used by rx'ing protocols */ + u_int rt_fibnum; /* which FIB */ +#ifdef _KERNEL + /* XXX ugly, user apps use this definition but don't have a mtx def */ + struct mtx rt_mtx; /* mutex for routing entry */ +#endif +}; + +/* + * Following structure necessary for 4.3 compatibility; + * We should eventually move it to a compat file. + */ +struct ortentry { + u_long rt_hash; /* to speed lookups */ + struct sockaddr rt_dst; /* key */ + struct sockaddr rt_gateway; /* value */ + short rt_flags; /* up/down?, host/net */ + short rt_refcnt; /* # held references */ + u_long rt_use; /* raw # packets forwarded */ + struct ifnet *rt_ifp; /* the answer: interface to use */ +}; + +#define rt_use rt_rmx.rmx_pksent + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +/* 0x80 unused, was RTF_DELCLONE */ +/* 0x100 unused, was RTF_CLONING */ +#define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +#define RTF_LLINFO 0x400 /* DEPRECATED - exists ONLY for backward + compatibility */ +#define RTF_LLDATA 0x400 /* used by apps to add/del L2 entries */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ + +/* XXX: temporary to stay API/ABI compatible with userland */ +#ifndef _KERNEL +#define RTF_PRCLONING 0x10000 /* unused, for compatibility */ +#endif + +/* 0x20000 unused, was RTF_WASCLONED */ +#define RTF_PROTO3 0x40000 /* protocol specific routing flag */ +/* 0x80000 unused */ +#define RTF_PINNED 0x100000 /* future use */ +#define RTF_LOCAL 0x200000 /* route represents a local address */ +#define RTF_BROADCAST 0x400000 /* route represents a bcast address */ +#define RTF_MULTICAST 0x800000 /* route represents a mcast address */ + /* 0x8000000 and up unassigned */ +#define RTF_STICKY 0x10000000 /* always route dst->src */ + +#define RTF_RNH_LOCKED 0x40000000 /* radix node head is locked */ + +/* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ +#define RTF_FMASK \ + (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ + RTF_REJECT | RTF_STATIC | RTF_STICKY) + +/* + * Routing statistics. + */ +struct rtstat { + short rts_badredirect; /* bogus redirect calls */ + short rts_dynamic; /* routes created by redirects */ + short rts_newgateway; /* routes modified by redirects */ + short rts_unreach; /* lookups which failed */ + short rts_wildcard; /* lookups satisfied by a wildcard */ +}; +/* + * Structures for routing messages. + */ +struct rt_msghdr { + u_short rtm_msglen; /* to skip over non-understood messages */ + u_char rtm_version; /* future binary compatibility */ + u_char rtm_type; /* message type */ + u_short rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + pid_t rtm_pid; /* identify sender */ + int rtm_seq; /* for sender to identify action */ + int rtm_errno; /* why failed */ + int rtm_fmask; /* bitmask used in RTM_CHANGE message */ + u_long rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx; /* metrics themselves */ +}; + +#define RTM_VERSION 5 /* Up the ante and ignore older versions */ + +/* + * Message types. + */ +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_GET 0x4 /* Report Metrics */ +#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ +#define RTM_REDIRECT 0x6 /* Told to use different route */ +#define RTM_MISS 0x7 /* Lookup failed on this address */ +#define RTM_LOCK 0x8 /* fix specified metrics */ +#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ +#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ +#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ +#define RTM_NEWADDR 0xc /* address being added to iface */ +#define RTM_DELADDR 0xd /* address being removed from iface */ +#define RTM_IFINFO 0xe /* iface going up/down etc. */ +#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */ +#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */ +#define RTM_IFANNOUNCE 0x11 /* iface arrival/departure */ +#define RTM_IEEE80211 0x12 /* IEEE80211 wireless event */ + +/* + * Bitmask values for rtm_inits and rmx_locks. + */ +#define RTV_MTU 0x1 /* init or lock _mtu */ +#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ +#define RTV_EXPIRE 0x4 /* init or lock _expire */ +#define RTV_RPIPE 0x8 /* init or lock _recvpipe */ +#define RTV_SPIPE 0x10 /* init or lock _sendpipe */ +#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ +#define RTV_RTT 0x40 /* init or lock _rtt */ +#define RTV_RTTVAR 0x80 /* init or lock _rttvar */ +#define RTV_WEIGHT 0x100 /* init or lock _weight */ + +/* + * Bitmask values for rtm_addrs. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ + +/* + * Index offsets for sockaddr array for alternate internal encoding. + */ +#define RTAX_DST 0 /* destination sockaddr present */ +#define RTAX_GATEWAY 1 /* gateway sockaddr present */ +#define RTAX_NETMASK 2 /* netmask sockaddr present */ +#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_IFP 4 /* interface name sockaddr present */ +#define RTAX_IFA 5 /* interface addr sockaddr present */ +#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ +#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTAX_MAX 8 /* size of array to allocate */ + +struct rt_addrinfo { + int rti_addrs; + struct sockaddr *rti_info[RTAX_MAX]; + int rti_flags; + struct ifaddr *rti_ifa; + struct ifnet *rti_ifp; +}; + +/* + * This macro returns the size of a struct sockaddr when passed + * through a routing socket. Basically we round up sa_len to + * a multiple of sizeof(long), with a minimum of sizeof(long). + * The check for a NULL pointer is just a convenience, probably never used. + * The case sa_len == 0 should only apply to empty structures. + */ +#define SA_SIZE(sa) \ + ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \ + sizeof(long) : \ + 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) + +#ifdef _KERNEL + +#define RT_LINK_IS_UP(ifp) (!((ifp)->if_capabilities & IFCAP_LINKSTATE) \ + || (ifp)->if_link_state == LINK_STATE_UP) + +#define RT_LOCK_INIT(_rt) \ + mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK) +#define RT_LOCK(_rt) mtx_lock(&(_rt)->rt_mtx) +#define RT_TRYLOCK(_rt) mtx_trylock(&(_rt)->rt_mtx) +#define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) +#define RT_LOCK_DESTROY(_rt) mtx_destroy(&(_rt)->rt_mtx) +#define RT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED) + +#define RT_ADDREF(_rt) do { \ + RT_LOCK_ASSERT(_rt); \ + KASSERT((_rt)->rt_refcnt >= 0, \ + ("negative refcnt %d", (_rt)->rt_refcnt)); \ + (_rt)->rt_refcnt++; \ +} while (0) + +#define RT_REMREF(_rt) do { \ + RT_LOCK_ASSERT(_rt); \ + KASSERT((_rt)->rt_refcnt > 0, \ + ("bogus refcnt %d", (_rt)->rt_refcnt)); \ + (_rt)->rt_refcnt--; \ +} while (0) + +#define RTFREE_LOCKED(_rt) do { \ + if ((_rt)->rt_refcnt <= 1) \ + rtfree(_rt); \ + else { \ + RT_REMREF(_rt); \ + RT_UNLOCK(_rt); \ + } \ + /* guard against invalid refs */ \ + _rt = 0; \ +} while (0) + +#define RTFREE(_rt) do { \ + RT_LOCK(_rt); \ + RTFREE_LOCKED(_rt); \ +} while (0) + +#define RT_TEMP_UNLOCK(_rt) do { \ + RT_ADDREF(_rt); \ + RT_UNLOCK(_rt); \ +} while (0) + +#define RT_RELOCK(_rt) do { \ + RT_LOCK(_rt); \ + if ((_rt)->rt_refcnt <= 1) { \ + rtfree(_rt); \ + _rt = 0; /* signal that it went away */ \ + } else { \ + RT_REMREF(_rt); \ + /* note that _rt is still valid */ \ + } \ +} while (0) + +struct radix_node_head *rt_tables_get_rnh(int, int); + +struct ifmultiaddr; + +void rt_ieee80211msg(struct ifnet *, int, void *, size_t); +void rt_ifannouncemsg(struct ifnet *, int); +void rt_ifmsg(struct ifnet *); +void rt_missmsg(int, struct rt_addrinfo *, int, int); +void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); +void rt_newmaddrmsg(int, struct ifmultiaddr *); +int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *); +void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); + +/* + * Note the following locking behavior: + * + * rtalloc_ign() and rtalloc() return ro->ro_rt unlocked + * + * rtalloc1() returns a locked rtentry + * + * rtfree() and RTFREE_LOCKED() require a locked rtentry + * + * RTFREE() uses an unlocked entry. + */ + +int rtexpunge(struct rtentry *); +void rtfree(struct rtentry *); +int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *); + +/* XXX MRT COMPAT VERSIONS THAT SET UNIVERSE to 0 */ +/* Thes are used by old code not yet converted to use multiple FIBS */ +int rt_getifa(struct rt_addrinfo *); +void rtalloc_ign(struct route *ro, u_long ignflags); +void rtalloc(struct route *ro); /* XXX deprecated, use rtalloc_ign(ro, 0) */ +struct rtentry *rtalloc1(struct sockaddr *, int, u_long); +int rtinit(struct ifaddr *, int, int); +int rtioctl(u_long, caddr_t); +void rtredirect(struct sockaddr *, struct sockaddr *, + struct sockaddr *, int, struct sockaddr *); +int rtrequest(int, struct sockaddr *, + struct sockaddr *, struct sockaddr *, int, struct rtentry **); + +/* defaults to "all" FIBs */ +int rtinit_fib(struct ifaddr *, int, int); + +/* XXX MRT NEW VERSIONS THAT USE FIBs + * For now the protocol indepedent versions are the same as the AF_INET ones + * but this will change.. + */ +int rt_getifa_fib(struct rt_addrinfo *, u_int fibnum); +void rtalloc_ign_fib(struct route *ro, u_long ignflags, u_int fibnum); +void rtalloc_fib(struct route *ro, u_int fibnum); +struct rtentry *rtalloc1_fib(struct sockaddr *, int, u_long, u_int); +int rtioctl_fib(u_long, caddr_t, u_int); +void rtredirect_fib(struct sockaddr *, struct sockaddr *, + struct sockaddr *, int, struct sockaddr *, u_int); +int rtrequest_fib(int, struct sockaddr *, + struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); +int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); + +#include +typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *); +typedef void (*rtevent_redirect_fn)(void *, struct rtentry *, struct rtentry *, struct sockaddr *); +EVENTHANDLER_DECLARE(route_arp_update_event, rtevent_arp_update_fn); +EVENTHANDLER_DECLARE(route_redirect_event, rtevent_redirect_fn); +#endif + +#endif diff --git a/freebsd/sys/net/rtsock.c b/freebsd/sys/net/rtsock.c index 287dd74d..0cfc6e91 100644 --- a/freebsd/sys/net/rtsock.c +++ b/freebsd/sys/net/rtsock.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1988, 1991, 1993 @@ -31,42 +31,42 @@ * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 * $FreeBSD$ */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifdef INET6 -#include +#include #endif #if defined(INET) || defined(INET6) @@ -76,8 +76,8 @@ extern void sctp_addr_change(struct ifaddr *ifa, int cmd); #endif #ifdef COMPAT_FREEBSD32 -#include -#include +#include +#include struct if_data32 { uint8_t ifi_type; diff --git a/freebsd/sys/net/slcompress.c b/freebsd/sys/net/slcompress.c index be337c1f..876d5be3 100644 --- a/freebsd/sys/net/slcompress.c +++ b/freebsd/sys/net/slcompress.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1989, 1993, 1994 @@ -41,16 +41,16 @@ * */ -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #ifndef SL_NO_STATS #define INCR(counter) ++comp->counter; diff --git a/freebsd/sys/net/slcompress.h b/freebsd/sys/net/slcompress.h index 08c9042e..794d8b83 100644 --- a/freebsd/sys/net/slcompress.h +++ b/freebsd/sys/net/slcompress.h @@ -34,8 +34,8 @@ * $FreeBSD$ */ -#ifndef _NET_SLCOMPRESS_HH_ -#define _NET_SLCOMPRESS_HH_ +#ifndef _NET_SLCOMPRESS_H_ +#define _NET_SLCOMPRESS_H_ #define MAX_STATES 16 /* must be > 2 and < 256 */ #define MAX_HDR 128 @@ -155,4 +155,4 @@ int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *); int sl_uncompress_tcp_core(u_char *, int, int, u_int, struct slcompress *, u_char **, u_int *); -#endif /* !_NET_SLCOMPRESS_HH_ */ +#endif /* !_NET_SLCOMPRESS_H_ */ diff --git a/freebsd/sys/net/vnet.h b/freebsd/sys/net/vnet.h index 7f6326fe..d3c426a4 100644 --- a/freebsd/sys/net/vnet.h +++ b/freebsd/sys/net/vnet.h @@ -54,8 +54,8 @@ * sysinits. */ -#ifndef _NET_VNET_HH_ -#define _NET_VNET_HH_ +#ifndef _NET_VNET_H_ +#define _NET_VNET_H_ /* * struct vnet describes a virtualized network stack, and is primarily a @@ -63,7 +63,7 @@ * as required for libkvm. */ #if defined(_KERNEL) || defined(_WANT_VNET) -#include +#include struct vnet { LIST_ENTRY(vnet) vnet_le; /* all vnets list */ @@ -86,10 +86,10 @@ struct vnet { #ifdef _KERNEL #ifdef VIMAGE -#include -#include /* for struct thread */ -#include -#include +#include +#include /* for struct thread */ +#include +#include /* * Location of the kernel's 'set_vnet' linker set. @@ -275,7 +275,7 @@ int vnet_sysctl_handle_uint(SYSCTL_HANDLER_ARGS); * startup and shutdown methods to be run when virtual network stack * instances are created and destroyed. */ -#include +#include /* * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and @@ -330,7 +330,7 @@ void vnet_deregister_sysuninit(void *arg); /* * EVENTHANDLER(9) extensions. */ -#include +#include void vnet_global_eventhandler_iterator_func(void *, ...); #define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ @@ -434,4 +434,4 @@ do { \ #endif /* VIMAGE */ #endif /* _KERNEL */ -#endif /* !_NET_VNET_HH_ */ +#endif /* !_NET_VNET_H_ */ diff --git a/freebsd/sys/net/zlib.c b/freebsd/sys/net/zlib.c index a7a54740..06b92bb9 100644 --- a/freebsd/sys/net/zlib.c +++ b/freebsd/sys/net/zlib.c @@ -1,4 +1,4 @@ -#include +#include /* * This file is derived from various .h and .c files from the zlib-1.0.4 @@ -49,38 +49,38 @@ #define _Z_UTIL_H #ifdef _KERNEL -#include +#include #else -#include +#include #endif #ifdef _KERNEL /* Assume this is a *BSD or SVR4 kernel */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include # define HAVE_MEMCPY #else #if defined(__KERNEL__) /* Assume this is a Linux kernel */ -#include +#include #define HAVE_MEMCPY #else /* not kernel */ #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS) -# include -# include +# include +# include #else extern int errno; #endif #ifdef STDC -# include -# include +# include +# include #endif #endif /* __KERNEL__ */ #endif /* _KERNEL */ @@ -135,9 +135,9 @@ static const char *z_errmsg[10]; /* indexed by 2-zlib_error */ #ifdef MSDOS # define OS_CODE 0x00 # ifdef __TURBOC__ -# include +# include # else /* MSC or DJGPP */ -# include +# include # endif #endif @@ -228,7 +228,7 @@ static const char *z_errmsg[10]; /* indexed by 2-zlib_error */ /* Diagnostic functions */ #ifdef DEBUG_ZLIB -# include +# include # ifndef verbose # define verbose 0 # endif @@ -278,7 +278,7 @@ void zcfree OF((voidpf opaque, voidpf ptr)); #ifndef _DEFLATE_H #define _DEFLATE_H -/* #include */ +/* #include */ /* =========================================================================== * Internal compression state. @@ -595,7 +595,7 @@ void _tr_stored_type_only OF((deflate_state *)); /* From: deflate.c,v 1.15 1996/07/24 13:40:58 me Exp $ */ -/* #include */ +/* #include */ char deflate_copyright[] = " deflate 1.0.4 Copyright 1995-1996 Jean-loup Gailly "; /* @@ -1871,10 +1871,10 @@ local block_state deflate_slow(s, flush) /* From: trees.c,v 1.11 1996/07/24 13:41:06 me Exp $ */ -/* #include */ +/* #include */ #ifdef DEBUG_ZLIB -# include +# include #endif /* =========================================================================== @@ -2996,7 +2996,7 @@ local void copy_block(s, buf, len, header) * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ +/* #include */ /* +++ infblock.h */ /* infblock.h -- header to use infblock.c @@ -3424,8 +3424,8 @@ z_streamp z; * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ -/* #include */ +/* #include */ +/* #include */ /* +++ inftrees.h */ /* inftrees.h -- header to use inftrees.c @@ -4101,8 +4101,8 @@ int inflate_packet_flush(s) * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ -/* #include */ +/* #include */ +/* #include */ char inflate_copyright[] = " inflate 1.0.4 Copyright 1995-1996 Mark Adler "; /* @@ -4585,11 +4585,11 @@ z_streamp z; /* for zfree function */ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ /* +++ inffast.h */ /* inffast.h -- header to use inffast.c @@ -4854,11 +4854,11 @@ z_streamp z; * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ #ifndef NO_DUMMY_DECL struct inflate_codes_state {int dummy;}; /* for buggy compilers */ @@ -4950,12 +4950,12 @@ int r; * For conditions of distribution and use, see copyright notice in zlib.h */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ -/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ #ifndef NO_DUMMY_DECL struct inflate_codes_state {int dummy;}; /* for buggy compilers */ @@ -5126,10 +5126,10 @@ z_streamp z; /* From: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */ #ifdef DEBUG_ZLIB -#include +#include #endif -/* #include */ +/* #include */ #ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ @@ -5343,7 +5343,7 @@ void zcfree (opaque, ptr) /* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */ -/* #include */ +/* #include */ #define BASE 65521L /* largest prime smaller than 65536 */ #define NMAX 5552 diff --git a/freebsd/sys/net/zlib.h b/freebsd/sys/net/zlib.h index 3da670fd..9529e43b 100644 --- a/freebsd/sys/net/zlib.h +++ b/freebsd/sys/net/zlib.h @@ -235,7 +235,7 @@ typedef uLong FAR uLongf; /* Compile with -DZLIB_DLL for Windows DLL support */ #if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) -# include +# include # define EXPORT WINAPI #else # define EXPORT diff --git a/freebsd/sys/net80211/_ieee80211.h b/freebsd/sys/net80211/_ieee80211.h index 764e5cf1..c488c006 100644 --- a/freebsd/sys/net80211/_ieee80211.h +++ b/freebsd/sys/net80211/_ieee80211.h @@ -25,8 +25,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211__IEEE80211_HH_ -#define _NET80211__IEEE80211_HH_ +#ifndef _NET80211__IEEE80211_H_ +#define _NET80211__IEEE80211_H_ /* * 802.11 implementation definitions. @@ -393,4 +393,4 @@ struct ieee80211_mimo_info { uint8_t pad[2]; uint32_t evm[3]; /* EVM data */ }; -#endif /* _NET80211__IEEE80211_HH_ */ +#endif /* _NET80211__IEEE80211_H_ */ diff --git a/freebsd/sys/net80211/ieee80211.c b/freebsd/sys/net80211/ieee80211.c index 8770d452..831998b6 100644 --- a/freebsd/sys/net80211/ieee80211.c +++ b/freebsd/sys/net80211/ieee80211.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,34 +26,34 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 generic handler */ -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include +#include -#include +#include const char *ieee80211_phymode_name[IEEE80211_MODE_MAX] = { [IEEE80211_MODE_AUTO] = "auto", diff --git a/freebsd/sys/net80211/ieee80211.h b/freebsd/sys/net80211/ieee80211.h index 6019e0ed..712c2a8d 100644 --- a/freebsd/sys/net80211/ieee80211.h +++ b/freebsd/sys/net80211/ieee80211.h @@ -25,8 +25,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_HH_ -#define _NET80211_IEEE80211_HH_ +#ifndef _NET80211_IEEE80211_H_ +#define _NET80211_IEEE80211_H_ /* * 802.11 protocol definitions. @@ -1084,4 +1084,4 @@ struct ieee80211_duration { IEEE80211_DUR_DS_SLOW_PLCPHDR + \ IEEE80211_DUR_DIFS) -#endif /* _NET80211_IEEE80211_HH_ */ +#endif /* _NET80211_IEEE80211_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_acl.c b/freebsd/sys/net80211/ieee80211_acl.c index 955989a6..2bad7bf4 100644 --- a/freebsd/sys/net80211/ieee80211_acl.c +++ b/freebsd/sys/net80211/ieee80211_acl.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -39,23 +39,23 @@ __FBSDID("$FreeBSD$"); * and if found the frame is either accepted (ACL_POLICY_ALLOW) * or rejected (ACL_POLICY_DENT). */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include enum { ACL_POLICY_OPEN = 0, /* open, don't check ACL's */ diff --git a/freebsd/sys/net80211/ieee80211_action.c b/freebsd/sys/net80211/ieee80211_action.c index 4bd5c700..0804b46c 100644 --- a/freebsd/sys/net80211/ieee80211_action.c +++ b/freebsd/sys/net80211/ieee80211_action.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -34,22 +34,22 @@ __FBSDID("$FreeBSD$"); * IEEE 802.11 send/recv action frame support. */ -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include static int send_inval(struct ieee80211_node *ni, int cat, int act, void *sa) diff --git a/freebsd/sys/net80211/ieee80211_action.h b/freebsd/sys/net80211/ieee80211_action.h index 943d145b..4ee2aff4 100644 --- a/freebsd/sys/net80211/ieee80211_action.h +++ b/freebsd/sys/net80211/ieee80211_action.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_ACTION_HH_ -#define _NET80211_IEEE80211_ACTION_HH_ +#ifndef _NET80211_IEEE80211_ACTION_H_ +#define _NET80211_IEEE80211_ACTION_H_ /* * 802.11 send/recv action frame support. @@ -49,4 +49,4 @@ void ieee80211_recv_action_unregister(int cat, int act); int ieee80211_recv_action(struct ieee80211_node *, const struct ieee80211_frame *, const uint8_t *, const uint8_t *); -#endif /* _NET80211_IEEE80211_ACTION_HH_ */ +#endif /* _NET80211_IEEE80211_ACTION_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_adhoc.c b/freebsd/sys/net80211/ieee80211_adhoc.c index 44d91041..3030bcd0 100644 --- a/freebsd/sys/net80211/ieee80211_adhoc.c +++ b/freebsd/sys/net80211/ieee80211_adhoc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,37 +33,37 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 IBSS mode support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) diff --git a/freebsd/sys/net80211/ieee80211_adhoc.h b/freebsd/sys/net80211/ieee80211_adhoc.h index 2fad984e..d8e19e5e 100644 --- a/freebsd/sys/net80211/ieee80211_adhoc.h +++ b/freebsd/sys/net80211/ieee80211_adhoc.h @@ -24,12 +24,12 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_ADHOC_HH_ -#define _NET80211_IEEE80211_ADHOC_HH_ +#ifndef _NET80211_IEEE80211_ADHOC_H_ +#define _NET80211_IEEE80211_ADHOC_H_ /* * Adhoc-mode (ibss+ahdemo) implementation definitions. */ void ieee80211_adhoc_attach(struct ieee80211com *); void ieee80211_adhoc_detach(struct ieee80211com *); -#endif /* !_NET80211_IEEE80211_STA_HH_ */ +#endif /* !_NET80211_IEEE80211_STA_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_ageq.c b/freebsd/sys/net80211/ieee80211_ageq.c index 2e838e35..3d164977 100644 --- a/freebsd/sys/net80211/ieee80211_ageq.c +++ b/freebsd/sys/net80211/ieee80211_ageq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 Sam Leffler, Errno Consulting @@ -25,25 +25,25 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 age queue support. */ -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include /* * Initialize an ageq. diff --git a/freebsd/sys/net80211/ieee80211_ageq.h b/freebsd/sys/net80211/ieee80211_ageq.h index 8aecae05..fdcf071a 100644 --- a/freebsd/sys/net80211/ieee80211_ageq.h +++ b/freebsd/sys/net80211/ieee80211_ageq.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_STAGEQ_HH_ -#define _NET80211_IEEE80211_STAGEQ_HH_ +#ifndef _NET80211_IEEE80211_STAGEQ_H_ +#define _NET80211_IEEE80211_STAGEQ_H_ struct ieee80211_node; struct mbuf; @@ -51,4 +51,4 @@ void ieee80211_ageq_drain_node(struct ieee80211_ageq *, struct mbuf *ieee80211_ageq_age(struct ieee80211_ageq *, int quanta); struct mbuf *ieee80211_ageq_remove(struct ieee80211_ageq *, struct ieee80211_node *match); -#endif /* _NET80211_IEEE80211_STAGEQ_HH_ */ +#endif /* _NET80211_IEEE80211_STAGEQ_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_amrr.c b/freebsd/sys/net80211/ieee80211_amrr.c index 33f6c5f3..9043ec61 100644 --- a/freebsd/sys/net80211/ieee80211_amrr.c +++ b/freebsd/sys/net80211/ieee80211_amrr.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: ieee80211_amrr.c,v 1.1 2006/06/17 19:07:19 damien Exp $ */ @@ -20,7 +20,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include __FBSDID("$FreeBSD$"); /*- @@ -31,25 +31,25 @@ __FBSDID("$FreeBSD$"); * INRIA Sophia - Projet Planete * http://www-sop.inria.fr/rapports/sophia/RR-5208.html */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef INET -#include -#include +#include +#include #endif -#include -#include -#include +#include +#include +#include #define is_success(amn) \ ((amn)->amn_retrycnt < (amn)->amn_txcnt / 10) diff --git a/freebsd/sys/net80211/ieee80211_amrr.h b/freebsd/sys/net80211/ieee80211_amrr.h index b425e268..ec67bdfb 100644 --- a/freebsd/sys/net80211/ieee80211_amrr.h +++ b/freebsd/sys/net80211/ieee80211_amrr.h @@ -17,8 +17,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _NET80211_IEEE80211_AMRR_HH_ -#define _NET80211_IEEE80211_AMRR_HH_ +#ifndef _NET80211_IEEE80211_AMRR_H_ +#define _NET80211_IEEE80211_AMRR_H_ /*- * Naive implementation of the Adaptive Multi Rate Retry algorithm: @@ -58,4 +58,4 @@ struct ieee80211_amrr_node { u_int amn_retrycnt; }; -#endif /* _NET80211_IEEE80211_AMRR_HH_ */ +#endif /* _NET80211_IEEE80211_AMRR_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_crypto.c b/freebsd/sys/net80211/ieee80211_crypto.c index c3a263c8..a3b3375e 100644 --- a/freebsd/sys/net80211/ieee80211_crypto.c +++ b/freebsd/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,26 +26,26 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 generic crypto support. */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include -#include -#include -#include /* XXX ETHER_HDR_LEN */ +#include +#include +#include /* XXX ETHER_HDR_LEN */ -#include +#include MALLOC_DEFINE(M_80211_CRYPTO, "80211crypto", "802.11 crypto state"); diff --git a/freebsd/sys/net80211/ieee80211_crypto.h b/freebsd/sys/net80211/ieee80211_crypto.h index b9e8e25b..57d05ad7 100644 --- a/freebsd/sys/net80211/ieee80211_crypto.h +++ b/freebsd/sys/net80211/ieee80211_crypto.h @@ -25,8 +25,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_CRYPTO_HH_ -#define _NET80211_IEEE80211_CRYPTO_HH_ +#ifndef _NET80211_IEEE80211_CRYPTO_H_ +#define _NET80211_IEEE80211_CRYPTO_H_ /* * 802.11 protocol crypto-related definitions. @@ -242,4 +242,4 @@ void ieee80211_notify_replay_failure(struct ieee80211vap *, void ieee80211_notify_michael_failure(struct ieee80211vap *, const struct ieee80211_frame *, u_int keyix); #endif /* defined(__KERNEL__) || defined(_KERNEL) */ -#endif /* _NET80211_IEEE80211_CRYPTO_HH_ */ +#endif /* _NET80211_IEEE80211_CRYPTO_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_crypto_ccmp.c b/freebsd/sys/net80211/ieee80211_crypto_ccmp.c index 82443508..a4f327bc 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_ccmp.c +++ b/freebsd/sys/net80211/ieee80211_crypto_ccmp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -35,24 +35,24 @@ __FBSDID("$FreeBSD$"); * AP driver. The code is used with the consent of the author and * it's license is included below. */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include #define AES_BLOCK_LEN 16 diff --git a/freebsd/sys/net80211/ieee80211_crypto_none.c b/freebsd/sys/net80211/ieee80211_crypto_none.c index f9112a9f..88dd7d72 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_none.c +++ b/freebsd/sys/net80211/ieee80211_crypto_none.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,27 +25,27 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 NULL crypto support. */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include static void *none_attach(struct ieee80211vap *, struct ieee80211_key *); static void none_detach(struct ieee80211_key *); diff --git a/freebsd/sys/net80211/ieee80211_crypto_tkip.c b/freebsd/sys/net80211/ieee80211_crypto_tkip.c index 6b0656e2..01d2002e 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_tkip.c +++ b/freebsd/sys/net80211/ieee80211_crypto_tkip.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -35,23 +35,23 @@ __FBSDID("$FreeBSD$"); * AP driver. The code is used with the consent of the author and * it's license is included below. */ -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include static void *tkip_attach(struct ieee80211vap *, struct ieee80211_key *); static void tkip_detach(struct ieee80211_key *); diff --git a/freebsd/sys/net80211/ieee80211_crypto_wep.c b/freebsd/sys/net80211/ieee80211_crypto_wep.c index 01b3c37d..577237e7 100644 --- a/freebsd/sys/net80211/ieee80211_crypto_wep.c +++ b/freebsd/sys/net80211/ieee80211_crypto_wep.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,29 +25,29 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 WEP crypto support. */ -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include static void *wep_attach(struct ieee80211vap *, struct ieee80211_key *); static void wep_detach(struct ieee80211_key *); diff --git a/freebsd/sys/net80211/ieee80211_ddb.c b/freebsd/sys/net80211/ieee80211_ddb.c index f3b30431..73778c29 100644 --- a/freebsd/sys/net80211/ieee80211_ddb.c +++ b/freebsd/sys/net80211/ieee80211_ddb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting @@ -25,38 +25,38 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include #ifdef DDB /* * IEEE 802.11 DDB support */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include -#include +#include +#include #define DB_PRINTSYM(prefix, name, addr) do { \ db_printf("%s%-25s : ", prefix, name); \ diff --git a/freebsd/sys/net80211/ieee80211_dfs.c b/freebsd/sys/net80211/ieee80211_dfs.c index 803ed337..3090a78c 100644 --- a/freebsd/sys/net80211/ieee80211_dfs.c +++ b/freebsd/sys/net80211/ieee80211_dfs.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,26 +33,26 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 DFS/Radar support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include MALLOC_DEFINE(M_80211_DFS, "80211dfs", "802.11 DFS state"); diff --git a/freebsd/sys/net80211/ieee80211_dfs.h b/freebsd/sys/net80211/ieee80211_dfs.h index 474b2078..90760777 100644 --- a/freebsd/sys/net80211/ieee80211_dfs.h +++ b/freebsd/sys/net80211/ieee80211_dfs.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_DFS_HH_ -#define _NET80211_IEEE80211_DFS_HH_ +#ifndef _NET80211_IEEE80211_DFS_H_ +#define _NET80211_IEEE80211_DFS_H_ /* * 802.11h/DFS definitions. @@ -54,4 +54,4 @@ void ieee80211_dfs_cac_clear(struct ieee80211com *, void ieee80211_dfs_notify_radar(struct ieee80211com *, struct ieee80211_channel *); struct ieee80211_channel *ieee80211_dfs_pickchannel(struct ieee80211com *); -#endif /* _NET80211_IEEE80211_DFS_HH_ */ +#endif /* _NET80211_IEEE80211_DFS_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_freebsd.c b/freebsd/sys/net80211/ieee80211_freebsd.c index 4188f112..23623ece 100644 --- a/freebsd/sys/net80211/ieee80211_freebsd.c +++ b/freebsd/sys/net80211/ieee80211_freebsd.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2003-2009 Sam Leffler, Errno Consulting @@ -25,37 +25,37 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 support (FreeBSD-specific code) */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include SYSCTL_NODE(_net, OID_AUTO, wlan, CTLFLAG_RD, 0, "IEEE 80211 parameters"); @@ -481,7 +481,7 @@ ieee80211_process_callback(struct ieee80211_node *ni, } } -#include +#include void get_random_bytes(void *p, size_t n) diff --git a/freebsd/sys/net80211/ieee80211_freebsd.h b/freebsd/sys/net80211/ieee80211_freebsd.h index 69efecd0..3cdc643e 100644 --- a/freebsd/sys/net80211/ieee80211_freebsd.h +++ b/freebsd/sys/net80211/ieee80211_freebsd.h @@ -24,16 +24,16 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_FREEBSD_HH_ -#define _NET80211_IEEE80211_FREEBSD_HH_ +#ifndef _NET80211_IEEE80211_FREEBSD_H_ +#define _NET80211_IEEE80211_FREEBSD_H_ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * Common state locking definitions. @@ -167,7 +167,7 @@ typedef struct mtx ieee80211_scan_table_lock_t; * is the last reference, otherwise 0 * ieee80211_node_refcnt reference count for printing (only) */ -#include +#include #define ieee80211_node_initref(_ni) \ do { ((_ni)->ni_refcnt = 1); } while (0) @@ -547,4 +547,4 @@ struct ieee80211_bpf_params { uint8_t ibp_try3; /* series 4 try count */ uint8_t ibp_rate3; /* series 4 IEEE tx rate */ }; -#endif /* _NET80211_IEEE80211_FREEBSD_HH_ */ +#endif /* _NET80211_IEEE80211_FREEBSD_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_hostap.c b/freebsd/sys/net80211/ieee80211_hostap.c index 892957be..803a6f4a 100644 --- a/freebsd/sys/net80211/ieee80211_hostap.c +++ b/freebsd/sys/net80211/ieee80211_hostap.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,36 +33,36 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 HOSTAP mode support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include +#include #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) diff --git a/freebsd/sys/net80211/ieee80211_hostap.h b/freebsd/sys/net80211/ieee80211_hostap.h index fa35e220..87f858d1 100644 --- a/freebsd/sys/net80211/ieee80211_hostap.h +++ b/freebsd/sys/net80211/ieee80211_hostap.h @@ -24,12 +24,12 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_HOSTAP_HH_ -#define _NET80211_IEEE80211_HOSTAP_HH_ +#ifndef _NET80211_IEEE80211_HOSTAP_H_ +#define _NET80211_IEEE80211_HOSTAP_H_ /* * Hostap implementation definitions. */ void ieee80211_hostap_attach(struct ieee80211com *); void ieee80211_hostap_detach(struct ieee80211com *); -#endif /* !_NET80211_IEEE80211_HOSTAP_HH_ */ +#endif /* !_NET80211_IEEE80211_HOSTAP_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_ht.c b/freebsd/sys/net80211/ieee80211_ht.c index 2b55c067..8f698f98 100644 --- a/freebsd/sys/net80211/ieee80211_ht.c +++ b/freebsd/sys/net80211/ieee80211_ht.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -34,23 +34,23 @@ __FBSDID("$FreeBSD$"); * IEEE 802.11n protocol support. */ -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include /* define here, used throughout file */ #define MS(_v, _f) (((_v) & _f) >> _f##_S) diff --git a/freebsd/sys/net80211/ieee80211_ht.h b/freebsd/sys/net80211/ieee80211_ht.h index 552a4264..7b0eab7a 100644 --- a/freebsd/sys/net80211/ieee80211_ht.h +++ b/freebsd/sys/net80211/ieee80211_ht.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_HT_HH_ -#define _NET80211_IEEE80211_HT_HH_ +#ifndef _NET80211_IEEE80211_HT_H_ +#define _NET80211_IEEE80211_HT_H_ /* * 802.11n protocol implementation definitions. @@ -199,4 +199,4 @@ uint8_t *ieee80211_add_htinfo_vendor(uint8_t *, struct ieee80211_node *); struct ieee80211_beacon_offsets; void ieee80211_ht_update_beacon(struct ieee80211vap *, struct ieee80211_beacon_offsets *); -#endif /* _NET80211_IEEE80211_HT_HH_ */ +#endif /* _NET80211_IEEE80211_HT_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_hwmp.c b/freebsd/sys/net80211/ieee80211_hwmp.c index f0a2cde9..ecf2879a 100644 --- a/freebsd/sys/net80211/ieee80211_hwmp.c +++ b/freebsd/sys/net80211/ieee80211_hwmp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 The FreeBSD Foundation @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -38,33 +38,33 @@ __FBSDID("$FreeBSD$"); * * Based on March 2009, D3.0 802.11s draft spec. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include static void hwmp_vattach(struct ieee80211vap *); static void hwmp_vdetach(struct ieee80211vap *); diff --git a/freebsd/sys/net80211/ieee80211_input.c b/freebsd/sys/net80211/ieee80211_input.c index 60803d2f..a5ee1094 100644 --- a/freebsd/sys/net80211/ieee80211_input.c +++ b/freebsd/sys/net80211/ieee80211_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,37 +26,37 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include + +#include +#include #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include +#include #ifdef INET -#include -#include +#include +#include #endif int @@ -748,7 +748,7 @@ ieee80211_getbssid(const struct ieee80211vap *vap, return wh->i_addr3; } -#include +#include void ieee80211_note(const struct ieee80211vap *vap, const char *fmt, ...) diff --git a/freebsd/sys/net80211/ieee80211_input.h b/freebsd/sys/net80211/ieee80211_input.h index 778badb6..5b38dddc 100644 --- a/freebsd/sys/net80211/ieee80211_input.h +++ b/freebsd/sys/net80211/ieee80211_input.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_INPUT_HH_ -#define _NET80211_IEEE80211_INPUT_HH_ +#ifndef _NET80211_IEEE80211_INPUT_H_ +#define _NET80211_IEEE80211_INPUT_H_ /* Verify the existence and length of __elem or get out. */ #define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen, _action) do { \ @@ -157,4 +157,4 @@ int ieee80211_alloc_challenge(struct ieee80211_node *); int ieee80211_parse_beacon(struct ieee80211_node *, struct mbuf *, struct ieee80211_scanparams *); int ieee80211_parse_action(struct ieee80211_node *, struct mbuf *); -#endif /* _NET80211_IEEE80211_INPUT_HH_ */ +#endif /* _NET80211_IEEE80211_INPUT_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_ioctl.c b/freebsd/sys/net80211/ieee80211_ioctl.c index 87d1acc5..995c82f2 100644 --- a/freebsd/sys/net80211/ieee80211_ioctl.c +++ b/freebsd/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,44 +26,44 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 ioctl support (FreeBSD-specific) */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef INET -#include -#include +#include +#include #endif #ifdef IPX -#include -#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #define IS_UP_AUTO(_vap) \ (IFNET_IS_UP_RUNNING((_vap)->iv_ifp) && \ diff --git a/freebsd/sys/net80211/ieee80211_ioctl.h b/freebsd/sys/net80211/ieee80211_ioctl.h index 109a27fb..89d8fe53 100644 --- a/freebsd/sys/net80211/ieee80211_ioctl.h +++ b/freebsd/sys/net80211/ieee80211_ioctl.h @@ -25,15 +25,15 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_IOCTL_HH_ -#define _NET80211_IEEE80211_IOCTL_HH_ +#ifndef _NET80211_IEEE80211_IOCTL_H_ +#define _NET80211_IEEE80211_IOCTL_H_ /* * IEEE 802.11 ioctls. */ -#include -#include -#include +#include +#include +#include /* * Per/node (station) statistics. @@ -846,4 +846,4 @@ struct ieee80211_clone_params { #define IEEE80211_CLONE_TDMA 0x0010 /* operate in TDMA mode */ #endif /* __FreeBSD__ */ -#endif /* _NET80211_IEEE80211_IOCTL_HH_ */ +#endif /* _NET80211_IEEE80211_IOCTL_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_mesh.c b/freebsd/sys/net80211/ieee80211_mesh.c index 06bac89a..1ed730fc 100644 --- a/freebsd/sys/net80211/ieee80211_mesh.c +++ b/freebsd/sys/net80211/ieee80211_mesh.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 The FreeBSD Foundation @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -38,31 +38,31 @@ __FBSDID("$FreeBSD$"); * * Based on March 2009, D3.0 802.11s draft spec. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include static void mesh_rt_flush_invalid(struct ieee80211vap *); static int mesh_select_proto_path(struct ieee80211vap *, const char *); diff --git a/freebsd/sys/net80211/ieee80211_mesh.h b/freebsd/sys/net80211/ieee80211_mesh.h index e90cd402..de9b5c2a 100644 --- a/freebsd/sys/net80211/ieee80211_mesh.h +++ b/freebsd/sys/net80211/ieee80211_mesh.h @@ -28,8 +28,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_MESH_HH_ -#define _NET80211_IEEE80211_MESH_HH_ +#ifndef _NET80211_IEEE80211_MESH_H_ +#define _NET80211_IEEE80211_MESH_H_ #define IEEE80211_MESH_DEFAULT_TTL 31 @@ -500,4 +500,4 @@ ieee80211_mesh_discover(struct ieee80211vap *vap, } #endif /* _KERNEL */ -#endif /* !_NET80211_IEEE80211_MESH_HH_ */ +#endif /* !_NET80211_IEEE80211_MESH_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_monitor.c b/freebsd/sys/net80211/ieee80211_monitor.c index b87c1d37..70b95a02 100644 --- a/freebsd/sys/net80211/ieee80211_monitor.c +++ b/freebsd/sys/net80211/ieee80211_monitor.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,31 +33,31 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 Monitor mode support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include static void monitor_vattach(struct ieee80211vap *); static int monitor_newstate(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/freebsd/sys/net80211/ieee80211_monitor.h b/freebsd/sys/net80211/ieee80211_monitor.h index 09f95dba..d7dd8e98 100644 --- a/freebsd/sys/net80211/ieee80211_monitor.h +++ b/freebsd/sys/net80211/ieee80211_monitor.h @@ -24,12 +24,12 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_MONITOR_HH_ -#define _NET80211_IEEE80211_MONITOR_HH_ +#ifndef _NET80211_IEEE80211_MONITOR_H_ +#define _NET80211_IEEE80211_MONITOR_H_ /* * Monitor implementation definitions. */ void ieee80211_monitor_attach(struct ieee80211com *); void ieee80211_monitor_detach(struct ieee80211com *); -#endif /* !_NET80211_IEEE80211_MONITOR_HH_ */ +#endif /* !_NET80211_IEEE80211_MONITOR_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_node.c b/freebsd/sys/net80211/ieee80211_node.c index 8b8335c1..95993d88 100644 --- a/freebsd/sys/net80211/ieee80211_node.c +++ b/freebsd/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,36 +26,36 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include -#include -#include +#include +#include +#include -#include +#include /* * IEEE80211_NODE_HASHSIZE must be a power of 2. diff --git a/freebsd/sys/net80211/ieee80211_node.h b/freebsd/sys/net80211/ieee80211_node.h index cf47a101..01bb2cf1 100644 --- a/freebsd/sys/net80211/ieee80211_node.h +++ b/freebsd/sys/net80211/ieee80211_node.h @@ -25,11 +25,11 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_NODE_HH_ -#define _NET80211_IEEE80211_NODE_HH_ +#ifndef _NET80211_IEEE80211_NODE_H_ +#define _NET80211_IEEE80211_NODE_H_ -#include /* for ieee80211_nodestats */ -#include /* for aggregation state */ +#include /* for ieee80211_nodestats */ +#include /* for aggregation state */ /* * Each ieee80211com instance has a single timer that fires every @@ -453,4 +453,4 @@ void ieee80211_node_join(struct ieee80211_node *,int); void ieee80211_node_leave(struct ieee80211_node *); int8_t ieee80211_getrssi(struct ieee80211vap *); void ieee80211_getsignal(struct ieee80211vap *, int8_t *, int8_t *); -#endif /* _NET80211_IEEE80211_NODE_HH_ */ +#endif /* _NET80211_IEEE80211_NODE_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_output.c b/freebsd/sys/net80211/ieee80211_output.c index b7abe9ec..24b49ab4 100644 --- a/freebsd/sys/net80211/ieee80211_output.c +++ b/freebsd/sys/net80211/ieee80211_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,50 +26,50 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include -#include +#include +#include #ifdef INET -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef INET6 -#include +#include #endif -#include +#include #define ETHER_HEADER_COPY(dst, src) \ memcpy(dst, src, sizeof(struct ether_header)) diff --git a/freebsd/sys/net80211/ieee80211_phy.c b/freebsd/sys/net80211/ieee80211_phy.c index 5c5a2f55..9d37a967 100644 --- a/freebsd/sys/net80211/ieee80211_phy.c +++ b/freebsd/sys/net80211/ieee80211_phy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,26 +25,26 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 PHY-related support. */ -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #ifdef notyet struct ieee80211_ds_plcp_hdr { diff --git a/freebsd/sys/net80211/ieee80211_phy.h b/freebsd/sys/net80211/ieee80211_phy.h index af76e666..56b404f7 100644 --- a/freebsd/sys/net80211/ieee80211_phy.h +++ b/freebsd/sys/net80211/ieee80211_phy.h @@ -25,8 +25,8 @@ * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_PHY_HH_ -#define _NET80211_IEEE80211_PHY_HH_ +#ifndef _NET80211_IEEE80211_PHY_H_ +#define _NET80211_IEEE80211_PHY_H_ #ifdef _KERNEL /* @@ -152,4 +152,4 @@ uint8_t ieee80211_plcp2rate(uint8_t, enum ieee80211_phytype); */ uint8_t ieee80211_rate2plcp(int, enum ieee80211_phytype); #endif /* _KERNEL */ -#endif /* !_NET80211_IEEE80211_PHY_HH_ */ +#endif /* !_NET80211_IEEE80211_PHY_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_power.c b/freebsd/sys/net80211/ieee80211_power.c index f56a641f..c15080c4 100644 --- a/freebsd/sys/net80211/ieee80211_power.c +++ b/freebsd/sys/net80211/ieee80211_power.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,27 +25,27 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 power save support. */ -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include static void ieee80211_update_ps(struct ieee80211vap *, int); static int ieee80211_set_tim(struct ieee80211_node *, int); diff --git a/freebsd/sys/net80211/ieee80211_power.h b/freebsd/sys/net80211/ieee80211_power.h index 6cb0eab8..352cdadb 100644 --- a/freebsd/sys/net80211/ieee80211_power.h +++ b/freebsd/sys/net80211/ieee80211_power.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_POWER_HH_ -#define _NET80211_IEEE80211_POWER_HH_ +#ifndef _NET80211_IEEE80211_POWER_H_ +#define _NET80211_IEEE80211_POWER_H_ struct ieee80211com; struct ieee80211vap; @@ -76,4 +76,4 @@ void ieee80211_node_pwrsave(struct ieee80211_node *, int enable); void ieee80211_sta_pwrsave(struct ieee80211vap *, int enable); void ieee80211_power_poll(struct ieee80211com *); -#endif /* _NET80211_IEEE80211_POWER_HH_ */ +#endif /* _NET80211_IEEE80211_POWER_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_proto.c b/freebsd/sys/net80211/ieee80211_proto.c index 70c5f299..d2874951 100644 --- a/freebsd/sys/net80211/ieee80211_proto.c +++ b/freebsd/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Atsushi Onoe @@ -26,37 +26,37 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 protocol support. */ -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include /* XXX for ether_sprintf */ +#include +#include +#include /* XXX for ether_sprintf */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include -#include +#include +#include /* XXX tunables */ #define AGGRESSIVE_MODE_SWITCH_HYSTERESIS 3 /* pkts / 100ms */ diff --git a/freebsd/sys/net80211/ieee80211_proto.h b/freebsd/sys/net80211/ieee80211_proto.h index f81a6433..c2808477 100644 --- a/freebsd/sys/net80211/ieee80211_proto.h +++ b/freebsd/sys/net80211/ieee80211_proto.h @@ -25,8 +25,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_PROTO_HH_ -#define _NET80211_IEEE80211_PROTO_HH_ +#ifndef _NET80211_IEEE80211_PROTO_H_ +#define _NET80211_IEEE80211_PROTO_H_ /* * 802.11 protocol implementation definitions. @@ -384,4 +384,4 @@ void ieee80211_notify_node_auth(struct ieee80211_node *); void ieee80211_notify_country(struct ieee80211vap *, const uint8_t [], const uint8_t cc[2]); void ieee80211_notify_radio(struct ieee80211com *, int); -#endif /* _NET80211_IEEE80211_PROTO_HH_ */ +#endif /* _NET80211_IEEE80211_PROTO_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_radiotap.c b/freebsd/sys/net80211/ieee80211_radiotap.c index f630ae99..b51974b3 100644 --- a/freebsd/sys/net80211/ieee80211_radiotap.c +++ b/freebsd/sys/net80211/ieee80211_radiotap.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 Sam Leffler, Errno Consulting @@ -25,29 +25,29 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 radiotap support. */ -#include - -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include static int radiotap_offset(struct ieee80211_radiotap_header *, int); diff --git a/freebsd/sys/net80211/ieee80211_radiotap.h b/freebsd/sys/net80211/ieee80211_radiotap.h index 89eac4be..b8a8b510 100644 --- a/freebsd/sys/net80211/ieee80211_radiotap.h +++ b/freebsd/sys/net80211/ieee80211_radiotap.h @@ -29,8 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ -#ifndef _NET80211_IEEE80211_RADIOTAP_HH_ -#define _NET80211_IEEE80211_RADIOTAP_HH_ +#ifndef _NET80211_IEEE80211_RADIOTAP_H_ +#define _NET80211_IEEE80211_RADIOTAP_H_ /* A generic radio capture format is desirable. It must be * rigidly defined (e.g., units for fields should be given), @@ -231,4 +231,4 @@ enum ieee80211_radiotap_type { #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ #define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */ -#endif /* !_NET80211_IEEE80211_RADIOTAP_HH_ */ +#endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_ratectl.c b/freebsd/sys/net80211/ieee80211_ratectl.c index 8eede3cb..b54188e0 100644 --- a/freebsd/sys/net80211/ieee80211_ratectl.c +++ b/freebsd/sys/net80211/ieee80211_ratectl.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2010 Rui Paulo @@ -25,19 +25,19 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include static const struct ieee80211_ratectl *ratectls[IEEE80211_RATECTL_MAX]; diff --git a/freebsd/sys/net80211/ieee80211_ratectl_none.c b/freebsd/sys/net80211/ieee80211_ratectl_none.c index 97f0749f..62b7c99c 100644 --- a/freebsd/sys/net80211/ieee80211_ratectl_none.c +++ b/freebsd/sys/net80211/ieee80211_ratectl_none.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2010 Bernhard Schmidt @@ -25,27 +25,27 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef INET -#include -#include +#include +#include #endif -#include -#include +#include +#include static void none_init(struct ieee80211vap *vap) diff --git a/freebsd/sys/net80211/ieee80211_regdomain.c b/freebsd/sys/net80211/ieee80211_regdomain.c index e83132c8..890ddf79 100644 --- a/freebsd/sys/net80211/ieee80211_regdomain.c +++ b/freebsd/sys/net80211/ieee80211_regdomain.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2005-2008 Sam Leffler, Errno Consulting @@ -25,25 +25,25 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 regdomain support. */ -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include +#include +#include -#include -#include +#include +#include static void null_getradiocaps(struct ieee80211com *ic, int maxchan, diff --git a/freebsd/sys/net80211/ieee80211_regdomain.h b/freebsd/sys/net80211/ieee80211_regdomain.h index f71c1093..8942dd98 100644 --- a/freebsd/sys/net80211/ieee80211_regdomain.h +++ b/freebsd/sys/net80211/ieee80211_regdomain.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_REGDOMAIN_HH_ -#define _NET80211_IEEE80211_REGDOMAIN_HH_ +#ifndef _NET80211_IEEE80211_REGDOMAIN_H_ +#define _NET80211_IEEE80211_REGDOMAIN_H_ /* * 802.11 regulatory domain definitions. @@ -279,4 +279,4 @@ struct ieee80211_regdomain_req; int ieee80211_setregdomain(struct ieee80211vap *, struct ieee80211_regdomain_req *); #endif /* defined(__KERNEL__) || defined(_KERNEL) */ -#endif /* _NET80211_IEEE80211_REGDOMAIN_HH_ */ +#endif /* _NET80211_IEEE80211_REGDOMAIN_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_rssadapt.c b/freebsd/sys/net80211/ieee80211_rssadapt.c index b50d2e66..687ea41e 100644 --- a/freebsd/sys/net80211/ieee80211_rssadapt.c +++ b/freebsd/sys/net80211/ieee80211_rssadapt.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $NetBSD: ieee80211_rssadapt.c,v 1.9 2005/02/26 22:45:09 perry Exp $ */ @@ -32,20 +32,20 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include struct rssadapt_expavgctl { /* RSS threshold decay. */ diff --git a/freebsd/sys/net80211/ieee80211_rssadapt.h b/freebsd/sys/net80211/ieee80211_rssadapt.h index 26211ece..ee1d2d90 100644 --- a/freebsd/sys/net80211/ieee80211_rssadapt.h +++ b/freebsd/sys/net80211/ieee80211_rssadapt.h @@ -29,8 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ -#ifndef _NET80211_IEEE80211_RSSADAPT_HH_ -#define _NET80211_IEEE80211_RSSADAPT_HH_ +#ifndef _NET80211_IEEE80211_RSSADAPT_H_ +#define _NET80211_IEEE80211_RSSADAPT_H_ /* Data-rate adaptation loosely based on "Link Adaptation Strategy * for IEEE 802.11 WLAN via Received Signal Strength Measurement" @@ -68,4 +68,4 @@ struct ieee80211_rssadapt_node { #define IEEE80211_RSSADAPT_SUCCESS 1 #define IEEE80211_RSSADAPT_FAILURE 0 -#endif /* _NET80211_IEEE80211_RSSADAPT_HH_ */ +#endif /* _NET80211_IEEE80211_RSSADAPT_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_scan.c b/freebsd/sys/net80211/ieee80211_scan.c index bda486ec..4a23066d 100644 --- a/freebsd/sys/net80211/ieee80211_scan.c +++ b/freebsd/sys/net80211/ieee80211_scan.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting @@ -25,29 +25,29 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 scanning support. */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include struct scan_state { struct ieee80211_scan_state base; /* public state */ diff --git a/freebsd/sys/net80211/ieee80211_scan.h b/freebsd/sys/net80211/ieee80211_scan.h index 6273902d..4c5e869a 100644 --- a/freebsd/sys/net80211/ieee80211_scan.h +++ b/freebsd/sys/net80211/ieee80211_scan.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_SCAN_HH_ -#define _NET80211_IEEE80211_SCAN_HH_ +#ifndef _NET80211_IEEE80211_SCAN_H_ +#define _NET80211_IEEE80211_SCAN_H_ /* * 802.11 scanning support. @@ -298,4 +298,4 @@ void ieee80211_scanner_unregister(enum ieee80211_opmode, const struct ieee80211_scanner *); void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *); const struct ieee80211_scanner *ieee80211_scanner_get(enum ieee80211_opmode); -#endif /* _NET80211_IEEE80211_SCAN_HH_ */ +#endif /* _NET80211_IEEE80211_SCAN_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_scan_sta.c b/freebsd/sys/net80211/ieee80211_scan_sta.c index aa9d67ec..573f994f 100644 --- a/freebsd/sys/net80211/ieee80211_scan_sta.c +++ b/freebsd/sys/net80211/ieee80211_scan_sta.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting @@ -25,36 +25,36 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IEEE 802.11 station scanning support. */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include +#include /* * Parameters for managing cache entries: diff --git a/freebsd/sys/net80211/ieee80211_sta.c b/freebsd/sys/net80211/ieee80211_sta.c index 67704469..d07e83c4 100644 --- a/freebsd/sys/net80211/ieee80211_sta.c +++ b/freebsd/sys/net80211/ieee80211_sta.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,36 +33,36 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 Station mode support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include +#include #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) diff --git a/freebsd/sys/net80211/ieee80211_sta.h b/freebsd/sys/net80211/ieee80211_sta.h index 43316f5b..1508a7c7 100644 --- a/freebsd/sys/net80211/ieee80211_sta.h +++ b/freebsd/sys/net80211/ieee80211_sta.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_STA_HH_ -#define _NET80211_IEEE80211_STA_HH_ +#ifndef _NET80211_IEEE80211_STA_H_ +#define _NET80211_IEEE80211_STA_H_ /* * Station-mode implementation definitions. @@ -33,4 +33,4 @@ void ieee80211_sta_attach(struct ieee80211com *); void ieee80211_sta_detach(struct ieee80211com *); void ieee80211_sta_vattach(struct ieee80211vap *); -#endif /* !_NET80211_IEEE80211_STA_HH_ */ +#endif /* !_NET80211_IEEE80211_STA_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_superg.c b/freebsd/sys/net80211/ieee80211_superg.c index dd886e41..3fcfcd74 100644 --- a/freebsd/sys/net80211/ieee80211_superg.c +++ b/freebsd/sys/net80211/ieee80211_superg.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting @@ -25,29 +25,29 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include /* * Atheros fast-frame encapsulation format. diff --git a/freebsd/sys/net80211/ieee80211_superg.h b/freebsd/sys/net80211/ieee80211_superg.h index bda45dda..970a5fef 100644 --- a/freebsd/sys/net80211/ieee80211_superg.h +++ b/freebsd/sys/net80211/ieee80211_superg.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_SUPERG_HH_ -#define _NET80211_IEEE80211_SUPERG_HH_ +#ifndef _NET80211_IEEE80211_SUPERG_H_ +#define _NET80211_IEEE80211_SUPERG_H_ /* * Atheros' 802.11 SuperG protocol support. @@ -126,4 +126,4 @@ ieee80211_decap_fastframe(struct ieee80211vap *vap, struct ieee80211_node *ni, ieee80211_ff_decap(ni, m) : m; } #endif /* _KERNEL */ -#endif /* _NET80211_IEEE80211_SUPERG_HH_ */ +#endif /* _NET80211_IEEE80211_SUPERG_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_tdma.c b/freebsd/sys/net80211/ieee80211_tdma.c index c41ca491..1a6b3298 100644 --- a/freebsd/sys/net80211/ieee80211_tdma.c +++ b/freebsd/sys/net80211/ieee80211_tdma.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -34,33 +34,33 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 TDMA mode support. */ -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifndef TDMA_SLOTLEN_DEFAULT #define TDMA_SLOTLEN_DEFAULT 10*1000 /* 10ms */ diff --git a/freebsd/sys/net80211/ieee80211_tdma.h b/freebsd/sys/net80211/ieee80211_tdma.h index 989d6417..2fe591f7 100644 --- a/freebsd/sys/net80211/ieee80211_tdma.h +++ b/freebsd/sys/net80211/ieee80211_tdma.h @@ -25,8 +25,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_TDMA_HH_ -#define _NET80211_IEEE80211_TDMA_HH_ +#ifndef _NET80211_IEEE80211_TDMA_H_ +#define _NET80211_IEEE80211_TDMA_H_ /* * TDMA-mode implementation definitions. @@ -99,4 +99,4 @@ struct ieee80211_beacon_offsets; void ieee80211_tdma_update_beacon(struct ieee80211vap *vap, struct ieee80211_beacon_offsets *bo); #endif /* _KERNEL */ -#endif /* !_NET80211_IEEE80211_TDMA_HH_ */ +#endif /* !_NET80211_IEEE80211_TDMA_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_var.h b/freebsd/sys/net80211/ieee80211_var.h index 2ab54b78..58a46d3b 100644 --- a/freebsd/sys/net80211/ieee80211_var.h +++ b/freebsd/sys/net80211/ieee80211_var.h @@ -25,35 +25,35 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_VAR_HH_ -#define _NET80211_IEEE80211_VAR_HH_ +#ifndef _NET80211_IEEE80211_VAR_H_ +#define _NET80211_IEEE80211_VAR_H_ /* * Definitions for IEEE 802.11 drivers. */ /* NB: portability glue must go first */ #if defined(__NetBSD__) -#include +#include #elif defined(__FreeBSD__) -#include +#include #elif defined(__linux__) -#include +#include #else #error "No support for your operating system!" #endif -#include -#include -#include -#include -#include -#include /* for ieee80211_stats */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* for ieee80211_stats */ +#include +#include +#include +#include +#include +#include #define IEEE80211_TXPOWER_MAX 100 /* .5 dbM (XXX units?) */ #define IEEE80211_TXPOWER_MIN 0 /* kill radio */ @@ -913,4 +913,4 @@ void ieee80211_discard_mac(const struct ieee80211vap *, #define IEEE80211_DISCARD_MAC(_vap, _m, _mac, _type, _fmt, ...) #endif -#endif /* _NET80211_IEEE80211_VAR_HH_ */ +#endif /* _NET80211_IEEE80211_VAR_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_wds.c b/freebsd/sys/net80211/ieee80211_wds.c index b0f5378d..772f305c 100644 --- a/freebsd/sys/net80211/ieee80211_wds.c +++ b/freebsd/sys/net80211/ieee80211_wds.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #ifdef __FreeBSD__ __FBSDID("$FreeBSD$"); #endif @@ -33,34 +33,34 @@ __FBSDID("$FreeBSD$"); /* * IEEE 802.11 WDS mode support. */ -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif static void wds_vattach(struct ieee80211vap *); diff --git a/freebsd/sys/net80211/ieee80211_wds.h b/freebsd/sys/net80211/ieee80211_wds.h index 200cba27..c34fb6ee 100644 --- a/freebsd/sys/net80211/ieee80211_wds.h +++ b/freebsd/sys/net80211/ieee80211_wds.h @@ -24,8 +24,8 @@ * * $FreeBSD$ */ -#ifndef _NET80211_IEEE80211_WDS_HH_ -#define _NET80211_IEEE80211_WDS_HH_ +#ifndef _NET80211_IEEE80211_WDS_H_ +#define _NET80211_IEEE80211_WDS_H_ /* * WDS implementation definitions. @@ -36,4 +36,4 @@ void ieee80211_wds_detach(struct ieee80211com *); void ieee80211_dwds_mcast(struct ieee80211vap *, struct mbuf *); void ieee80211_dwds_discover(struct ieee80211_node *, struct mbuf *); int ieee80211_node_wdsq_age(struct ieee80211_node *); -#endif /* !_NET80211_IEEE80211_WDS_HH_ */ +#endif /* !_NET80211_IEEE80211_WDS_H_ */ diff --git a/freebsd/sys/net80211/ieee80211_xauth.c b/freebsd/sys/net80211/ieee80211_xauth.c index 55318069..7c937906 100644 --- a/freebsd/sys/net80211/ieee80211_xauth.c +++ b/freebsd/sys/net80211/ieee80211_xauth.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004 Video54 Technologies, Inc. @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -41,22 +41,22 @@ __FBSDID("$FreeBSD$"); * of the available callbacks--the user mode authenticator process works * entirely from messages about stations joining and leaving. */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include /* XXX number of references from net80211 layer; needed for module code */ static int nrefs = 0; diff --git a/freebsd/sys/netatalk/aarp.c b/freebsd/sys/netatalk/aarp.c index 63fabede..d8daf757 100644 --- a/freebsd/sys/netatalk/aarp.c +++ b/freebsd/sys/netatalk/aarp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004-2009 Robert N. M. Watson @@ -52,29 +52,29 @@ * $FreeBSD$ */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include #undef s_net -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include static void aarptfree(struct aarptab *aat); static void at_aarpinput(struct ifnet *ifp, struct mbuf *m); diff --git a/freebsd/sys/netatalk/aarp.h b/freebsd/sys/netatalk/aarp.h index 4d7e06ac..b55a9a7c 100644 --- a/freebsd/sys/netatalk/aarp.h +++ b/freebsd/sys/netatalk/aarp.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_AARP_HH_ -#define _NETATALK_AARP_HH_ +#ifndef _NETATALK_AARP_H_ +#define _NETATALK_AARP_H_ /* * This structure is used for both phase 1 and 2. Under phase 1 @@ -83,4 +83,4 @@ struct aarptab { struct aarptab *aarptnew(struct at_addr *); #endif -#endif /* _NETATALK_AARP_HH_ */ +#endif /* _NETATALK_AARP_H_ */ diff --git a/freebsd/sys/netatalk/at.h b/freebsd/sys/netatalk/at.h index 27e88acb..5a944c1a 100644 --- a/freebsd/sys/netatalk/at.h +++ b/freebsd/sys/netatalk/at.h @@ -1,2 +1,86 @@ -#include -#include +/*- + * Copyright (c) 1990,1991 Regents of The University of Michigan. + * 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 that copyright notice and this permission notice appear + * in supporting documentation, and that the name of The University + * of Michigan not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. This software is supplied as is without expressed or + * implied warranties of any kind. + * + * Research Systems Unix Group + * The University of Michigan + * c/o Mike Clark + * 535 W. William Street + * Ann Arbor, Michigan + * +1-313-763-0525 + * netatalk@itd.umich.edu + * + * $FreeBSD$ + */ + +#ifndef _NETATALK_AT_H_ +#define _NETATALK_AT_H_ + +/* + * Supported protocols + */ +#define ATPROTO_DDP 0 +#define ATPROTO_AARP 254 + +#define DDP_MAXSZ 587 + +/* + * If ATPORT_FIRST <= Port < ATPORT_RESERVED, the port was created by a + * privileged process. + * + * If ATPORT_RESERVED <= Port < ATPORT_LAST, the port was not necessarily + * created by a privileged process. + */ +#define ATPORT_FIRST 1 +#define ATPORT_RESERVED 128 +#define ATPORT_LAST 255 + +/* + * AppleTalk address. + */ +struct at_addr { + u_short s_net; + u_char s_node; +}; + +#define ATADDR_ANYNET (u_short)0x0000 +#define ATADDR_ANYNODE (u_char)0x00 +#define ATADDR_ANYPORT (u_char)0x00 +#define ATADDR_BCAST (u_char)0xff /* There is no BCAST for NET. */ + +struct netrange { + u_char nr_phase; + u_short nr_firstnet; + u_short nr_lastnet; +}; + +/* + * Socket address, AppleTalk style. We keep magic information in the zero + * bytes. There are three types, NONE, CONFIG which has the phase and a net + * range, and IFACE which has the network address of an interface. IFACE may + * be filled in by the client, and is filled in by the kernel. + */ +struct sockaddr_at { + u_char sat_len; + u_char sat_family; + u_char sat_port; + struct at_addr sat_addr; + union { + struct netrange r_netrange; + char r_zero[8]; /* Hide struct netrange here. */ + } sat_range; +}; + +#define sat_zero sat_range.r_zero + +#endif /* !_NETATALK_AT_H_ */ diff --git a/freebsd/sys/netatalk/at_control.c b/freebsd/sys/netatalk/at_control.c index c03d2ad8..1c5d0a56 100644 --- a/freebsd/sys/netatalk/at_control.c +++ b/freebsd/sys/netatalk/at_control.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -27,27 +27,27 @@ * netatalk@umich.edu */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #undef s_net -#include +#include -#include -#include -#include +#include +#include +#include struct rwlock at_ifaddr_rw; struct at_ifaddrhead at_ifaddrhead; diff --git a/freebsd/sys/netatalk/at_extern.h b/freebsd/sys/netatalk/at_extern.h index aebae73c..c00e526d 100644 --- a/freebsd/sys/netatalk/at_extern.h +++ b/freebsd/sys/netatalk/at_extern.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_AT_EXTERN_HH_ -#define _NETATALK_AT_EXTERN_HH_ +#ifndef _NETATALK_AT_EXTERN_H_ +#define _NETATALK_AT_EXTERN_H_ extern struct mtx aarptab_mtx; @@ -64,4 +64,4 @@ int ddp_route(struct mbuf *m, struct route *ro); struct ddpcb *ddp_search(struct sockaddr_at *, struct sockaddr_at *, struct at_ifaddr *); -#endif /* !_NETATALK_AT_EXTERN_HH_ */ +#endif /* !_NETATALK_AT_EXTERN_H_ */ diff --git a/freebsd/sys/netatalk/at_proto.c b/freebsd/sys/netatalk/at_proto.c index cc7902b0..53f04236 100644 --- a/freebsd/sys/netatalk/at_proto.c +++ b/freebsd/sys/netatalk/at_proto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990, 1991 Regents of The University of Michigan. @@ -25,18 +25,18 @@ * $FreeBSD$ */ -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include -#include +#include -#include -#include -#include +#include +#include +#include static struct domain atalkdomain; diff --git a/freebsd/sys/netatalk/at_rmx.c b/freebsd/sys/netatalk/at_rmx.c index 54272ad7..61777a70 100644 --- a/freebsd/sys/netatalk/at_rmx.c +++ b/freebsd/sys/netatalk/at_rmx.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1994, 1995 Massachusetts Institute of Technology @@ -34,11 +34,11 @@ /* This code generates debugging traces to the radix code. */ -#include -#include -#include +#include +#include +#include -#include +#include int at_inithead(void **head, int off); diff --git a/freebsd/sys/netatalk/at_var.h b/freebsd/sys/netatalk/at_var.h index ead90fb1..39b12c77 100644 --- a/freebsd/sys/netatalk/at_var.h +++ b/freebsd/sys/netatalk/at_var.h @@ -23,8 +23,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_AT_VAR_HH_ -#define _NETATALK_AT_VAR_HH_ +#ifndef _NETATALK_AT_VAR_H_ +#define _NETATALK_AT_VAR_H_ /* * For phase2, we need to keep not only our address on an interface, but also @@ -74,4 +74,4 @@ extern struct at_ifaddrhead at_ifaddrhead; #define AT_IFADDR_WUNLOCK() rw_wunlock(&at_ifaddr_rw) #endif -#endif /* _NETATALK_AT_VAR_HH_ */ +#endif /* _NETATALK_AT_VAR_H_ */ diff --git a/freebsd/sys/netatalk/ddp.h b/freebsd/sys/netatalk/ddp.h index f954b080..1867ae42 100644 --- a/freebsd/sys/netatalk/ddp.h +++ b/freebsd/sys/netatalk/ddp.h @@ -23,8 +23,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_DDP_HH_ -#define _NETATALK_DDP_HH_ +#ifndef _NETATALK_DDP_H_ +#define _NETATALK_DDP_H_ /*- * <-1byte(8bits) -> @@ -134,4 +134,4 @@ struct ddpshdr { #define dsh_sport dsh_u.du_bits.dub_sport #define dsh_bytes dsh_u.du_bytes -#endif /* _NETATALK_DDP_HH_ */ +#endif /* _NETATALK_DDP_H_ */ diff --git a/freebsd/sys/netatalk/ddp_input.c b/freebsd/sys/netatalk/ddp_input.c index 64eaac7d..267538ec 100644 --- a/freebsd/sys/netatalk/ddp_input.c +++ b/freebsd/sys/netatalk/ddp_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004-2009 Robert N. M. Watson @@ -51,26 +51,26 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include static volatile int ddp_forward = 1; static volatile int ddp_firewall = 0; diff --git a/freebsd/sys/netatalk/ddp_output.c b/freebsd/sys/netatalk/ddp_output.c index 0bb74123..9f171fd8 100644 --- a/freebsd/sys/netatalk/ddp_output.c +++ b/freebsd/sys/netatalk/ddp_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990, 1991 Regents of The University of Michigan. @@ -25,24 +25,24 @@ /* $FreeBSD$ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #undef s_net -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include int ddp_cksum = 1; diff --git a/freebsd/sys/netatalk/ddp_pcb.c b/freebsd/sys/netatalk/ddp_pcb.c index 4faeb092..3998cbfa 100644 --- a/freebsd/sys/netatalk/ddp_pcb.c +++ b/freebsd/sys/netatalk/ddp_pcb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004-2009 Robert N. M. Watson @@ -51,23 +51,23 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include struct mtx ddp_list_mtx; static struct ddpcb *ddp_ports[ATPORT_LAST]; diff --git a/freebsd/sys/netatalk/ddp_pcb.h b/freebsd/sys/netatalk/ddp_pcb.h index 4449c3ae..d71836f6 100644 --- a/freebsd/sys/netatalk/ddp_pcb.h +++ b/freebsd/sys/netatalk/ddp_pcb.h @@ -50,8 +50,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_DDP_PCB_HH_ -#define _NETATALK_DDP_PCB_HH_ +#ifndef _NETATALK_DDP_PCB_H_ +#define _NETATALK_DDP_PCB_H_ int at_pcballoc(struct socket *so); int at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, @@ -81,4 +81,4 @@ void at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr); #define DDP_LIST_SUNLOCK() mtx_unlock(&ddp_list_mtx) #define DDP_LIST_SLOCK_ASSERT() mtx_assert(&ddp_list_mtx, MA_OWNED) -#endif /* !_NETATALK_DDP_PCB_HH_ */ +#endif /* !_NETATALK_DDP_PCB_H_ */ diff --git a/freebsd/sys/netatalk/ddp_usrreq.c b/freebsd/sys/netatalk/ddp_usrreq.c index 1d1990c4..e8557552 100644 --- a/freebsd/sys/netatalk/ddp_usrreq.c +++ b/freebsd/sys/netatalk/ddp_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004-2009 Robert N. M. Watson @@ -52,22 +52,22 @@ * $FreeBSD$ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include static u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */ static u_long ddp_recvspace = 10 * (587 + sizeof(struct sockaddr_at)); diff --git a/freebsd/sys/netatalk/ddp_var.h b/freebsd/sys/netatalk/ddp_var.h index e0148a24..71bbb5be 100644 --- a/freebsd/sys/netatalk/ddp_var.h +++ b/freebsd/sys/netatalk/ddp_var.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _NETATALK_DDP_VAR_HH_ -#define _NETATALK_DDP_VAR_HH_ +#ifndef _NETATALK_DDP_VAR_H_ +#define _NETATALK_DDP_VAR_H_ struct ddpcb { struct sockaddr_at ddp_fsat, ddp_lsat; @@ -60,4 +60,4 @@ extern struct pr_usrreqs ddp_usrreqs; extern struct mtx ddp_list_mtx; #endif -#endif /* _NETATALK_DDP_VAR_HH_ */ +#endif /* _NETATALK_DDP_VAR_H_ */ diff --git a/freebsd/sys/netatalk/endian.h b/freebsd/sys/netatalk/endian.h index b15332c1..4d7ba619 100644 --- a/freebsd/sys/netatalk/endian.h +++ b/freebsd/sys/netatalk/endian.h @@ -23,9 +23,9 @@ * $FreeBSD$ */ -#ifndef _ATALK_ENDIAN_HH_ -#define _ATALK_ENDIAN_HH_ +#ifndef _ATALK_ENDIAN_H_ +#define _ATALK_ENDIAN_H_ -#include +#include -#endif /* !_ATALK_ENDIAN_HH_ */ +#endif /* !_ATALK_ENDIAN_H_ */ diff --git a/freebsd/sys/netatalk/phase2.h b/freebsd/sys/netatalk/phase2.h index aaa3dd38..e6a4bec1 100644 --- a/freebsd/sys/netatalk/phase2.h +++ b/freebsd/sys/netatalk/phase2.h @@ -25,7 +25,7 @@ * $FreeBSD$ */ -#include +#include #define llc_org_code llc_un.type_snap.org_code #define llc_ether_type llc_un.type_snap.ether_type diff --git a/freebsd/sys/netinet/accf_data.c b/freebsd/sys/netinet/accf_data.c index 15696daf..7b81cda6 100644 --- a/freebsd/sys/netinet/accf_data.c +++ b/freebsd/sys/netinet/accf_data.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000 Alfred Perlstein @@ -26,17 +26,17 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #define ACCEPT_FILTER_MOD -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* accept filter that holds a socket until data arrives */ diff --git a/freebsd/sys/netinet/accf_dns.c b/freebsd/sys/netinet/accf_dns.c index f91cbb08..abba9d8b 100644 --- a/freebsd/sys/netinet/accf_dns.c +++ b/freebsd/sys/netinet/accf_dns.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (C) 2007 David Malone @@ -30,13 +30,13 @@ #define ACCEPT_FILTER_MOD -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* check for full DNS request */ static int sohasdns(struct socket *so, void *arg, int waitflag); diff --git a/freebsd/sys/netinet/accf_http.c b/freebsd/sys/netinet/accf_http.c index ce21b1d1..4397b439 100644 --- a/freebsd/sys/netinet/accf_http.c +++ b/freebsd/sys/netinet/accf_http.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2000 Paycounter, Inc. @@ -27,18 +27,18 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #define ACCEPT_FILTER_MOD -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* check for GET/HEAD */ static int sohashttpget(struct socket *so, void *arg, int waitflag); diff --git a/freebsd/sys/netinet/icmp6.h b/freebsd/sys/netinet/icmp6.h index bf61ac5b..5faae7c1 100644 --- a/freebsd/sys/netinet/icmp6.h +++ b/freebsd/sys/netinet/icmp6.h @@ -1,2 +1,741 @@ -#include -#include +/* $FreeBSD$ */ +/* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */ + +/*- + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. + */ + +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_ICMP6_H_ +#define _NETINET_ICMP6_H_ + +#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) + - sizeof(struct icmp6_hdr) */ + +struct icmp6_hdr { + u_int8_t icmp6_type; /* type field */ + u_int8_t icmp6_code; /* code field */ + u_int16_t icmp6_cksum; /* checksum field */ + union { + u_int32_t icmp6_un_data32[1]; /* type-specific field */ + u_int16_t icmp6_un_data16[2]; /* type-specific field */ + u_int8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +} __packed; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ +#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ +#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ +#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ + +#define ICMP6_ECHO_REQUEST 128 /* echo service */ +#define ICMP6_ECHO_REPLY 129 /* echo reply */ +#define MLD_LISTENER_QUERY 130 /* multicast listener query */ +#define MLD_LISTENER_REPORT 131 /* multicast listener report */ +#define MLD_LISTENER_DONE 132 /* multicast listener done */ +#define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */ + +/* RFC2292 decls */ +#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ +#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ +#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ + +#ifndef _KERNEL +/* the followings are for backward compatibility to old KAME apps. */ +#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY +#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT +#define MLD6_LISTENER_DONE MLD_LISTENER_DONE +#endif + +#define ND_ROUTER_SOLICIT 133 /* router solicitation */ +#define ND_ROUTER_ADVERT 134 /* router advertisement */ +#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ +#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */ +#define ND_REDIRECT 137 /* redirect */ + +#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ + +#define ICMP6_WRUREQUEST 139 /* who are you request */ +#define ICMP6_WRUREPLY 140 /* who are you reply */ +#define ICMP6_FQDN_QUERY 139 /* FQDN query */ +#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ +#define ICMP6_NI_QUERY 139 /* node information request */ +#define ICMP6_NI_REPLY 140 /* node information reply */ +#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */ + +/* The definitions below are experimental. TBA */ +#define MLD_MTRACE_RESP 200 /* mtrace resp (to sender) */ +#define MLD_MTRACE 201 /* mtrace messages */ + +#ifndef _KERNEL +#define MLD6_MTRACE_RESP MLD_MTRACE_RESP +#define MLD6_MTRACE MLD_MTRACE +#endif + +#define ICMP6_MAXTYPE 201 + +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ + +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ + +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ +#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ +#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ + +#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ +#define ICMP6_NI_REFUSED 1 /* node information request is refused */ +#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ + +#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ +#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ +#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ + +/* Used in kernel only */ +#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ +#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ + +/* + * Multicast Listener Discovery + */ +struct mld_hdr { + struct icmp6_hdr mld_icmp6_hdr; + struct in6_addr mld_addr; /* multicast address */ +} __packed; + +/* definitions to provide backward compatibility to old KAME applications */ +#ifndef _KERNEL +#define mld6_hdr mld_hdr +#define mld6_type mld_type +#define mld6_code mld_code +#define mld6_cksum mld_cksum +#define mld6_maxdelay mld_maxdelay +#define mld6_reserved mld_reserved +#define mld6_addr mld_addr +#endif + +/* shortcut macro definitions */ +#define mld_type mld_icmp6_hdr.icmp6_type +#define mld_code mld_icmp6_hdr.icmp6_code +#define mld_cksum mld_icmp6_hdr.icmp6_cksum +#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] +#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] +#define mld_v2_reserved mld_icmp6_hdr.icmp6_data16[0] +#define mld_v2_numrecs mld_icmp6_hdr.icmp6_data16[1] + +/* + * Neighbor Discovery + */ + +struct nd_router_solicit { /* router solicitation */ + struct icmp6_hdr nd_rs_hdr; + /* could be followed by options */ +} __packed; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +struct nd_router_advert { /* router advertisement */ + struct icmp6_hdr nd_ra_hdr; + u_int32_t nd_ra_reachable; /* reachable time */ + u_int32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +} __packed; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] +#define ND_RA_FLAG_MANAGED 0x80 +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_HA 0x20 + +/* + * Router preference values based on draft-draves-ipngwg-router-selection-01. + * These are non-standard definitions. + */ +#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ + +#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ +#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ +#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ +#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +struct nd_neighbor_solicit { /* neighbor solicitation */ + struct icmp6_hdr nd_ns_hdr; + struct in6_addr nd_ns_target; /*target address */ + /* could be followed by options */ +} __packed; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +struct nd_neighbor_advert { /* neighbor advertisement */ + struct icmp6_hdr nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +} __packed; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] +#if BYTE_ORDER == BIG_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80 +#define ND_NA_FLAG_SOLICITED 0x40 +#define ND_NA_FLAG_OVERRIDE 0x20 +#endif +#endif + +struct nd_redirect { /* redirect */ + struct icmp6_hdr nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +} __packed; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +struct nd_opt_hdr { /* Neighbor discovery option header */ + u_int8_t nd_opt_type; + u_int8_t nd_opt_len; + /* followed by option specific data*/ +} __packed; + +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 + +#define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ + +struct nd_opt_prefix_info { /* prefix information */ + u_int8_t nd_opt_pi_type; + u_int8_t nd_opt_pi_len; + u_int8_t nd_opt_pi_prefix_len; + u_int8_t nd_opt_pi_flags_reserved; + u_int32_t nd_opt_pi_valid_time; + u_int32_t nd_opt_pi_preferred_time; + u_int32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; +} __packed; + +#define ND_OPT_PI_FLAG_ONLINK 0x80 +#define ND_OPT_PI_FLAG_AUTO 0x40 + +struct nd_opt_rd_hdr { /* redirected header */ + u_int8_t nd_opt_rh_type; + u_int8_t nd_opt_rh_len; + u_int16_t nd_opt_rh_reserved1; + u_int32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +} __packed; + +struct nd_opt_mtu { /* MTU option */ + u_int8_t nd_opt_mtu_type; + u_int8_t nd_opt_mtu_len; + u_int16_t nd_opt_mtu_reserved; + u_int32_t nd_opt_mtu_mtu; +} __packed; + +struct nd_opt_route_info { /* route info */ + u_int8_t nd_opt_rti_type; + u_int8_t nd_opt_rti_len; + u_int8_t nd_opt_rti_prefixlen; + u_int8_t nd_opt_rti_flags; + u_int32_t nd_opt_rti_lifetime; + /* prefix follows */ +} __packed; + +/* + * icmp6 namelookup + */ + +struct icmp6_namelookup { + struct icmp6_hdr icmp6_nl_hdr; + u_int8_t icmp6_nl_nonce[8]; + int32_t icmp6_nl_ttl; +#if 0 + u_int8_t icmp6_nl_len; + u_int8_t icmp6_nl_name[3]; +#endif + /* could be followed by options */ +} __packed; + +/* + * icmp6 node information + */ +struct icmp6_nodeinfo { + struct icmp6_hdr icmp6_ni_hdr; + u_int8_t icmp6_ni_nonce[8]; + /* could be followed by reply data */ +} __packed; + +#define ni_type icmp6_ni_hdr.icmp6_type +#define ni_code icmp6_ni_hdr.icmp6_code +#define ni_cksum icmp6_ni_hdr.icmp6_cksum +#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] +#define ni_flags icmp6_ni_hdr.icmp6_data16[1] + +#define NI_QTYPE_NOOP 0 /* NOOP */ +#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ +#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ +#define NI_QTYPE_DNSNAME 2 /* DNS Name */ +#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ +#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ + +#if BYTE_ORDER == BIG_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x1 +#define NI_FQDN_FLAG_VALIDTTL 0x1 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 +#define NI_FQDN_FLAG_VALIDTTL 0x0100 +#endif + +#ifdef NAME_LOOKUPS_04 +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 +#define NI_NODEADDR_FLAG_SITELOCAL 0x2 +#define NI_NODEADDR_FLAG_GLOBAL 0x4 +#define NI_NODEADDR_FLAG_ALL 0x8 +#define NI_NODEADDR_FLAG_TRUNCATE 0x10 +#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 +#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 +#define NI_NODEADDR_FLAG_GLOBAL 0x0400 +#define NI_NODEADDR_FLAG_ALL 0x0800 +#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 +#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ +#endif +#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */ +#if BYTE_ORDER == BIG_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x1 +#define NI_NODEADDR_FLAG_ALL 0x2 +#define NI_NODEADDR_FLAG_COMPAT 0x4 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x8 +#define NI_NODEADDR_FLAG_SITELOCAL 0x10 +#define NI_NODEADDR_FLAG_GLOBAL 0x20 +#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */ +#elif BYTE_ORDER == LITTLE_ENDIAN +#define NI_NODEADDR_FLAG_TRUNCATE 0x0100 +#define NI_NODEADDR_FLAG_ALL 0x0200 +#define NI_NODEADDR_FLAG_COMPAT 0x0400 +#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800 +#define NI_NODEADDR_FLAG_SITELOCAL 0x1000 +#define NI_NODEADDR_FLAG_GLOBAL 0x2000 +#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */ +#endif +#endif + +struct ni_reply_fqdn { + u_int32_t ni_fqdn_ttl; /* TTL */ + u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ + u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ +} __packed; + +/* + * Router Renumbering. as router-renum-08.txt + */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + u_int8_t rr_segnum; + u_int8_t rr_flags; + u_int16_t rr_maxdelay; + u_int32_t rr_reserved; +} __packed; + +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +struct rr_pco_match { /* match prefix part */ + u_int8_t rpm_code; + u_int8_t rpm_len; + u_int8_t rpm_ordinal; + u_int8_t rpm_matchlen; + u_int8_t rpm_minlen; + u_int8_t rpm_maxlen; + u_int16_t rpm_reserved; + struct in6_addr rpm_prefix; +} __packed; + +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 +#define RPM_PCO_MAX 4 + +struct rr_pco_use { /* use prefix part */ + u_int8_t rpu_uselen; + u_int8_t rpu_keeplen; + u_int8_t rpu_ramask; + u_int8_t rpu_raflags; + u_int32_t rpu_vltime; + u_int32_t rpu_pltime; + u_int32_t rpu_flags; + struct in6_addr rpu_prefix; +} __packed; +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 + +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 +#endif + +struct rr_result { /* router renumbering result message */ + u_int16_t rrr_flags; + u_int8_t rrr_ordinal; + u_int8_t rrr_matchedlen; + u_int32_t rrr_ifid; + struct in6_addr rrr_prefix; +} __packed; +#if BYTE_ORDER == BIG_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#elif BYTE_ORDER == LITTLE_ENDIAN +#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif + +/* + * icmp6 filter structures. + */ + +struct icmp6_filter { + u_int32_t icmp6_filt[8]; +}; + +#ifdef _KERNEL +#define ICMP6_FILTER_SETPASSALL(filterp) \ +do { \ + int i; u_char *p; \ + p = (u_char *)filterp; \ + for (i = 0; i < sizeof(struct icmp6_filter); i++) \ + p[i] = 0xff; \ +} while (/*CONSTCOND*/ 0) +#define ICMP6_FILTER_SETBLOCKALL(filterp) \ + bzero(filterp, sizeof(struct icmp6_filter)) +#else /* _KERNEL */ +#define ICMP6_FILTER_SETPASSALL(filterp) \ + memset(filterp, 0xff, sizeof(struct icmp6_filter)) +#define ICMP6_FILTER_SETBLOCKALL(filterp) \ + memset(filterp, 0x00, sizeof(struct icmp6_filter)) +#endif /* _KERNEL */ + +#define ICMP6_FILTER_SETPASS(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))) +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + +/* + * Variables related to this implementation + * of the internet control message protocol version 6. + */ +struct icmp6errstat { + u_quad_t icp6errs_dst_unreach_noroute; + u_quad_t icp6errs_dst_unreach_admin; + u_quad_t icp6errs_dst_unreach_beyondscope; + u_quad_t icp6errs_dst_unreach_addr; + u_quad_t icp6errs_dst_unreach_noport; + u_quad_t icp6errs_packet_too_big; + u_quad_t icp6errs_time_exceed_transit; + u_quad_t icp6errs_time_exceed_reassembly; + u_quad_t icp6errs_paramprob_header; + u_quad_t icp6errs_paramprob_nextheader; + u_quad_t icp6errs_paramprob_option; + u_quad_t icp6errs_redirect; /* we regard redirect as an error here */ + u_quad_t icp6errs_unknown; +}; + +struct icmp6stat { +/* statistics related to icmp6 packets generated */ + u_quad_t icp6s_error; /* # of calls to icmp6_error */ + u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */ + u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */ + u_quad_t icp6s_outhist[256]; +/* statistics related to input message processed */ + u_quad_t icp6s_badcode; /* icmp6_code out of range */ + u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */ + u_quad_t icp6s_checksum; /* bad checksum */ + u_quad_t icp6s_badlen; /* calculated bound mismatch */ + /* + * number of responses: this member is inherited from netinet code, but + * for netinet6 code, it is already available in icp6s_outhist[]. + */ + u_quad_t icp6s_reflect; + u_quad_t icp6s_inhist[256]; + u_quad_t icp6s_nd_toomanyopt; /* too many ND options */ + struct icmp6errstat icp6s_outerrhist; +#define icp6s_odst_unreach_noroute \ + icp6s_outerrhist.icp6errs_dst_unreach_noroute +#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin +#define icp6s_odst_unreach_beyondscope \ + icp6s_outerrhist.icp6errs_dst_unreach_beyondscope +#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr +#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport +#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big +#define icp6s_otime_exceed_transit \ + icp6s_outerrhist.icp6errs_time_exceed_transit +#define icp6s_otime_exceed_reassembly \ + icp6s_outerrhist.icp6errs_time_exceed_reassembly +#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header +#define icp6s_oparamprob_nextheader \ + icp6s_outerrhist.icp6errs_paramprob_nextheader +#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option +#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect +#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown + u_quad_t icp6s_pmtuchg; /* path MTU changes */ + u_quad_t icp6s_nd_badopt; /* bad ND options */ + u_quad_t icp6s_badns; /* bad neighbor solicitation */ + u_quad_t icp6s_badna; /* bad neighbor advertisement */ + u_quad_t icp6s_badrs; /* bad router advertisement */ + u_quad_t icp6s_badra; /* bad router advertisement */ + u_quad_t icp6s_badredirect; /* bad redirect message */ +}; + +#ifdef _KERNEL +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ +#define ICMP6STAT_ADD(name, val) V_icmp6stat.name += (val) +#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) + +/* + * Kernel module consumers must use this accessor macro. + */ +void kmod_icmp6stat_inc(int statnum); +#define KMOD_ICMP6STAT_INC(name) \ + kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(u_quad_t)) +#endif + +/* + * Names for ICMP sysctl objects + */ +#define ICMPV6CTL_STATS 1 +#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ +#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ +#if 0 /*obsoleted*/ +#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */ +#endif +#define ICMPV6CTL_ND6_PRUNE 6 +#define ICMPV6CTL_ND6_DELAY 8 +#define ICMPV6CTL_ND6_UMAXTRIES 9 +#define ICMPV6CTL_ND6_MMAXTRIES 10 +#define ICMPV6CTL_ND6_USELOOPBACK 11 +/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */ +#define ICMPV6CTL_NODEINFO 13 +#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ +#define ICMPV6CTL_ND6_MAXNUDHINT 15 +#define ICMPV6CTL_MTUDISC_HIWAT 16 +#define ICMPV6CTL_MTUDISC_LOWAT 17 +#define ICMPV6CTL_ND6_DEBUG 18 +#define ICMPV6CTL_ND6_DRLIST 19 +#define ICMPV6CTL_ND6_PRLIST 20 +#define ICMPV6CTL_MLD_MAXSRCFILTER 21 +#define ICMPV6CTL_MLD_SOMAXSRC 22 +#define ICMPV6CTL_MLD_VERSION 23 +#define ICMPV6CTL_ND6_MAXQLEN 24 +#define ICMPV6CTL_MAXID 25 + +#define RTF_PROBEMTU RTF_PROTO1 + +#ifdef _KERNEL +# ifdef __STDC__ +struct rtentry; +struct rttimer; +struct in6_multi; +# endif +void icmp6_paramerror(struct mbuf *, int); +void icmp6_error(struct mbuf *, int, int, int); +void icmp6_error2(struct mbuf *, int, int, int, struct ifnet *); +int icmp6_input(struct mbuf **, int *, int); +void icmp6_fasttimo(void); +void icmp6_slowtimo(void); +void icmp6_reflect(struct mbuf *, size_t); +void icmp6_prepare(struct mbuf *); +void icmp6_redirect_input(struct mbuf *, int); +void icmp6_redirect_output(struct mbuf *, struct rtentry *); + +struct ip6ctlparam; +void icmp6_mtudisc_update(struct ip6ctlparam *, int); + +/* XXX: is this the right place for these macros? */ +#define icmp6_ifstat_inc(ifp, tag) \ +do { \ + if (ifp) \ + ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \ +} while (/*CONSTCOND*/ 0) + +#define icmp6_ifoutstat_inc(ifp, type, code) \ +do { \ + icmp6_ifstat_inc(ifp, ifs6_out_msg); \ + if (type < ICMP6_INFOMSG_MASK) \ + icmp6_ifstat_inc(ifp, ifs6_out_error); \ + switch (type) { \ + case ICMP6_DST_UNREACH: \ + icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \ + if (code == ICMP6_DST_UNREACH_ADMIN) \ + icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \ + break; \ + case ICMP6_PACKET_TOO_BIG: \ + icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \ + break; \ + case ICMP6_TIME_EXCEEDED: \ + icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \ + break; \ + case ICMP6_PARAM_PROB: \ + icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \ + break; \ + case ICMP6_ECHO_REQUEST: \ + icmp6_ifstat_inc(ifp, ifs6_out_echo); \ + break; \ + case ICMP6_ECHO_REPLY: \ + icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \ + break; \ + case MLD_LISTENER_QUERY: \ + icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \ + break; \ + case MLD_LISTENER_REPORT: \ + icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \ + break; \ + case MLD_LISTENER_DONE: \ + icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \ + break; \ + case ND_ROUTER_SOLICIT: \ + icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \ + break; \ + case ND_ROUTER_ADVERT: \ + icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \ + break; \ + case ND_NEIGHBOR_SOLICIT: \ + icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \ + break; \ + case ND_NEIGHBOR_ADVERT: \ + icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \ + break; \ + case ND_REDIRECT: \ + icmp6_ifstat_inc(ifp, ifs6_out_redirect); \ + break; \ + } \ +} while (/*CONSTCOND*/ 0) + +VNET_DECLARE(int, icmp6_rediraccept); /* accept/process redirects */ +VNET_DECLARE(int, icmp6_redirtimeout); /* cache time for redirect routes */ + +#define V_icmp6_rediraccept VNET(icmp6_rediraccept) +#define V_icmp6_redirtimeout VNET(icmp6_redirtimeout) + +#define ICMP6_NODEINFO_FQDNOK 0x1 +#define ICMP6_NODEINFO_NODEADDROK 0x2 +#define ICMP6_NODEINFO_TMPADDROK 0x4 +#define ICMP6_NODEINFO_GLOBALOK 0x8 +#endif /* _KERNEL */ + +#endif /* not _NETINET_ICMP6_H_ */ diff --git a/freebsd/sys/netinet/icmp_var.h b/freebsd/sys/netinet/icmp_var.h index d55fc4d3..30da6a26 100644 --- a/freebsd/sys/netinet/icmp_var.h +++ b/freebsd/sys/netinet/icmp_var.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_ICMP_VAR_HH_ -#define _NETINET_ICMP_VAR_HH_ +#ifndef _NETINET_ICMP_VAR_H_ +#define _NETINET_ICMP_VAR_H_ /* diff --git a/freebsd/sys/netinet/if_atm.c b/freebsd/sys/netinet/if_atm.c index ea6c567d..1c51718d 100644 --- a/freebsd/sys/netinet/if_atm.c +++ b/freebsd/sys/netinet/if_atm.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: if_atm.c,v 1.6 1996/10/13 02:03:01 christos Exp $ */ @@ -33,36 +33,36 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * IP <=> ATM address resolution. */ -#include -#include -#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef NATM -#include +#include #endif #define SDL(s) ((struct sockaddr_dl *)s) diff --git a/freebsd/sys/netinet/if_ether.c b/freebsd/sys/netinet/if_ether.c index 2e40c0d2..e7a20c2c 100644 --- a/freebsd/sys/netinet/if_ether.c +++ b/freebsd/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -37,43 +37,43 @@ * add "inuse/lock" bit (or ref. count) along with valid bit */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #if defined(INET) || defined(INET6) -#include +#include #endif -#include -#include +#include +#include -#include +#include #define SIN(s) ((struct sockaddr_in *)s) #define SDL(s) ((struct sockaddr_dl *)s) diff --git a/freebsd/sys/netinet/if_ether.h b/freebsd/sys/netinet/if_ether.h index e3c8d009..ce63d8db 100644 --- a/freebsd/sys/netinet/if_ether.h +++ b/freebsd/sys/netinet/if_ether.h @@ -1,2 +1,122 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + * $FreeBSD$ + */ + +#ifndef _NETINET_IF_ETHER_H_ +#define _NETINET_IF_ETHER_H_ + +#include +#include + +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((u_char *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((u_char *)ipaddr)[2]; \ + (enaddr)[5] = ((u_char *)ipaddr)[3]; \ +} +/* + * Macro to map an IP6 multicast address to an Ethernet multicast address. + * The high-order 16 bits of the Ethernet address are statically assigned, + * and the low-order 32 bits are taken from the low end of the IP6 address. + */ +#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ +/* struct in6_addr *ip6addr; */ \ +/* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x33; \ + (enaddr)[1] = 0x33; \ + (enaddr)[2] = ((u_char *)ip6addr)[12]; \ + (enaddr)[3] = ((u_char *)ip6addr)[13]; \ + (enaddr)[4] = ((u_char *)ip6addr)[14]; \ + (enaddr)[5] = ((u_char *)ip6addr)[15]; \ +} + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ + u_char arp_spa[4]; /* sender protocol address */ + u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ + u_char arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +struct sockaddr_inarp { + u_char sin_len; + u_char sin_family; + u_short sin_port; + struct in_addr sin_addr; + struct in_addr sin_srcaddr; + u_short sin_tos; + u_short sin_other; +#define SIN_PROXY 1 +}; +/* + * IP and ethernet specific routing flags + */ +#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */ +#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */ + +#ifdef _KERNEL +extern u_char ether_ipmulticast_min[ETHER_ADDR_LEN]; +extern u_char ether_ipmulticast_max[ETHER_ADDR_LEN]; + +struct llentry; +struct ifaddr; + +int arpresolve(struct ifnet *ifp, struct rtentry *rt, + struct mbuf *m, struct sockaddr *dst, u_char *desten, + struct llentry **lle); +void arp_ifinit(struct ifnet *, struct ifaddr *); +void arp_ifinit2(struct ifnet *, struct ifaddr *, u_char *); +#endif + +#endif diff --git a/freebsd/sys/netinet/igmp.c b/freebsd/sys/netinet/igmp.c index 5f8893d7..c41b8f71 100644 --- a/freebsd/sys/netinet/igmp.c +++ b/freebsd/sys/netinet/igmp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Bruce Simpson. @@ -49,37 +49,37 @@ * MULTICAST Revision: 3.5.1.4 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include #ifndef KTR_IGMPV3 #define KTR_IGMPV3 KTR_INET diff --git a/freebsd/sys/netinet/igmp.h b/freebsd/sys/netinet/igmp.h index f328d21f..8f574290 100644 --- a/freebsd/sys/netinet/igmp.h +++ b/freebsd/sys/netinet/igmp.h @@ -1,2 +1,148 @@ -#include -#include +/*- + * Copyright (c) 1988 Stephen Deering. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * 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. + * 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. + * + * @(#)igmp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NETINET_IGMP_H_ +#define _NETINET_IGMP_H_ + +/* + * Internet Group Management Protocol (IGMP) definitions. + * + * Written by Steve Deering, Stanford, May 1988. + * + * MULTICAST Revision: 3.5.1.2 + */ + +/* Minimum length of any IGMP protocol message. */ +#define IGMP_MINLEN 8 + +/* + * IGMPv1/v2 query and host report format. + */ +struct igmp { + u_char igmp_type; /* version & type of IGMP message */ + u_char igmp_code; /* subtype for routing msgs */ + u_short igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ +}; /* (zero for queries) */ + +/* + * IGMP v3 query format. + */ +struct igmpv3 { + u_char igmp_type; /* version & type of IGMP message */ + u_char igmp_code; /* subtype for routing msgs */ + u_short igmp_cksum; /* IP-style checksum */ + struct in_addr igmp_group; /* group address being reported */ + /* (zero for queries) */ + u_char igmp_misc; /* reserved/suppress/robustness */ + u_char igmp_qqi; /* querier's query interval */ + u_short igmp_numsrc; /* number of sources */ + /*struct in_addr igmp_sources[1];*/ /* source addresses */ +}; +#define IGMP_V3_QUERY_MINLEN 12 +#define IGMP_EXP(x) (((x) >> 4) & 0x07) +#define IGMP_MANT(x) ((x) & 0x0f) +#define IGMP_QRESV(x) (((x) >> 4) & 0x0f) +#define IGMP_SFLAG(x) (((x) >> 3) & 0x01) +#define IGMP_QRV(x) ((x) & 0x07) + +struct igmp_grouprec { + u_char ig_type; /* record type */ + u_char ig_datalen; /* length of auxiliary data */ + u_short ig_numsrc; /* number of sources */ + struct in_addr ig_group; /* group address being reported */ + /*struct in_addr ig_sources[1];*/ /* source addresses */ +}; +#define IGMP_GRPREC_HDRLEN 8 + +/* + * IGMPv3 host membership report header. + */ +struct igmp_report { + u_char ir_type; /* IGMP_v3_HOST_MEMBERSHIP_REPORT */ + u_char ir_rsv1; /* must be zero */ + u_short ir_cksum; /* checksum */ + u_short ir_rsv2; /* must be zero */ + u_short ir_numgrps; /* number of group records */ + /*struct igmp_grouprec ir_groups[1];*/ /* group records */ +}; +#define IGMP_V3_REPORT_MINLEN 8 +#define IGMP_V3_REPORT_MAXRECS 65535 + +/* + * Message types, including version number. + */ +#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIMv1 message (historic) */ +#define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ +#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* Leave-group message */ +#define IGMP_MTRACE_REPLY 0x1e /* mtrace(8) reply */ +#define IGMP_MTRACE_QUERY 0x1f /* mtrace(8) probe */ +#define IGMP_v3_HOST_MEMBERSHIP_REPORT 0x22 /* Ver. 3 membership report */ + +/* + * IGMPv3 report modes. + */ +#define IGMP_DO_NOTHING 0 /* don't send a record */ +#define IGMP_MODE_IS_INCLUDE 1 /* MODE_IN */ +#define IGMP_MODE_IS_EXCLUDE 2 /* MODE_EX */ +#define IGMP_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */ +#define IGMP_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */ +#define IGMP_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */ +#define IGMP_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */ + +/* + * IGMPv3 query types. + */ +#define IGMP_V3_GENERAL_QUERY 1 +#define IGMP_V3_GROUP_QUERY 2 +#define IGMP_V3_GROUP_SOURCE_QUERY 3 + +/* + * Maximum report interval for IGMP v1/v2 host membership reports [RFC 1112] + */ +#define IGMP_V1V2_MAX_RI 10 +#define IGMP_MAX_HOST_REPORT_DELAY IGMP_V1V2_MAX_RI + +/* + * IGMP_TIMER_SCALE denotes that the igmp code field specifies + * time in tenths of a second. + */ +#define IGMP_TIMER_SCALE 10 + +#endif /* _NETINET_IGMP_H_ */ diff --git a/freebsd/sys/netinet/igmp_var.h b/freebsd/sys/netinet/igmp_var.h index e1abe6ab..ca17158f 100644 --- a/freebsd/sys/netinet/igmp_var.h +++ b/freebsd/sys/netinet/igmp_var.h @@ -34,8 +34,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IGMP_VAR_HH_ -#define _NETINET_IGMP_VAR_HH_ +#ifndef _NETINET_IGMP_VAR_H_ +#define _NETINET_IGMP_VAR_H_ /* * Internet Group Management Protocol (IGMP), diff --git a/freebsd/sys/netinet/in.c b/freebsd/sys/netinet/in.c index 64e5d329..b9231e13 100644 --- a/freebsd/sys/netinet/in.c +++ b/freebsd/sys/netinet/in.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -32,38 +32,38 @@ * @(#)in.c 8.4 (Berkeley) 1/9/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include static int in_mask2len(struct in_addr *); static void in_len2mask(struct in_addr *, int); @@ -1309,8 +1309,8 @@ in_purgemaddrs(struct ifnet *ifp) IN_MULTI_UNLOCK(); } -#include -#include +#include +#include struct in_llentry { struct llentry base; diff --git a/freebsd/sys/netinet/in.h b/freebsd/sys/netinet/in.h index 73c7ca1a..f38aaee2 100644 --- a/freebsd/sys/netinet/in.h +++ b/freebsd/sys/netinet/in.h @@ -1,2 +1,794 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + * $FreeBSD$ + */ + +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ + +#include +#include +#include + +/* Protocols common to RFC 1700, POSIX, and X/Open. */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_UDP 17 /* user datagram protocol */ + +#define INADDR_ANY (u_int32_t)0x00000000 +#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ + +#ifndef _UINT8_T_DECLARED +typedef __uint8_t uint8_t; +#define _UINT8_T_DECLARED +#endif + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _IN_ADDR_T_DECLARED +typedef uint32_t in_addr_t; +#define _IN_ADDR_T_DECLARED +#endif + +#ifndef _IN_PORT_T_DECLARED +typedef uint16_t in_port_t; +#define _IN_PORT_T_DECLARED +#endif + +#ifndef _SA_FAMILY_T_DECLARED +typedef __sa_family_t sa_family_t; +#define _SA_FAMILY_T_DECLARED +#endif + +/* Internet address (a structure for historical reasons). */ +#ifndef _STRUCT_IN_ADDR_DECLARED +struct in_addr { + in_addr_t s_addr; +}; +#define _STRUCT_IN_ADDR_DECLARED +#endif + +#ifndef _SOCKLEN_T_DECLARED +typedef __socklen_t socklen_t; +#define _SOCKLEN_T_DECLARED +#endif + +/* Avoid collision with original definition in sys/socket.h. */ +#ifndef _STRUCT_SOCKADDR_STORAGE_DECLARED +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128U +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { + unsigned char ss_len; /* address length */ + sa_family_t ss_family; /* address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; /* force desired struct alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; +#define _STRUCT_SOCKADDR_STORAGE_DECLARED +#endif + +/* Socket address, internet style. */ +struct sockaddr_in { + uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +#if !defined(_KERNEL) && __BSD_VISIBLE + +#ifndef _BYTEORDER_PROTOTYPED +#define _BYTEORDER_PROTOTYPED +__BEGIN_DECLS +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); +__END_DECLS +#endif + +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif + +#endif /* !_KERNEL && __BSD_VISIBLE */ + +#if __POSIX_VISIBLE >= 200112 +#define IPPROTO_RAW 255 /* raw IP packet */ +#define INET_ADDRSTRLEN 16 +#endif + +#if __BSD_VISIBLE +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +/* + * Protocols (RFC 1700) + */ +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_IPV4 4 /* IPv4 encapsulation */ +#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ +#define IPPROTO_ST 7 /* Stream protocol II */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PIGP 9 /* private interior gateway */ +#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ +#define IPPROTO_NVPII 11 /* network voice protocol*/ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_ARGUS 13 /* Argus */ +#define IPPROTO_EMCON 14 /* EMCON */ +#define IPPROTO_XNET 15 /* Cross Net Debugger */ +#define IPPROTO_CHAOS 16 /* Chaos*/ +#define IPPROTO_MUX 18 /* Multiplexing */ +#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ +#define IPPROTO_HMP 20 /* Host Monitoring */ +#define IPPROTO_PRM 21 /* Packet Radio Measurement */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_TRUNK1 23 /* Trunk-1 */ +#define IPPROTO_TRUNK2 24 /* Trunk-2 */ +#define IPPROTO_LEAF1 25 /* Leaf-1 */ +#define IPPROTO_LEAF2 26 /* Leaf-2 */ +#define IPPROTO_RDP 27 /* Reliable Data */ +#define IPPROTO_IRTP 28 /* Reliable Transaction */ +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ +#define IPPROTO_BLT 30 /* Bulk Data Transfer */ +#define IPPROTO_NSP 31 /* Network Services */ +#define IPPROTO_INP 32 /* Merit Internodal */ +#define IPPROTO_SEP 33 /* Sequential Exchange */ +#define IPPROTO_3PC 34 /* Third Party Connect */ +#define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ +#define IPPROTO_XTP 36 /* XTP */ +#define IPPROTO_DDP 37 /* Datagram Delivery */ +#define IPPROTO_CMTP 38 /* Control Message Transport */ +#define IPPROTO_TPXX 39 /* TP++ Transport */ +#define IPPROTO_IL 40 /* IL transport protocol */ +#define IPPROTO_IPV6 41 /* IP6 header */ +#define IPPROTO_SDRP 42 /* Source Demand Routing */ +#define IPPROTO_ROUTING 43 /* IP6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ +#define IPPROTO_IDRP 45 /* InterDomain Routing*/ +#define IPPROTO_RSVP 46 /* resource reservation */ +#define IPPROTO_GRE 47 /* General Routing Encap. */ +#define IPPROTO_MHRP 48 /* Mobile Host Routing */ +#define IPPROTO_BHA 49 /* BHA */ +#define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ +#define IPPROTO_AH 51 /* IP6 Auth Header */ +#define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ +#define IPPROTO_SWIPE 53 /* IP with encryption */ +#define IPPROTO_NHRP 54 /* Next Hop Resolution */ +#define IPPROTO_MOBILE 55 /* IP Mobility */ +#define IPPROTO_TLSP 56 /* Transport Layer Security */ +#define IPPROTO_SKIP 57 /* SKIP */ +#define IPPROTO_ICMPV6 58 /* ICMP6 */ +#define IPPROTO_NONE 59 /* IP6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */ +#define IPPROTO_AHIP 61 /* any host internal protocol */ +#define IPPROTO_CFTP 62 /* CFTP */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ +#define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ +#define IPPROTO_RVD 66 /* Remote Virtual Disk */ +#define IPPROTO_IPPC 67 /* Pluribus Packet Core */ +#define IPPROTO_ADFS 68 /* Any distributed FS */ +#define IPPROTO_SATMON 69 /* Satnet Monitoring */ +#define IPPROTO_VISA 70 /* VISA Protocol */ +#define IPPROTO_IPCV 71 /* Packet Core Utility */ +#define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ +#define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ +#define IPPROTO_WSN 74 /* Wang Span Network */ +#define IPPROTO_PVP 75 /* Packet Video Protocol */ +#define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ +#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ +#define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ +#define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ +#define IPPROTO_EON 80 /* ISO cnlp */ +#define IPPROTO_VMTP 81 /* VMTP */ +#define IPPROTO_SVMTP 82 /* Secure VMTP */ +#define IPPROTO_VINES 83 /* Banyon VINES */ +#define IPPROTO_TTP 84 /* TTP */ +#define IPPROTO_IGP 85 /* NSFNET-IGP */ +#define IPPROTO_DGP 86 /* dissimilar gateway prot. */ +#define IPPROTO_TCF 87 /* TCF */ +#define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ +#define IPPROTO_OSPFIGP 89 /* OSPFIGP */ +#define IPPROTO_SRPC 90 /* Strite RPC protocol */ +#define IPPROTO_LARP 91 /* Locus Address Resoloution */ +#define IPPROTO_MTP 92 /* Multicast Transport */ +#define IPPROTO_AX25 93 /* AX.25 Frames */ +#define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ +#define IPPROTO_MICP 95 /* Mobile Int.ing control */ +#define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ +#define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ +#define IPPROTO_ENCAP 98 /* encapsulation header */ +#define IPPROTO_APES 99 /* any private encr. scheme */ +#define IPPROTO_GMTP 100 /* GMTP*/ +#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ +#define IPPROTO_SCTP 132 /* SCTP */ +/* 101-254: Partly Unassigned */ +#define IPPROTO_PIM 103 /* Protocol Independent Mcast */ +#define IPPROTO_CARP 112 /* CARP */ +#define IPPROTO_PGM 113 /* PGM */ +#define IPPROTO_PFSYNC 240 /* PFSYNC */ +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion, no longer used */ +#define IPPROTO_OLD_DIVERT 254 /* OLD divert pseudo-proto */ +#define IPPROTO_MAX 256 + +/* last return value of *_input(), meaning "all job for this pkt is done". */ +#define IPPROTO_DONE 257 + +/* Only used internally, so can be outside the range of valid IP protocols. */ +#define IPPROTO_DIVERT 258 /* divert pseudo-protocol */ + +/* + * Defined to avoid confusion. The master value is defined by + * PROTO_SPACER in sys/protosw.h. + */ +#define IPPROTO_SPACER 32767 /* spacer for loadable protos */ + +/* + * Local port number conventions: + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * The default range is IPPORT_HIFIRSTAUTO through + * IPPORT_HILASTAUTO, although that is settable by sysctl. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers + * into the "high" range. These are reserved for client outbound connections + * which do not want to be filtered by any firewalls. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. This + * convention is based on "vouchsafe" principles only. It is only secure + * if you trust the remote host to restrict these ports. + * + * The default range of ports and the high range can be changed by + * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) + * + * Changing those values has bad security implications if you are + * using a stateless firewall that is allowing packets outside of that + * range in order to allow transparent outgoing connections. + * + * Such a firewall configuration will generally depend on the use of these + * default values. If you change them, you may find your Security + * Administrator looking for you with a heavy object. + * + * For a slightly more orthodox text view on this: + * + * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers + * + * port numbers are divided into three ranges: + * + * 0 - 1023 Well Known Ports + * 1024 - 49151 Registered Ports + * 49152 - 65535 Dynamic and/or Private Ports + * + */ + +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). (IP_PORTRANGE_LOW) + */ +#define IPPORT_RESERVED 1024 + +/* + * Default local port range, used by IP_PORTRANGE_DEFAULT + */ +#define IPPORT_EPHEMERALFIRST 10000 +#define IPPORT_EPHEMERALLAST 65535 + +/* + * Dynamic port range, used by IP_PORTRANGE_HIGH. + */ +#define IPPORT_HIFIRSTAUTO 49152 +#define IPPORT_HILASTAUTO 65535 + +/* + * Scanning for a free reserved port return a value below IPPORT_RESERVED, + * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was + * 512, but that conflicts with some well-known-services that firewalls may + * have a fit if we use. + */ +#define IPPORT_RESERVEDSTART 600 + +#define IPPORT_MAX 65535 + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + */ +#define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ff + +#define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) + +#define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) +#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) +#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) + +#define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ + (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ + (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) + +#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) + +#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) + +#define INADDR_LOOPBACK (u_int32_t)0x7f000001 +#ifndef _KERNEL +#define INADDR_NONE 0xffffffff /* -1 return */ +#endif + +#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ +#define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ +#define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ +#define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ +#define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ +#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ + +#define IN_LOOPBACKNET 127 /* official! */ + +/* + * Options for use with [gs]etsockopt at the IP level. + * First word of comment is data type; bool is stored in int. + */ +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ +#define IP_HDRINCL 2 /* int; header is included with data */ +#define IP_TOS 3 /* int; IP type of service and preced. */ +#define IP_TTL 4 /* int; IP time to live */ +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ +#define IP_SENDSRCADDR IP_RECVDSTADDR /* cmsg_type to set src addr */ +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */ +#define IP_MULTICAST_IF 9 /* struct in_addr *or* struct ip_mreqn; + * set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ +#define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ +#define IP_RSVP_ON 15 /* enable RSVP in kernel */ +#define IP_RSVP_OFF 16 /* disable RSVP in kernel */ +#define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ +#define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ +#define IP_PORTRANGE 19 /* int; range to choose for unspec port */ +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */ +/* for IPSEC */ +#define IP_IPSEC_POLICY 21 /* int; set/get security policy */ +#define IP_FAITH 22 /* bool; accept FAITH'ed connections */ + +#define IP_ONESBCAST 23 /* bool: send all-ones broadcast */ +#define IP_BINDANY 24 /* bool: allow bind to any address */ + +/* + * Options for controlling the firewall and dummynet. + * Historical options (from 40 to 64) will eventually be + * replaced by only two options, IP_FW3 and IP_DUMMYNET3. + */ +#define IP_FW_TABLE_ADD 40 /* add entry */ +#define IP_FW_TABLE_DEL 41 /* delete entry */ +#define IP_FW_TABLE_FLUSH 42 /* flush table */ +#define IP_FW_TABLE_GETSIZE 43 /* get table size */ +#define IP_FW_TABLE_LIST 44 /* list table contents */ + +#define IP_FW3 48 /* generic ipfw v.3 sockopts */ +#define IP_DUMMYNET3 49 /* generic dummynet v.3 sockopts */ + +#define IP_FW_ADD 50 /* add a firewall rule to chain */ +#define IP_FW_DEL 51 /* delete a firewall rule from chain */ +#define IP_FW_FLUSH 52 /* flush firewall rule chain */ +#define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */ +#define IP_FW_GET 54 /* get entire firewall rule chain */ +#define IP_FW_RESETLOG 55 /* reset logging counters */ + +#define IP_FW_NAT_CFG 56 /* add/config a nat rule */ +#define IP_FW_NAT_DEL 57 /* delete a nat rule */ +#define IP_FW_NAT_GET_CONFIG 58 /* get configuration of a nat rule */ +#define IP_FW_NAT_GET_LOG 59 /* get log of a nat rule */ + +#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ +#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ +#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ +#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ + +#define IP_RECVTTL 65 /* bool; receive IP TTL w/dgram */ +#define IP_MINTTL 66 /* minimum TTL for packet or drop */ +#define IP_DONTFRAG 67 /* don't fragment packet */ + +/* IPv4 Source Filter Multicast API [RFC3678] */ +#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ +#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ +#define IP_BLOCK_SOURCE 72 /* block a source */ +#define IP_UNBLOCK_SOURCE 73 /* unblock a source */ + +/* The following option is private; do not use it from user applications. */ +#define IP_MSFILTER 74 /* set/get filter list */ + +/* Protocol Independent Multicast API [RFC3678] */ +#define MCAST_JOIN_GROUP 80 /* join an any-source group */ +#define MCAST_LEAVE_GROUP 81 /* leave all sources for group */ +#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ +#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ +#define MCAST_BLOCK_SOURCE 84 /* block a source */ +#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ + +/* + * Defaults and limits for options + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +/* + * The imo_membership vector for each socket is now dynamically allocated at + * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized + * according to a power-of-two increment. + */ +#define IP_MIN_MEMBERSHIPS 31 +#define IP_MAX_MEMBERSHIPS 4095 +#define IP_MAX_SOURCE_FILTER 1024 /* XXX to be unused */ + +/* + * Default resource limits for IPv4 multicast source filtering. + * These may be modified by sysctl. + */ +#define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */ +#define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ +#define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Modified argument structure for IP_MULTICAST_IF, obtained from Linux. + * This is used to specify an interface index for multicast sends, as + * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). + */ +struct ip_mreqn { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_address; /* local IP address of interface */ + int imr_ifindex; /* Interface index; cast to uint32_t */ +}; + +/* + * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] + */ +struct ip_mreq_source { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument structures for Protocol-Independent Multicast Source + * Filter APIs. [RFC3678] + */ +struct group_req { + uint32_t gr_interface; /* interface index */ + struct sockaddr_storage gr_group; /* group address */ +}; + +struct group_source_req { + uint32_t gsr_interface; /* interface index */ + struct sockaddr_storage gsr_group; /* group address */ + struct sockaddr_storage gsr_source; /* source address */ +}; + +#ifndef __MSFILTERREQ_DEFINED +#define __MSFILTERREQ_DEFINED +/* + * The following structure is private; do not use it from user applications. + * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between + * the RFC 3678 libc functions and the kernel. + */ +struct __msfilterreq { + uint32_t msfr_ifindex; /* interface index */ + uint32_t msfr_fmode; /* filter mode for group */ + uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ + struct sockaddr_storage msfr_group; /* group address */ + struct sockaddr_storage *msfr_srcs; /* pointer to the first member + * of a contiguous array of + * sources to filter in full. + */ +}; +#endif + +struct sockaddr; + +/* + * Advanced (Full-state) APIs [RFC3678] + * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). + * We use uint32_t here to be consistent. + */ +int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, + uint32_t, struct in_addr *); +int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, + uint32_t *, struct in_addr *); +int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, + uint32_t, uint32_t, struct sockaddr_storage *); +int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, + uint32_t *, uint32_t *, struct sockaddr_storage *); + +/* + * Filter modes; also used to represent per-socket filter mode internally. + */ +#define MCAST_UNDEFINED 0 /* fmode: not yet defined */ +#define MCAST_INCLUDE 1 /* fmode: include these source(s) */ +#define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */ + +/* + * Argument for IP_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IP_PORTRANGE_DEFAULT 0 /* default range */ +#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + +/* + * Definitions for inet sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ + +#define CTL_IPPROTO_NAMES { \ + { "ip", CTLTYPE_NODE }, \ + { "icmp", CTLTYPE_NODE }, \ + { "igmp", CTLTYPE_NODE }, \ + { "ggp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "tcp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { "egp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "pup", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "udp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "idp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "ipsec", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "pim", CTLTYPE_NODE }, \ +} + +/* + * Names for IP sysctl objects + */ +#define IPCTL_FORWARDING 1 /* act as router */ +#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPCTL_DEFTTL 3 /* default TTL */ +#ifdef notyet +#define IPCTL_DEFMTU 4 /* default MTU */ +#endif +#define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ +#define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ +#define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ +#define IPCTL_SOURCEROUTE 8 /* may perform source routes */ +#define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ +#define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ +#define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ +#define IPCTL_STATS 12 /* ipstat structure */ +#define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ +#define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ +#define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */ +#define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ +#define IPCTL_MAXID 17 + +#define IPCTL_NAMES { \ + { 0, 0 }, \ + { "forwarding", CTLTYPE_INT }, \ + { "redirect", CTLTYPE_INT }, \ + { "ttl", CTLTYPE_INT }, \ + { "mtu", CTLTYPE_INT }, \ + { "rtexpire", CTLTYPE_INT }, \ + { "rtminexpire", CTLTYPE_INT }, \ + { "rtmaxcache", CTLTYPE_INT }, \ + { "sourceroute", CTLTYPE_INT }, \ + { "directed-broadcast", CTLTYPE_INT }, \ + { "intr-queue-maxlen", CTLTYPE_INT }, \ + { "intr-queue-drops", CTLTYPE_INT }, \ + { "stats", CTLTYPE_STRUCT }, \ + { "accept_sourceroute", CTLTYPE_INT }, \ + { "fastforwarding", CTLTYPE_INT }, \ +} + +#endif /* __BSD_VISIBLE */ + +#ifdef _KERNEL + +struct ifnet; struct mbuf; /* forward declarations for Standard C */ + +int in_broadcast(struct in_addr, struct ifnet *); +int in_canforward(struct in_addr); +int in_localaddr(struct in_addr); +int in_localip(struct in_addr); +int inet_aton(const char *, struct in_addr *); /* in libkern */ +char *inet_ntoa(struct in_addr); /* in libkern */ +char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */ +char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */ +int inet_pton(int af, const char *, void *); /* in libkern */ +void in_ifdetach(struct ifnet *); + +#define in_hosteq(s, t) ((s).s_addr == (t).s_addr) +#define in_nullhost(x) ((x).s_addr == INADDR_ANY) +#define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP)) + +#define satosin(sa) ((struct sockaddr_in *)(sa)) +#define sintosa(sin) ((struct sockaddr *)(sin)) +#define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) + +/* + * Historically, BSD keeps ip_len and ip_off in host format + * when doing layer 3 processing, and this often requires + * to translate the format back and forth. + * To make the process explicit, we define a couple of macros + * that also take into account the fact that at some point + * we may want to keep those fields always in net format. + */ + +#if (BYTE_ORDER == BIG_ENDIAN) || defined(HAVE_NET_IPLEN) +#define SET_NET_IPLEN(p) do {} while (0) +#define SET_HOST_IPLEN(p) do {} while (0) +#else +#define SET_NET_IPLEN(p) do { \ + struct ip *h_ip = (p); \ + h_ip->ip_len = htons(h_ip->ip_len); \ + h_ip->ip_off = htons(h_ip->ip_off); \ + } while (0) + +#define SET_HOST_IPLEN(p) do { \ + struct ip *h_ip = (p); \ + h_ip->ip_len = ntohs(h_ip->ip_len); \ + h_ip->ip_off = ntohs(h_ip->ip_off); \ + } while (0) +#endif /* !HAVE_NET_IPLEN */ + +#endif /* _KERNEL */ + +/* INET6 stuff */ +#if __POSIX_VISIBLE >= 200112 +#define __KAME_NETINET_IN_HH_INCLUDED_ +#include +#undef __KAME_NETINET_IN_HH_INCLUDED_ +#endif + +#endif /* !_NETINET_IN_H_*/ diff --git a/freebsd/sys/netinet/in_gif.c b/freebsd/sys/netinet/in_gif.c index 3613e214..12faa528 100644 --- a/freebsd/sys/netinet/in_gif.c +++ b/freebsd/sys/netinet/in_gif.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: in_gif.c,v 1.54 2001/05/14 14:02:16 itojun Exp $ */ @@ -31,46 +31,46 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif #ifdef MROUTING -#include +#include #endif /* MROUTING */ -#include +#include static int gif_validate4(const struct ip *, struct gif_softc *, struct ifnet *); diff --git a/freebsd/sys/netinet/in_gif.h b/freebsd/sys/netinet/in_gif.h index 1e42b01f..e1f4ae48 100644 --- a/freebsd/sys/netinet/in_gif.h +++ b/freebsd/sys/netinet/in_gif.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETINET_IN_GIF_HH_ -#define _NETINET_IN_GIF_HH_ +#ifndef _NETINET_IN_GIF_H_ +#define _NETINET_IN_GIF_H_ #define GIF_TTL 30 @@ -42,4 +42,4 @@ int gif_encapcheck4(const struct mbuf *, int, int, void *); int in_gif_attach(struct gif_softc *); int in_gif_detach(struct gif_softc *); -#endif /*_NETINET_IN_GIF_HH_*/ +#endif /*_NETINET_IN_GIF_H_*/ diff --git a/freebsd/sys/netinet/in_mcast.c b/freebsd/sys/netinet/in_mcast.c index ed2bcc12..d6a316a5 100644 --- a/freebsd/sys/netinet/in_mcast.c +++ b/freebsd/sys/netinet/in_mcast.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007-2009 Bruce Simpson. @@ -34,33 +34,33 @@ * IPv4 multicast socket, group, and socket option processing module. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifndef KTR_IGMPV3 #define KTR_IGMPV3 KTR_INET diff --git a/freebsd/sys/netinet/in_pcb.c b/freebsd/sys/netinet/in_pcb.c index 186a0f0a..9fd9536e 100644 --- a/freebsd/sys/netinet/in_pcb.c +++ b/freebsd/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1991, 1993, 1995 @@ -33,57 +33,57 @@ * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef DDB -#include +#include #endif -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif /* INET6 */ #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC */ -#include +#include /* * These configure the range of local port addresses assigned to diff --git a/freebsd/sys/netinet/in_pcb.h b/freebsd/sys/netinet/in_pcb.h index 8cd4a5f8..334537d7 100644 --- a/freebsd/sys/netinet/in_pcb.h +++ b/freebsd/sys/netinet/in_pcb.h @@ -31,17 +31,17 @@ * $FreeBSD$ */ -#ifndef _NETINET_IN_PCB_HH_ -#define _NETINET_IN_PCB_HH_ +#ifndef _NETINET_IN_PCB_H_ +#define _NETINET_IN_PCB_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #endif #define in6pcb inpcb /* for KAME src sync over BSD*'s */ @@ -237,7 +237,7 @@ struct inpcb { * Interface exported to userland by various protocols which use inpcbs. Hack * alert -- only define if struct xsocket is in scope. */ -#ifdef _SYS_SOCKETVAR_HH_ +#ifdef _SYS_SOCKETVAR_H_ struct xinpcb { size_t xi_len; /* length of this structure */ struct inpcb xi_inp; @@ -251,7 +251,7 @@ struct xinpgen { inp_gen_t xig_gen; /* generation count at this time */ so_gen_t xig_sogen; /* socket generation count at this time */ }; -#endif /* _SYS_SOCKETVAR_HH_ */ +#endif /* _SYS_SOCKETVAR_H_ */ struct inpcbport { LIST_ENTRY(inpcbport) phd_hash; @@ -522,4 +522,4 @@ void in_pcbsosetlabel(struct socket *so); void ipport_tick(void *xtp); #endif /* _KERNEL */ -#endif /* !_NETINET_IN_PCB_HH_ */ +#endif /* !_NETINET_IN_PCB_H_ */ diff --git a/freebsd/sys/netinet/in_proto.c b/freebsd/sys/netinet/in_proto.c index 9be0b626..db25a54d 100644 --- a/freebsd/sys/netinet/in_proto.c +++ b/freebsd/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -31,47 +31,47 @@ * @(#)in_proto.c 8.2 (Berkeley) 2/9/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * TCP/IP protocol family: IP, ICMP, UDP, TCP. @@ -80,19 +80,19 @@ __FBSDID("$FreeBSD$"); static struct pr_usrreqs nousrreqs; #ifdef IPSEC -#include +#include #endif /* IPSEC */ #ifdef SCTP -#include -#include -#include -#include +#include +#include +#include +#include #endif /* SCTP */ #ifdef DEV_PFSYNC -#include -#include +#include +#include #endif extern struct domain inetdomain; diff --git a/freebsd/sys/netinet/in_rmx.c b/freebsd/sys/netinet/in_rmx.c index 25f99ea0..dda56194 100644 --- a/freebsd/sys/netinet/in_rmx.c +++ b/freebsd/sys/netinet/in_rmx.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright 1994, 1995 Massachusetts Institute of Technology @@ -42,25 +42,25 @@ * indefinitely. See in_rtqtimo() below for the exact mechanism. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include extern int in_inithead(void **head, int off); #ifdef VIMAGE diff --git a/freebsd/sys/netinet/in_systm.h b/freebsd/sys/netinet/in_systm.h index 68bb190e..4b34aa00 100644 --- a/freebsd/sys/netinet/in_systm.h +++ b/freebsd/sys/netinet/in_systm.h @@ -1,2 +1,58 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NETINET_IN_SYSTM_H_ +#define _NETINET_IN_SYSTM_H_ + +/* + * Miscellaneous internetwork + * definitions for kernel. + */ + +/* + * Network types. + * + * Internally the system keeps counters in the headers with the bytes + * swapped so that VAX instructions will work on them. It reverses + * the bytes before transmission at each protocol level. The n_ types + * represent the types with the bytes in ``high-ender'' order. + */ +typedef u_int16_t n_short; /* short as received from the net */ +typedef u_int32_t n_long; /* long as received from the net */ + +typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ + +#ifdef _KERNEL +uint32_t iptime(void); +#endif + +#endif diff --git a/freebsd/sys/netinet/in_var.h b/freebsd/sys/netinet/in_var.h index c921ad31..cd1d9043 100644 --- a/freebsd/sys/netinet/in_var.h +++ b/freebsd/sys/netinet/in_var.h @@ -30,12 +30,12 @@ * $FreeBSD$ */ -#ifndef _NETINET_IN_VAR_HH_ -#define _NETINET_IN_VAR_HH_ +#ifndef _NETINET_IN_VAR_H_ +#define _NETINET_IN_VAR_H_ -#include -#include -#include +#include +#include +#include struct igmp_ifinfo; struct in_multi; @@ -470,6 +470,6 @@ int in_rtrequest1(int, struct rt_addrinfo *, struct rtentry **, u_int); #endif /* _KERNEL */ /* INET6 stuff */ -#include +#include -#endif /* _NETINET_IN_VAR_HH_ */ +#endif /* _NETINET_IN_VAR_H_ */ diff --git a/freebsd/sys/netinet/ip.h b/freebsd/sys/netinet/ip.h index 9d5d8a9c..daee533e 100644 --- a/freebsd/sys/netinet/ip.h +++ b/freebsd/sys/netinet/ip.h @@ -1,2 +1,196 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)ip.h 8.2 (Berkeley) 6/1/94 + * $FreeBSD$ + */ + +#ifndef _NETINET_IP_H_ +#define _NETINET_IP_H_ + +#include + +/* + * Definitions for internet protocol version 4. + * + * Per RFC 791, September 1981. + */ +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#if BYTE_ORDER == LITTLE_ENDIAN + u_int ip_hl:4, /* header length */ + ip_v:4; /* version */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + u_int ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif + u_char ip_tos; /* type of service */ + u_short ip_len; /* total length */ + u_short ip_id; /* identification */ + u_short ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_char ip_ttl; /* time to live */ + u_char ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + struct in_addr ip_src,ip_dst; /* source and dest address */ +} __packed __aligned(4); + +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos). + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused). + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * ECN (Explicit Congestion Notification) codepoints in RFC3168 mapped to the + * lower 2 bits of the TOS field. + */ +#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */ +#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */ +#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */ +#define IPTOS_ECN_CE 0x03 /* congestion experienced */ +#define IPTOS_ECN_MASK 0x03 /* ECN field mask */ + +/* + * Definitions for options. + */ +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_NOP 1 /* no operation */ + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_ESO 133 /* extended security */ +#define IPOPT_CIPSO 134 /* commerical security */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SSRR 137 /* strict source route */ +#define IPOPT_RA 148 /* router alert */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + u_char ipt_code; /* IPOPT_TS */ + u_char ipt_len; /* size of structure (variable) */ + u_char ipt_ptr; /* index of current entry */ +#if BYTE_ORDER == LITTLE_ENDIAN + u_int ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + u_int ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + uint32_t ipt_time[1]; /* network format */ + struct ipt_ta { + struct in_addr ipt_addr; + uint32_t ipt_time; /* network format */ + } ipt_ta[1]; + } ipt_timestamp; +}; + +/* Flag bits for ipt_flg. */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* Bits for security (not byte swapped). */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ +#define IP_MSS 576 /* default maximum segment size */ + +/* + * This is the real IPv4 pseudo header, used for computing the TCP and UDP + * checksums. For the Internet checksum, struct ipovly can be used instead. + * For stronger checksums, the real thing must be used. + */ +struct ippseudo { + struct in_addr ippseudo_src; /* source internet address */ + struct in_addr ippseudo_dst; /* destination internet address */ + u_char ippseudo_pad; /* pad, must be zero */ + u_char ippseudo_p; /* protocol */ + u_short ippseudo_len; /* protocol length */ +}; +#endif diff --git a/freebsd/sys/netinet/ip6.h b/freebsd/sys/netinet/ip6.h index f30da6d1..3fb08a78 100644 --- a/freebsd/sys/netinet/ip6.h +++ b/freebsd/sys/netinet/ip6.h @@ -1,2 +1,352 @@ -#include -#include +/* $FreeBSD$ */ +/* $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $ */ + +/*- + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. + */ + +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)ip.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP6_H_ +#define _NETINET_IP6_H_ + +/* + * Definition for internet protocol version 6. + * RFC 2460 + */ + +struct ip6_hdr { + union { + struct ip6_hdrctl { + u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ + u_int16_t ip6_un1_plen; /* payload length */ + u_int8_t ip6_un1_nxt; /* next header */ + u_int8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +} __packed; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +#define IPV6_VERSION 0x60 +#define IPV6_VERSION_MASK 0xf0 + +#if BYTE_ORDER == BIG_ENDIAN +#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ +#endif /* LITTLE_ENDIAN */ +#endif +#if 1 +/* ECN bits proposed by Sally Floyd */ +#define IP6TOS_CE 0x01 /* congestion experienced */ +#define IP6TOS_ECT 0x02 /* ECN-capable transport */ +#endif + +/* + * Extension Headers + */ + +struct ip6_ext { + u_int8_t ip6e_nxt; + u_int8_t ip6e_len; +} __packed; + +/* Hop-by-Hop options header */ +/* XXX should we pad it to force alignment on an 8-byte boundary? */ +struct ip6_hbh { + u_int8_t ip6h_nxt; /* next header */ + u_int8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +} __packed; + +/* Destination options header */ +/* XXX should we pad it to force alignment on an 8-byte boundary? */ +struct ip6_dest { + u_int8_t ip6d_nxt; /* next header */ + u_int8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +} __packed; + +/* Option types and related macros */ +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ +#define IP6OPT_NSAP_ADDR 0xC3 /* 11 0 00011 */ +#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */ +#ifndef _KERNEL +#define IP6OPT_RTALERT 0x05 /* 00 0 00101 (KAME definition) */ +#endif +#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 (RFC3542, recommended) */ + +#define IP6OPT_RTALERT_LEN 4 +#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ +#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ +#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ +#define IP6OPT_MINLEN 2 + +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +#define IP6OPT_TYPE(o) ((o) & 0xC0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xC0 + +#define IP6OPT_MUTABLE 0x20 + +/* IPv6 options: common part */ +struct ip6_opt { + u_int8_t ip6o_type; + u_int8_t ip6o_len; +} __packed; + +/* Jumbo Payload Option */ +struct ip6_opt_jumbo { + u_int8_t ip6oj_type; + u_int8_t ip6oj_len; + u_int8_t ip6oj_jumbo_len[4]; +} __packed; +#define IP6OPT_JUMBO_LEN 6 + +/* NSAP Address Option */ +struct ip6_opt_nsap { + u_int8_t ip6on_type; + u_int8_t ip6on_len; + u_int8_t ip6on_src_nsap_len; + u_int8_t ip6on_dst_nsap_len; + /* followed by source NSAP */ + /* followed by destination NSAP */ +} __packed; + +/* Tunnel Limit Option */ +struct ip6_opt_tunnel { + u_int8_t ip6ot_type; + u_int8_t ip6ot_len; + u_int8_t ip6ot_encap_limit; +} __packed; + +/* Router Alert Option */ +struct ip6_opt_router { + u_int8_t ip6or_type; + u_int8_t ip6or_len; + u_int8_t ip6or_value[2]; +} __packed; +/* Router alert values (in network byte order) */ +#if BYTE_ORDER == BIG_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0001 +#define IP6_ALERT_AN 0x0002 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define IP6_ALERT_MLD 0x0000 +#define IP6_ALERT_RSVP 0x0100 +#define IP6_ALERT_AN 0x0200 +#endif /* LITTLE_ENDIAN */ +#endif + +/* Routing header */ +struct ip6_rthdr { + u_int8_t ip6r_nxt; /* next header */ + u_int8_t ip6r_len; /* length in units of 8 octets */ + u_int8_t ip6r_type; /* routing type */ + u_int8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +} __packed; + +/* Type 0 Routing header, deprecated by RFC 5095. */ +struct ip6_rthdr0 { + u_int8_t ip6r0_nxt; /* next header */ + u_int8_t ip6r0_len; /* length in units of 8 octets */ + u_int8_t ip6r0_type; /* always zero */ + u_int8_t ip6r0_segleft; /* segments left */ + u_int32_t ip6r0_reserved; /* reserved field */ + /* followed by up to 127 struct in6_addr */ +} __packed; + +/* Fragment header */ +struct ip6_frag { + u_int8_t ip6f_nxt; /* next header */ + u_int8_t ip6f_reserved; /* reserved field */ + u_int16_t ip6f_offlg; /* offset, reserved, and flag */ + u_int32_t ip6f_ident; /* identification */ +} __packed; + +#if BYTE_ORDER == BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +/* + * Internet implementation parameters. + */ +#define IPV6_MAXHLIM 255 /* maximum hoplimit */ +#define IPV6_DEFHLIM 64 /* default hlim */ +#define IPV6_FRAGTTL 120 /* ttl for fragment packets, in slowtimo tick */ +#define IPV6_HLIMDEC 1 /* subtracted when forwarding */ + +#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */ +#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/ +#define IPV6_MAXOPTHDR 2048 /* max option header size, 256 64-bit words */ + +#ifdef _KERNEL +/* + * IP6_EXTHDR_CHECK ensures that region between the IP6 header and the + * target header (including IPv6 itself, extension headers and + * TCP/UDP/ICMP6 headers) are continuous. KAME requires drivers + * to store incoming data into one internal mbuf or one or more external + * mbufs(never into two or more internal mbufs). Thus, the third case is + * supposed to never be matched but is prepared just in case. + */ + +#define IP6_EXTHDR_CHECK(m, off, hlen, ret) \ +do { \ + if ((m)->m_next != NULL) { \ + if (((m)->m_flags & M_LOOP) && \ + ((m)->m_len < (off) + (hlen)) && \ + (((m) = m_pullup((m), (off) + (hlen))) == NULL)) { \ + V_ip6stat.ip6s_exthdrtoolong++; \ + return ret; \ + } else if ((m)->m_flags & M_EXT) { \ + if ((m)->m_len < (off) + (hlen)) { \ + V_ip6stat.ip6s_exthdrtoolong++; \ + m_freem(m); \ + return ret; \ + } \ + } else { \ + if ((m)->m_len < (off) + (hlen)) { \ + V_ip6stat.ip6s_exthdrtoolong++; \ + m_freem(m); \ + return ret; \ + } \ + } \ + } else { \ + if ((m)->m_len < (off) + (hlen)) { \ + V_ip6stat.ip6s_tooshort++; \ + in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); \ + m_freem(m); \ + return ret; \ + } \ + } \ +} while (/*CONSTCOND*/ 0) + +/* + * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to + * "len") is located in single mbuf, on contiguous memory region. + * The pointer to the region will be returned to pointer variable "val", + * with type "typ". + * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the + * very top of mbuf. GET0 is likely to make memory copy than GET. + * + * XXX we're now testing this, needs m_pulldown() + */ +#define IP6_EXTHDR_GET(val, typ, m, off, len) \ +do { \ + struct mbuf *t; \ + int tmp; \ + if ((m)->m_len >= (off) + (len)) \ + (val) = (typ)(mtod((m), caddr_t) + (off)); \ + else { \ + t = m_pulldown((m), (off), (len), &tmp); \ + if (t) { \ + if (t->m_len < tmp + (len)) \ + panic("m_pulldown malfunction"); \ + (val) = (typ)(mtod(t, caddr_t) + tmp); \ + } else { \ + (val) = (typ)NULL; \ + (m) = NULL; \ + } \ + } \ +} while (/*CONSTCOND*/ 0) + +#define IP6_EXTHDR_GET0(val, typ, m, off, len) \ +do { \ + struct mbuf *t; \ + if ((off) == 0) \ + (val) = (typ)mtod(m, caddr_t); \ + else { \ + t = m_pulldown((m), (off), (len), NULL); \ + if (t) { \ + if (t->m_len < (len)) \ + panic("m_pulldown malfunction"); \ + (val) = (typ)mtod(t, caddr_t); \ + } else { \ + (val) = (typ)NULL; \ + (m) = NULL; \ + } \ + } \ +} while (/*CONSTCOND*/ 0) + +#endif /*_KERNEL*/ + +#endif /* not _NETINET_IP6_H_ */ diff --git a/freebsd/sys/netinet/ip_carp.c b/freebsd/sys/netinet/ip_carp.c index 25b20895..7b2a7e18 100644 --- a/freebsd/sys/netinet/ip_carp.c +++ b/freebsd/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -26,71 +26,71 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #ifndef __rtems__ -#include +#include #endif -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif #ifdef INET6 -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif -#include -#include +#include +#include #define CARP_IFNAME "carp" static MALLOC_DEFINE(M_CARP, "CARP", "CARP interfaces"); diff --git a/freebsd/sys/netinet/ip_divert.c b/freebsd/sys/netinet/ip_divert.c index 13999825..857df606 100644 --- a/freebsd/sys/netinet/ip_divert.c +++ b/freebsd/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -29,53 +29,53 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #if !defined(KLD_MODULE) -#include -#include +#include +#include #ifndef INET #error "IPDIVERT requires INET." #endif #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef SCTP -#include +#include #endif -#include +#include /* * Divert sockets diff --git a/freebsd/sys/netinet/ip_divert.h b/freebsd/sys/netinet/ip_divert.h index eb9b33d4..b8bcf4fb 100644 --- a/freebsd/sys/netinet/ip_divert.h +++ b/freebsd/sys/netinet/ip_divert.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP_DIVERT_HH_ -#define _NETINET_IP_DIVERT_HH_ +#ifndef _NETINET_IP_DIVERT_H_ +#define _NETINET_IP_DIVERT_H_ /* * divert has no custom kernel-userland API. @@ -52,4 +52,4 @@ * sin_addr = IN: address of the incoming interface; * OUT: INADDR_ANY */ -#endif /* _NETINET_IP_DIVERT_HH_ */ +#endif /* _NETINET_IP_DIVERT_H_ */ diff --git a/freebsd/sys/netinet/ip_ecn.c b/freebsd/sys/netinet/ip_ecn.c index 97b32b2c..33f07b8a 100644 --- a/freebsd/sys/netinet/ip_ecn.c +++ b/freebsd/sys/netinet/ip_ecn.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: ip_ecn.c,v 1.12 2002/01/07 11:34:47 kjc Exp $ */ @@ -36,27 +36,27 @@ * http://www.aciri.org/floyd/papers/draft-ipsec-ecn-00.txt */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif /* diff --git a/freebsd/sys/netinet/ip_ecn.h b/freebsd/sys/netinet/ip_ecn.h index 271c8a47..6a814160 100644 --- a/freebsd/sys/netinet/ip_ecn.h +++ b/freebsd/sys/netinet/ip_ecn.h @@ -35,11 +35,11 @@ * http://www.aciri.org/floyd/papers/draft-ipsec-ecn-00.txt */ -#ifndef _NETINET_IP_ECN_HH_ -#define _NETINET_IP_ECN_HH_ +#ifndef _NETINET_IP_ECN_H_ +#define _NETINET_IP_ECN_H_ #if defined(_KERNEL) && !defined(_LKM) -#include +#include #endif #define ECN_ALLOWED 1 /* ECN allowed */ diff --git a/freebsd/sys/netinet/ip_encap.c b/freebsd/sys/netinet/ip_encap.c index 45b0593c..9c7b904d 100644 --- a/freebsd/sys/netinet/ip_encap.c +++ b/freebsd/sys/netinet/ip_encap.c @@ -1,4 +1,4 @@ -#include +#include /* $KAME: ip_encap.c,v 1.41 2001/03/15 08:35:08 itojun Exp $ */ @@ -58,41 +58,41 @@ */ /* XXX is M_NETADDR correct? */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include +#include -#include -#include +#include +#include static MALLOC_DEFINE(M_NETADDR, "encap_export_host", "Export host address structure"); static void encap_add(struct encaptab *); diff --git a/freebsd/sys/netinet/ip_encap.h b/freebsd/sys/netinet/ip_encap.h index 44dd1a0d..3b1a5aee 100644 --- a/freebsd/sys/netinet/ip_encap.h +++ b/freebsd/sys/netinet/ip_encap.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETINET_IP_ENCAP_HH_ -#define _NETINET_IP_ENCAP_HH_ +#ifndef _NETINET_IP_ENCAP_H_ +#define _NETINET_IP_ENCAP_H_ #ifdef _KERNEL @@ -61,4 +61,4 @@ int encap_detach(const struct encaptab *); void *encap_getarg(struct mbuf *); #endif -#endif /*_NETINET_IP_ENCAP_HH_*/ +#endif /*_NETINET_IP_ENCAP_H_*/ diff --git a/freebsd/sys/netinet/ip_fastfwd.c b/freebsd/sys/netinet/ip_fastfwd.c index 6d406b2b..f27a4f7d 100644 --- a/freebsd/sys/netinet/ip_fastfwd.c +++ b/freebsd/sys/netinet/ip_fastfwd.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2003 Andre Oppermann, Internet Business Solutions AG @@ -75,38 +75,38 @@ * is being followed here. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include static VNET_DEFINE(int, ipfastforward_active); #define V_ipfastforward_active VNET(ipfastforward_active) diff --git a/freebsd/sys/netinet/ip_gre.c b/freebsd/sys/netinet/ip_gre.c index 253376de..cd118a53 100644 --- a/freebsd/sys/netinet/ip_gre.c +++ b/freebsd/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -#include +#include /* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */ @@ -46,52 +46,52 @@ * This currently handles IPPROTO_GRE, IPPROTO_MOBILE */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #else #error ip_gre input without IP? #endif #ifdef NETATALK -#include -#include -#include +#include +#include +#include #endif /* Needs IP headers. */ -#include +#include -#include +#include #if 1 void gre_inet_ntoa(struct in_addr in); /* XXX */ diff --git a/freebsd/sys/netinet/ip_icmp.c b/freebsd/sys/netinet/ip_icmp.c index b7a83128..d8d34aa4 100644 --- a/freebsd/sys/netinet/ip_icmp.c +++ b/freebsd/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -31,47 +31,47 @@ * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif -#include +#include -#include +#include /* * ICMP routines: error generation, receive packet processing, and diff --git a/freebsd/sys/netinet/ip_icmp.h b/freebsd/sys/netinet/ip_icmp.h index 903f033d..9cabdb58 100644 --- a/freebsd/sys/netinet/ip_icmp.h +++ b/freebsd/sys/netinet/ip_icmp.h @@ -1,2 +1,214 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NETINET_IP_ICMP_H_ +#define _NETINET_IP_ICMP_H_ + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +/* + * Internal of an ICMP Router Advertisement + */ +struct icmp_ra_addr { + u_int32_t ira_addr; + u_int32_t ira_preference; +}; + +/* + * Structure of an icmp header. + */ +struct icmphdr { + u_char icmp_type; /* type of message, see below */ + u_char icmp_code; /* type sub code */ + u_short icmp_cksum; /* ones complement cksum of struct */ +}; + +/* + * Structure of an icmp packet. + * + * XXX: should start with a struct icmphdr. + */ +struct icmp { + u_char icmp_type; /* type of message, see below */ + u_char icmp_code; /* type sub code */ + u_short icmp_cksum; /* ones complement cksum of struct */ + union { + u_char ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ + struct ih_idseq { + uint16_t icd_id; /* network format */ + uint16_t icd_seq; /* network format */ + } ih_idseq; + int ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu { + uint16_t ipm_void; /* network format */ + uint16_t ipm_nextmtu; /* network format */ + } ih_pmtu; + + struct ih_rtradv { + u_char irt_num_addrs; + u_char irt_wpa; + u_int16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu +#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs +#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa +#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime + union { + struct id_ts { /* ICMP Timestamp */ + /* + * The next 3 fields are in network format, + * milliseconds since 00:00 GMT + */ + uint32_t its_otime; /* Originate */ + uint32_t its_rtime; /* Receive */ + uint32_t its_ttime; /* Transmit */ + } id_ts; + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + struct icmp_ra_addr id_radv; + u_int32_t id_mask; + char id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_radv icmp_dun.id_radv +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ALTHOSTADDR 6 /* alternate host address */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERADVERT_NORMAL 0 /* normal advertisement */ +#define ICMP_ROUTERADVERT_NOROUTE_COMMON 16 /* selective routing */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ +#define ICMP_PARAMPROB_LENGTH 2 /* bad length */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ +#define ICMP_TRACEROUTE 30 /* traceroute */ +#define ICMP_DATACONVERR 31 /* data conversion error */ +#define ICMP_MOBILE_REDIRECT 32 /* mobile host redirect */ +#define ICMP_IPV6_WHEREAREYOU 33 /* IPv6 where-are-you */ +#define ICMP_IPV6_IAMHERE 34 /* IPv6 i-am-here */ +#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */ +#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */ +#define ICMP_SKIP 39 /* SKIP */ +#define ICMP_PHOTURIS 40 /* Photuris */ +#define ICMP_PHOTURIS_UNKNOWN_INDEX 1 /* unknown sec index */ +#define ICMP_PHOTURIS_AUTH_FAILED 2 /* auth failed */ +#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */ + +#define ICMP_MAXTYPE 40 + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#ifdef _KERNEL +void icmp_error(struct mbuf *, int, int, uint32_t, int); +void icmp_input(struct mbuf *, int); +int ip_next_mtu(int, int); +#endif + +#endif diff --git a/freebsd/sys/netinet/ip_id.c b/freebsd/sys/netinet/ip_id.c index ba99cdbb..21bb84cc 100644 --- a/freebsd/sys/netinet/ip_id.c +++ b/freebsd/sys/netinet/ip_id.c @@ -1,4 +1,4 @@ -#include +#include /*- @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -76,20 +76,20 @@ __FBSDID("$FreeBSD$"); * enabled. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static MALLOC_DEFINE(M_IPID, "ipid", "randomized ip id state"); diff --git a/freebsd/sys/netinet/ip_input.c b/freebsd/sys/netinet/ip_input.c index 3964e886..1b7f4319 100644 --- a/freebsd/sys/netinet/ip_input.c +++ b/freebsd/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -31,58 +31,58 @@ * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include +#include #endif /* IPSEC */ -#include +#include -#include +#include #ifdef CTASSERT CTASSERT(sizeof(struct ip) == 20); diff --git a/freebsd/sys/netinet/ip_ipsec.c b/freebsd/sys/netinet/ip_ipsec.c index f19d5e0e..f83b2d93 100644 --- a/freebsd/sys/netinet/ip_ipsec.c +++ b/freebsd/sys/netinet/ip_ipsec.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -29,45 +29,45 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef SCTP -#include +#include #endif -#include +#include #ifdef IPSEC -#include -#include -#include +#include +#include +#include #endif /*IPSEC*/ extern struct protosw inetsw[]; diff --git a/freebsd/sys/netinet/ip_ipsec.h b/freebsd/sys/netinet/ip_ipsec.h index c4de1652..31bc86a1 100644 --- a/freebsd/sys/netinet/ip_ipsec.h +++ b/freebsd/sys/netinet/ip_ipsec.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP_IPSEC_HH_ -#define _NETINET_IP_IPSEC_HH_ +#ifndef _NETINET_IP_IPSEC_H_ +#define _NETINET_IP_IPSEC_H_ int ip_ipsec_filtertunnel(struct mbuf *); int ip_ipsec_fwd(struct mbuf *); diff --git a/freebsd/sys/netinet/ip_mroute.c b/freebsd/sys/netinet/ip_mroute.c index 2f7676ad..022f2451 100644 --- a/freebsd/sys/netinet/ip_mroute.c +++ b/freebsd/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1989 Stephen Deering @@ -68,55 +68,55 @@ * TODO: Sync ip6_mroute.c with this file. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include #define _PIM_VT 1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include #ifndef KTR_IPMF #define KTR_IPMF KTR_INET diff --git a/freebsd/sys/netinet/ip_mroute.h b/freebsd/sys/netinet/ip_mroute.h index 3bc7f52f..c54c75aa 100644 --- a/freebsd/sys/netinet/ip_mroute.h +++ b/freebsd/sys/netinet/ip_mroute.h @@ -34,8 +34,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP_MROUTE_HH_ -#define _NETINET_IP_MROUTE_HH_ +#ifndef _NETINET_IP_MROUTE_H_ +#define _NETINET_IP_MROUTE_H_ /* * Definitions for IP multicast forwarding. @@ -356,4 +356,4 @@ extern int (*mrt_ioctl)(u_long, caddr_t, int); #endif /* _KERNEL */ -#endif /* _NETINET_IP_MROUTE_HH_ */ +#endif /* _NETINET_IP_MROUTE_H_ */ diff --git a/freebsd/sys/netinet/ip_options.c b/freebsd/sys/netinet/ip_options.c index f8b31607..8012fd3f 100644 --- a/freebsd/sys/netinet/ip_options.c +++ b/freebsd/sys/netinet/ip_options.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 1982, 1986, 1988, 1993 @@ -31,43 +31,43 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include static int ip_dosourceroute = 0; SYSCTL_INT(_net_inet_ip, IPCTL_SOURCEROUTE, sourceroute, CTLFLAG_RW, diff --git a/freebsd/sys/netinet/ip_options.h b/freebsd/sys/netinet/ip_options.h index 9c08004d..7ba5ae64 100644 --- a/freebsd/sys/netinet/ip_options.h +++ b/freebsd/sys/netinet/ip_options.h @@ -31,8 +31,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP_OPTIONS_HH_ -#define _NETINET_IP_OPTIONS_HH_ +#ifndef _NETINET_IP_OPTIONS_H_ +#define _NETINET_IP_OPTIONS_H_ struct ipoptrt { struct in_addr dst; /* final destination */ @@ -57,4 +57,4 @@ int ip_pcbopts(struct inpcb *, int, struct mbuf *); void ip_stripoptions(struct mbuf *, struct mbuf *); struct mbuf *ip_srcroute(struct mbuf *); -#endif /* !_NETINET_IP_OPTIONS_HH_ */ +#endif /* !_NETINET_IP_OPTIONS_H_ */ diff --git a/freebsd/sys/netinet/ip_output.c b/freebsd/sys/netinet/ip_output.c index 51132333..c01e0d32 100644 --- a/freebsd/sys/netinet/ip_output.c +++ b/freebsd/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -31,60 +31,60 @@ * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include - -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef SCTP -#include -#include +#include +#include #endif #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC*/ -#include +#include -#include +#include #define print_ip(x, a, y) printf("%s %d.%d.%d.%d%s",\ x, (ntohl(a.s_addr)>>24)&0xFF,\ diff --git a/freebsd/sys/netinet/ip_var.h b/freebsd/sys/netinet/ip_var.h index 2902174d..222b7efe 100644 --- a/freebsd/sys/netinet/ip_var.h +++ b/freebsd/sys/netinet/ip_var.h @@ -30,10 +30,10 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP_VAR_HH_ -#define _NETINET_IP_VAR_HH_ +#ifndef _NETINET_IP_VAR_H_ +#define _NETINET_IP_VAR_H_ -#include +#include /* * Overlay for ip header used by other protocols (tcp, udp). @@ -129,7 +129,7 @@ struct ipstat { #ifdef _KERNEL -#include +#include /* * In-kernel consumers can use these accessor macros directly to update @@ -312,4 +312,4 @@ VNET_DECLARE(int, ip_do_randomid); #endif /* _KERNEL */ -#endif /* !_NETINET_IP_VAR_HH_ */ +#endif /* !_NETINET_IP_VAR_H_ */ diff --git a/freebsd/sys/netinet/ipfw/dn_heap.c b/freebsd/sys/netinet/ipfw/dn_heap.c index 1e6133bc..3af37a86 100644 --- a/freebsd/sys/netinet/ipfw/dn_heap.c +++ b/freebsd/sys/netinet/ipfw/dn_heap.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa @@ -32,24 +32,24 @@ * $FreeBSD$ */ -#include -#include +#include +#include #ifdef _KERNEL __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include #ifndef log #define log(x, arg...) #endif #else /* !_KERNEL */ -#include -#include -#include -#include +#include +#include +#include +#include #include "dn_heap.h" #define log(x, arg...) fprintf(stderr, ## arg) diff --git a/freebsd/sys/netinet/ipfw/dn_sched_fifo.c b/freebsd/sys/netinet/ipfw/dn_sched_fifo.c index 6d5a4a12..3bd5e127 100644 --- a/freebsd/sys/netinet/ipfw/dn_sched_fifo.c +++ b/freebsd/sys/netinet/ipfw/dn_sched_fifo.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa @@ -31,22 +31,22 @@ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ */ -#include -#include /* ipfw_rule_ref */ -#include /* flow_id */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ */ +#include +#include /* ipfw_rule_ref */ +#include /* flow_id */ +#include +#include +#include +#include #else -#include +#include #endif /* diff --git a/freebsd/sys/netinet/ipfw/dn_sched_prio.c b/freebsd/sys/netinet/ipfw/dn_sched_prio.c index c6b6027c..b3cb689c 100644 --- a/freebsd/sys/netinet/ipfw/dn_sched_prio.c +++ b/freebsd/sys/netinet/ipfw/dn_sched_prio.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa @@ -30,22 +30,22 @@ * $FreeBSD$ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ */ -#include -#include /* ipfw_rule_ref */ -#include /* flow_id */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ */ +#include +#include /* ipfw_rule_ref */ +#include /* flow_id */ +#include +#include +#include +#include #else -#include +#include #endif #define DN_SCHED_PRIO 5 //XXX diff --git a/freebsd/sys/netinet/ipfw/dn_sched_qfq.c b/freebsd/sys/netinet/ipfw/dn_sched_qfq.c index 23890199..c8fc4886 100644 --- a/freebsd/sys/netinet/ipfw/dn_sched_qfq.c +++ b/freebsd/sys/netinet/ipfw/dn_sched_qfq.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2010 Fabio Checconi, Luigi Rizzo, Paolo Valente @@ -31,22 +31,22 @@ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ */ -#include -#include /* ipfw_rule_ref */ -#include /* flow_id */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ */ +#include +#include /* ipfw_rule_ref */ +#include /* flow_id */ +#include +#include +#include +#include #else -#include +#include #endif #ifdef QFQ_DEBUG diff --git a/freebsd/sys/netinet/ipfw/dn_sched_rr.c b/freebsd/sys/netinet/ipfw/dn_sched_rr.c index 4aa833f6..ccfd855c 100644 --- a/freebsd/sys/netinet/ipfw/dn_sched_rr.c +++ b/freebsd/sys/netinet/ipfw/dn_sched_rr.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa @@ -31,22 +31,22 @@ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ */ -#include -#include /* ipfw_rule_ref */ -#include /* flow_id */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ */ +#include +#include /* ipfw_rule_ref */ +#include /* flow_id */ +#include +#include +#include +#include #else -#include +#include #endif #define DN_SCHED_RR 3 // XXX Where? diff --git a/freebsd/sys/netinet/ipfw/dn_sched_wf2q.c b/freebsd/sys/netinet/ipfw/dn_sched_wf2q.c index c1e4c21d..330f78e2 100644 --- a/freebsd/sys/netinet/ipfw/dn_sched_wf2q.c +++ b/freebsd/sys/netinet/ipfw/dn_sched_wf2q.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa @@ -32,22 +32,22 @@ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ */ -#include -#include /* ipfw_rule_ref */ -#include /* flow_id */ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ */ +#include +#include /* ipfw_rule_ref */ +#include /* flow_id */ +#include +#include +#include +#include #else -#include +#include #endif #ifndef MAX64 diff --git a/freebsd/sys/netinet/ipfw/ip_dn_glue.c b/freebsd/sys/netinet/ipfw/ip_dn_glue.c index 302c4d29..8c8c3ef8 100644 --- a/freebsd/sys/netinet/ipfw/ip_dn_glue.c +++ b/freebsd/sys/netinet/ipfw/ip_dn_glue.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa @@ -32,31 +32,31 @@ * Binary compatibility support for /sbin/ipfw RELENG_7 and RELENG_8 */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ -#include -#include /* ip_output(), IP_FORWARDING */ -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include +#include /* ip_output(), IP_FORWARDING */ +#include +#include +#include +#include +#include +#include /* FREEBSD7.2 ip_dummynet.h r191715*/ diff --git a/freebsd/sys/netinet/ipfw/ip_dn_io.c b/freebsd/sys/netinet/ipfw/ip_dn_io.c index 7a2c46d4..72f0c354 100644 --- a/freebsd/sys/netinet/ipfw/ip_dn_io.c +++ b/freebsd/sys/netinet/ipfw/ip_dn_io.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2010 Luigi Rizzo, Riccardo Panicucci, Universita` di Pisa @@ -29,40 +29,40 @@ /* * Dummynet portions related to packet handling. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ -#include -#include -#include /* ip_len, ip_off */ -#include /* ip_output(), IP_FORWARDING */ -#include -#include -#include -#include -#include -#include - -#include /* various ether_* routines */ - -#include /* for ip6_input, ip6_output prototypes */ -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include +#include +#include /* ip_len, ip_off */ +#include /* ip_output(), IP_FORWARDING */ +#include +#include +#include +#include +#include +#include + +#include /* various ether_* routines */ + +#include /* for ip6_input, ip6_output prototypes */ +#include /* * We keep a private variable for the simulation time, but we could diff --git a/freebsd/sys/netinet/ipfw/ip_dummynet.c b/freebsd/sys/netinet/ipfw/ip_dummynet.c index dca39d06..5d51c30b 100644 --- a/freebsd/sys/netinet/ipfw/ip_dummynet.c +++ b/freebsd/sys/netinet/ipfw/ip_dummynet.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998-2002,2010 Luigi Rizzo, Universita` di Pisa @@ -27,38 +27,38 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* * Configuration and internal object management for dummynet. */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ -#include -#include /* ip_output(), IP_FORWARDING */ -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include +#include /* ip_output(), IP_FORWARDING */ +#include +#include +#include +#include +#include +#include /* which objects to copy */ #define DN_C_LINK 0x01 diff --git a/freebsd/sys/netinet/ipfw/ip_fw2.c b/freebsd/sys/netinet/ipfw/ip_fw2.c index 682cced1..dd0c2fea 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw2.c +++ b/freebsd/sys/netinet/ipfw/ip_fw2.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -33,67 +33,67 @@ __FBSDID("$FreeBSD$"); */ #if !defined(KLD_MODULE) -#include -#include -#include -#include +#include +#include +#include +#include #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for ETHERTYPE_IP */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for ETHERTYPE_IP */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include /* XXX for in_cksum */ +#include /* XXX for in_cksum */ #ifdef MAC -#include +#include #endif /* diff --git a/freebsd/sys/netinet/ipfw/ip_fw_log.c b/freebsd/sys/netinet/ipfw/ip_fw_log.c index 0a5cd94c..b529b9e1 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw_log.c +++ b/freebsd/sys/netinet/ipfw/ip_fw_log.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -33,47 +33,47 @@ __FBSDID("$FreeBSD$"); */ #if !defined(KLD_MODULE) -#include -#include -#include -#include +#include +#include +#include +#include #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include /* for ETHERTYPE_IP */ -#include -#include -#include /* for IFT_ETHER */ -#include /* for BPF */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include /* for ETHERTYPE_IP */ +#include +#include +#include /* for IFT_ETHER */ +#include /* for BPF */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifdef INET6 -#include /* ip6_sprintf() */ +#include /* ip6_sprintf() */ #endif #ifdef MAC -#include +#include #endif /* diff --git a/freebsd/sys/netinet/ipfw/ip_fw_nat.c b/freebsd/sys/netinet/ipfw/ip_fw_nat.c index e6c8bcec..dd47dedc 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw_nat.c +++ b/freebsd/sys/netinet/ipfw/ip_fw_nat.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 Paolo Pisati @@ -26,33 +26,33 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define IPFW_INTERNAL /* Access to protected data structures in ip_fw.h. */ -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include /* XXX for in_cksum */ +#include /* XXX for in_cksum */ static VNET_DEFINE(eventhandler_tag, ifaddr_event_tag); #define V_ifaddr_event_tag VNET(ifaddr_event_tag) diff --git a/freebsd/sys/netinet/ipfw/ip_fw_pfil.c b/freebsd/sys/netinet/ipfw/ip_fw_pfil.c index 8759f409..b32a08b7 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw_pfil.c +++ b/freebsd/sys/netinet/ipfw/ip_fw_pfil.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004 Andre Oppermann, Internet Business Solutions AG @@ -26,44 +26,44 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #if !defined(KLD_MODULE) -#include -#include -#include +#include +#include +#include #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif /* KLD_MODULE */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include static VNET_DEFINE(int, fw_enable) = 1; #define V_fw_enable VNET(fw_enable) diff --git a/freebsd/sys/netinet/ipfw/ip_fw_sockopt.c b/freebsd/sys/netinet/ipfw/ip_fw_sockopt.c index 6af09905..b9635416 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw_sockopt.c +++ b/freebsd/sys/netinet/ipfw/ip_fw_sockopt.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -36,41 +36,41 @@ __FBSDID("$FreeBSD$"); */ #if !defined(KLD_MODULE) -#include -#include -#include -#include +#include +#include +#include +#include #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif -#include -#include - -#include -#include -#include -#include /* struct m_tag used by nested headers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include /* hooks */ -#include -#include +#include +#include + +#include +#include +#include +#include /* struct m_tag used by nested headers */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include /* hooks */ +#include +#include #ifdef MAC -#include +#include #endif MALLOC_DEFINE(M_IPFW, "IpFw/IpAcct", "IpFw/IpAcct chain's"); diff --git a/freebsd/sys/netinet/ipfw/ip_fw_table.c b/freebsd/sys/netinet/ipfw/ip_fw_table.c index 39a1dfcc..a399a7a0 100644 --- a/freebsd/sys/netinet/ipfw/ip_fw_table.c +++ b/freebsd/sys/netinet/ipfw/ip_fw_table.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2004 Ruslan Ermilov and Vsevolod Lobko. @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -42,37 +42,37 @@ __FBSDID("$FreeBSD$"); */ #if !defined(KLD_MODULE) -#include -#include -#include -#include +#include +#include +#include +#include #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include /* ip_fw.h requires IFNAMSIZ */ -#include -#include -#include - -#include -#include /* struct ipfw_rule_ref */ -#include -#include /* LIST_HEAD */ -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include /* ip_fw.h requires IFNAMSIZ */ +#include +#include +#include + +#include +#include /* struct ipfw_rule_ref */ +#include +#include /* LIST_HEAD */ +#include #ifdef MAC -#include +#include #endif MALLOC_DEFINE(M_IPFW_TBL, "ipfw_tbl", "IpFw tables"); diff --git a/freebsd/sys/netinet/libalias/alias.c b/freebsd/sys/netinet/libalias/alias.c index e5c5138d..9a8d29bd 100644 --- a/freebsd/sys/netinet/libalias/alias.c +++ b/freebsd/sys/netinet/libalias/alias.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -114,36 +114,36 @@ __FBSDID("$FreeBSD$"); */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif /* diff --git a/freebsd/sys/netinet/libalias/alias.h b/freebsd/sys/netinet/libalias/alias.h index f835e1b7..2aed8293 100644 --- a/freebsd/sys/netinet/libalias/alias.h +++ b/freebsd/sys/netinet/libalias/alias.h @@ -36,12 +36,12 @@ * distribution. */ -#ifndef _ALIAS_HH_ -#define _ALIAS_HH_ +#ifndef _ALIAS_H_ +#define _ALIAS_H_ -#include -#include -#include +#include +#include +#include #define LIBALIAS_BUF_SIZE 128 #ifdef _KERNEL @@ -227,6 +227,6 @@ struct mbuf *m_megapullup(struct mbuf *, int); #define PKT_ALIAS_UNRESOLVED_FRAGMENT 3 #define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4 -#endif /* !_ALIAS_HH_ */ +#endif /* !_ALIAS_H_ */ /* lint -restore */ diff --git a/freebsd/sys/netinet/libalias/alias_cuseeme.c b/freebsd/sys/netinet/libalias/alias_cuseeme.c index 90f2aaae..0e04c3f4 100644 --- a/freebsd/sys/netinet/libalias/alias_cuseeme.c +++ b/freebsd/sys/netinet/libalias/alias_cuseeme.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1998 Brian Somers @@ -28,31 +28,31 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include +#include +#include #endif #define CUSEEME_PORT_NUMBER 7648 diff --git a/freebsd/sys/netinet/libalias/alias_db.c b/freebsd/sys/netinet/libalias/alias_db.c index 4b003366..35b1846b 100644 --- a/freebsd/sys/netinet/libalias/alias_db.c +++ b/freebsd/sys/netinet/libalias/alias_db.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -145,34 +145,34 @@ __FBSDID("$FreeBSD$"); */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif -#include -#include +#include +#include #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif static LIST_HEAD(, libalias) instancehead = LIST_HEAD_INITIALIZER(instancehead); @@ -2646,10 +2646,10 @@ LibAliasCheckNewLink(struct libalias *la) ****************/ /* Firewall include files */ -#include -#include -#include -#include +#include +#include +#include +#include /* * helper function, updates the pointer to cmd with the length diff --git a/freebsd/sys/netinet/libalias/alias_dummy.c b/freebsd/sys/netinet/libalias/alias_dummy.c index c5a316d4..d544e6e3 100644 --- a/freebsd/sys/netinet/libalias/alias_dummy.c +++ b/freebsd/sys/netinet/libalias/alias_dummy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2005 Paolo Pisati @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -36,26 +36,26 @@ __FBSDID("$FreeBSD$"); */ #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif static void diff --git a/freebsd/sys/netinet/libalias/alias_ftp.c b/freebsd/sys/netinet/libalias/alias_ftp.c index 4e8b7177..c8a09413 100644 --- a/freebsd/sys/netinet/libalias/alias_ftp.c +++ b/freebsd/sys/netinet/libalias/alias_ftp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -72,31 +72,31 @@ __FBSDID("$FreeBSD$"); /* Includes */ #ifdef _KERNEL -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include +#include +#include #endif #define FTP_CONTROL_PORT_NUMBER 21 diff --git a/freebsd/sys/netinet/libalias/alias_irc.c b/freebsd/sys/netinet/libalias/alias_irc.c index 05db0f4f..084301be 100644 --- a/freebsd/sys/netinet/libalias/alias_irc.c +++ b/freebsd/sys/netinet/libalias/alias_irc.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* Alias_irc.c intercepts packages contain IRC CTCP commands, and @@ -51,34 +51,34 @@ __FBSDID("$FreeBSD$"); /* Includes */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include +#include +#include #endif #define IRC_CONTROL_PORT_NUMBER_1 6667 diff --git a/freebsd/sys/netinet/libalias/alias_local.h b/freebsd/sys/netinet/libalias/alias_local.h index e24ece49..68839da3 100644 --- a/freebsd/sys/netinet/libalias/alias_local.h +++ b/freebsd/sys/netinet/libalias/alias_local.h @@ -43,24 +43,24 @@ * */ -#ifndef _ALIAS_LOCAL_HH_ -#define _ALIAS_LOCAL_HH_ +#ifndef _ALIAS_LOCAL_H_ +#define _ALIAS_LOCAL_H_ -#include -#include +#include +#include #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include /* XXX: LibAliasSetTarget() uses this constant. */ #define INADDR_NONE 0xffffffff -#include +#include #else -#include +#include #endif /* Sizes of input and output link tables */ @@ -368,7 +368,7 @@ enum alias_tcp_state { ALIAS_TCP_STATE_DISCONNECTED }; -#if defined(_NETINET_IP_HH_) +#if defined(_NETINET_IP_H_) static __inline void * ip_next(struct ip *iphdr) { @@ -377,7 +377,7 @@ ip_next(struct ip *iphdr) } #endif -#if defined(_NETINET_TCP_HH_) +#if defined(_NETINET_TCP_H_) static __inline void * tcp_next(struct tcphdr *tcphdr) { @@ -386,7 +386,7 @@ tcp_next(struct tcphdr *tcphdr) } #endif -#if defined(_NETINET_UDP_HH_) +#if defined(_NETINET_UDP_H_) static __inline void * udp_next(struct udphdr *udphdr) { @@ -394,4 +394,4 @@ udp_next(struct udphdr *udphdr) } #endif -#endif /* !_ALIAS_LOCAL_HH_ */ +#endif /* !_ALIAS_LOCAL_H_ */ diff --git a/freebsd/sys/netinet/libalias/alias_mod.c b/freebsd/sys/netinet/libalias/alias_mod.c index fa15b2e4..cb567473 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.c +++ b/freebsd/sys/netinet/libalias/alias_mod.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2005 Paolo Pisati @@ -26,31 +26,31 @@ * SUCH DAMAGE. * */ -#include +#include __FBSDID("$FreeBSD$"); #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif /* Protocol and userland module handlers chains. */ diff --git a/freebsd/sys/netinet/libalias/alias_mod.h b/freebsd/sys/netinet/libalias/alias_mod.h index f5f98cc3..995f61ac 100644 --- a/freebsd/sys/netinet/libalias/alias_mod.h +++ b/freebsd/sys/netinet/libalias/alias_mod.h @@ -31,14 +31,14 @@ * modular framework */ -#ifndef _ALIAS_MOD_HH_ -#define _ALIAS_MOD_HH_ +#ifndef _ALIAS_MOD_H_ +#define _ALIAS_MOD_H_ #ifdef _KERNEL MALLOC_DECLARE(M_ALIAS); /* Use kernel allocator. */ -#if defined(_SYS_MALLOC_HH_) +#if defined(_SYS_MALLOC_H_) #ifndef __rtems__ #define malloc(x) malloc(x, M_ALIAS, M_NOWAIT|M_ZERO) #define calloc(x, n) malloc(x*n) @@ -160,4 +160,4 @@ typedef struct moduledata { } moduledata_t; #endif -#endif /* !_ALIAS_MOD_HH_ */ +#endif /* !_ALIAS_MOD_H_ */ diff --git a/freebsd/sys/netinet/libalias/alias_nbt.c b/freebsd/sys/netinet/libalias/alias_nbt.c index 31ee0006..f4ae9af7 100644 --- a/freebsd/sys/netinet/libalias/alias_nbt.c +++ b/freebsd/sys/netinet/libalias/alias_nbt.c @@ -1,4 +1,4 @@ -#include +#include /*- * Written by Atsushi Murai @@ -30,7 +30,7 @@ * oConsidering for word alignment for other platform. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -44,28 +44,28 @@ __FBSDID("$FreeBSD$"); /* Includes */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif #define NETBIOS_NS_PORT_NUMBER 137 diff --git a/freebsd/sys/netinet/libalias/alias_pptp.c b/freebsd/sys/netinet/libalias/alias_pptp.c index f6c7f199..61f89392 100644 --- a/freebsd/sys/netinet/libalias/alias_pptp.c +++ b/freebsd/sys/netinet/libalias/alias_pptp.c @@ -1,4 +1,4 @@ -#include +#include /* * alias_pptp.c @@ -38,32 +38,32 @@ * Author: Erik Salander */ -#include +#include __FBSDID("$FreeBSD$"); /* Includes */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif #define PPTP_CONTROL_PORT_NUMBER 1723 diff --git a/freebsd/sys/netinet/libalias/alias_proxy.c b/freebsd/sys/netinet/libalias/alias_proxy.c index f4f2b643..cbd4b99b 100644 --- a/freebsd/sys/netinet/libalias/alias_proxy.c +++ b/freebsd/sys/netinet/libalias/alias_proxy.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* file: alias_proxy.c @@ -57,29 +57,29 @@ __FBSDID("$FreeBSD$"); /* System includes */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif -#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include /* Public API functions for libalias */ -#include /* Functions used by alias*.c */ +#include +#include /* Public API functions for libalias */ +#include /* Functions used by alias*.c */ #endif /* diff --git a/freebsd/sys/netinet/libalias/alias_sctp.c b/freebsd/sys/netinet/libalias/alias_sctp.c index cdec258c..fed592f0 100644 --- a/freebsd/sys/netinet/libalias/alias_sctp.c +++ b/freebsd/sys/netinet/libalias/alias_sctp.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2008 @@ -73,24 +73,24 @@ /* $FreeBSD$ */ #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #else -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #endif //#ifdef _KERNEL /* ---------------------------------------------------------------------- @@ -185,11 +185,11 @@ void SctpShowAliasStats(struct libalias *la); MALLOC_DEFINE(M_SCTPNAT, "sctpnat", "sctp nat dbs"); /* Use kernel allocator. */ -#ifdef _SYS_MALLOC_HH_ +#ifdef _SYS_MALLOC_H_ #define sn_malloc(x) malloc(x, M_SCTPNAT, M_NOWAIT|M_ZERO) #define sn_calloc(n,x) sn_malloc(x * n) #define sn_free(x) free(x, M_SCTPNAT) -#endif// #ifdef _SYS_MALLOC_HH_ +#endif// #ifdef _SYS_MALLOC_H_ #else //#ifdef _KERNEL #define sn_malloc(x) malloc(x) diff --git a/freebsd/sys/netinet/libalias/alias_sctp.h b/freebsd/sys/netinet/libalias/alias_sctp.h index 9ea21959..b6ad6f17 100644 --- a/freebsd/sys/netinet/libalias/alias_sctp.h +++ b/freebsd/sys/netinet/libalias/alias_sctp.h @@ -47,36 +47,36 @@ /* $FreeBSD$ */ -#ifndef _ALIAS_SCTP_HH_ -#define _ALIAS_SCTP_HH_ +#ifndef _ALIAS_SCTP_H_ +#define _ALIAS_SCTP_H_ -#include +#include #ifdef _KERNEL -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif // #ifdef _KERNEL -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include /** * These are defined in sctp_os_bsd.h, but it can't be included due to its local file * inclusion, so I'm defining them here. * */ -#include -#include +#include +#include /* The packed define for 64 bit platforms */ #ifndef SCTP_PACKED #define SCTP_PACKED __attribute__((packed)) @@ -86,14 +86,14 @@ #endif //#ifndef SCTP_UNUSED -#include -//#include --might be needed later for mbuf stuff -#include +#include +//#include --might be needed later for mbuf stuff +#include #ifndef _KERNEL -#include -#include -#include +#include +#include +#include #endif //#ifdef _KERNEL diff --git a/freebsd/sys/netinet/libalias/alias_skinny.c b/freebsd/sys/netinet/libalias/alias_skinny.c index 4d311efe..d472d307 100644 --- a/freebsd/sys/netinet/libalias/alias_skinny.c +++ b/freebsd/sys/netinet/libalias/alias_skinny.c @@ -1,4 +1,4 @@ -#include +#include /*- * alias_skinny.c @@ -33,26 +33,26 @@ */ #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif static void diff --git a/freebsd/sys/netinet/libalias/alias_smedia.c b/freebsd/sys/netinet/libalias/alias_smedia.c index 3d558a94..eed1c49f 100644 --- a/freebsd/sys/netinet/libalias/alias_smedia.c +++ b/freebsd/sys/netinet/libalias/alias_smedia.c @@ -1,4 +1,4 @@ -#include +#include /* * alias_smedia.c @@ -65,7 +65,7 @@ * */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -101,29 +101,29 @@ __FBSDID("$FreeBSD$"); */ #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #else -#include -#include +#include +#include #endif #define RTSP_CONTROL_PORT_NUMBER_1 554 diff --git a/freebsd/sys/netinet/libalias/alias_util.c b/freebsd/sys/netinet/libalias/alias_util.c index 1e0c95ae..066146c8 100644 --- a/freebsd/sys/netinet/libalias/alias_util.c +++ b/freebsd/sys/netinet/libalias/alias_util.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 Charles Mott @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); @@ -46,24 +46,24 @@ __FBSDID("$FreeBSD$"); */ #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #else -#include -#include +#include +#include #endif /* diff --git a/freebsd/sys/netinet/pim.h b/freebsd/sys/netinet/pim.h index 2f887cc2..2b52a447 100644 --- a/freebsd/sys/netinet/pim.h +++ b/freebsd/sys/netinet/pim.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_PIM_HH_ -#define _NETINET_PIM_HH_ +#ifndef _NETINET_PIM_H_ +#define _NETINET_PIM_H_ /* * Protocol Independent Multicast (PIM) definitions. @@ -42,7 +42,7 @@ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000. */ -#include +#include #ifndef _PIM_VT #ifndef BYTE_ORDER @@ -116,4 +116,4 @@ struct pim { {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}} -#endif /* _NETINET_PIM_HH_ */ +#endif /* _NETINET_PIM_H_ */ diff --git a/freebsd/sys/netinet/pim_var.h b/freebsd/sys/netinet/pim_var.h index 9d80bbb2..41657b61 100644 --- a/freebsd/sys/netinet/pim_var.h +++ b/freebsd/sys/netinet/pim_var.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_PIM_VAR_HH_ -#define _NETINET_PIM_VAR_HH_ +#ifndef _NETINET_PIM_VAR_H_ +#define _NETINET_PIM_VAR_H_ /* * Protocol Independent Multicast (PIM), @@ -81,4 +81,4 @@ void pim_input(struct mbuf *, int); SYSCTL_DECL(_net_inet_pim); #endif -#endif /* _NETINET_PIM_VAR_HH_ */ +#endif /* _NETINET_PIM_VAR_H_ */ diff --git a/freebsd/sys/netinet/raw_ip.c b/freebsd/sys/netinet/raw_ip.c index fb90880f..408b529b 100644 --- a/freebsd/sys/netinet/raw_ip.c +++ b/freebsd/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -32,48 +32,48 @@ * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include +#include #endif /*IPSEC*/ -#include +#include VNET_DEFINE(struct inpcbhead, ripcb); VNET_DEFINE(struct inpcbinfo, ripcbinfo); diff --git a/freebsd/sys/netinet/sctp.h b/freebsd/sys/netinet/sctp.h index bf188a23..09e2e465 100644 --- a/freebsd/sys/netinet/sctp.h +++ b/freebsd/sys/netinet/sctp.h @@ -29,13 +29,13 @@ */ /* $KAME: sctp.h,v 1.18 2005/03/06 16:04:16 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#ifndef _NETINET_SCTP_HH_ -#define _NETINET_SCTP_HH_ +#ifndef _NETINET_SCTP_H_ +#define _NETINET_SCTP_H_ -#include +#include #define SCTP_PACKED __attribute__((packed)) @@ -491,7 +491,7 @@ struct sctp_error_unrecognized_chunk { #define SCTP_SMALLEST_PMTU 512 /* smallest pmtu allowed when disabling PMTU * discovery */ -#include +#include /* This dictates the size of the packet * collection buffer. This only applies @@ -546,4 +546,4 @@ struct sctp_error_unrecognized_chunk { #undef SCTP_PACKED -#endif /* !_NETINET_SCTP_HH_ */ +#endif /* !_NETINET_SCTP_H_ */ diff --git a/freebsd/sys/netinet/sctp_asconf.c b/freebsd/sys/netinet/sctp_asconf.c index 206cf600..3c24b75d 100644 --- a/freebsd/sys/netinet/sctp_asconf.c +++ b/freebsd/sys/netinet/sctp_asconf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -32,17 +32,17 @@ /* $KAME: sctp_asconf.c,v 1.24 2005/03/06 16:04:16 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * debug flags: diff --git a/freebsd/sys/netinet/sctp_asconf.h b/freebsd/sys/netinet/sctp_asconf.h index ff8cf378..bf3d5665 100644 --- a/freebsd/sys/netinet/sctp_asconf.h +++ b/freebsd/sys/netinet/sctp_asconf.h @@ -30,11 +30,11 @@ /* $KAME: sctp_asconf.h,v 1.8 2005/03/06 16:04:16 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#ifndef _NETINET_SCTP_ASCONF_HH_ -#define _NETINET_SCTP_ASCONF_HH_ +#ifndef _NETINET_SCTP_ASCONF_H_ +#define _NETINET_SCTP_ASCONF_H_ #if defined(_KERNEL) || defined(__Userspace__) @@ -93,4 +93,4 @@ extern int #endif /* _KERNEL */ -#endif /* !_NETINET_SCTP_ASCONF_HH_ */ +#endif /* !_NETINET_SCTP_ASCONF_H_ */ diff --git a/freebsd/sys/netinet/sctp_auth.c b/freebsd/sys/netinet/sctp_auth.c index 6c2bf908..cf4ebaa9 100644 --- a/freebsd/sys/netinet/sctp_auth.c +++ b/freebsd/sys/netinet/sctp_auth.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -30,19 +30,19 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef SCTP_DEBUG #define SCTP_AUTH_DEBUG (SCTP_BASE_SYSCTL(sctp_debug_on) & SCTP_DEBUG_AUTH1) diff --git a/freebsd/sys/netinet/sctp_auth.h b/freebsd/sys/netinet/sctp_auth.h index da4dc09b..36535357 100644 --- a/freebsd/sys/netinet/sctp_auth.h +++ b/freebsd/sys/netinet/sctp_auth.h @@ -28,7 +28,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __SCTP_AUTH_HH__ diff --git a/freebsd/sys/netinet/sctp_bsd_addr.c b/freebsd/sys/netinet/sctp_bsd_addr.c index 8782e681..8612adc9 100644 --- a/freebsd/sys/netinet/sctp_bsd_addr.c +++ b/freebsd/sys/netinet/sctp_bsd_addr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -32,23 +32,23 @@ /* $KAME: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Declare all of our malloc named types */ MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor"); diff --git a/freebsd/sys/netinet/sctp_bsd_addr.h b/freebsd/sys/netinet/sctp_bsd_addr.h index 67d65dc6..ae2fa525 100644 --- a/freebsd/sys/netinet/sctp_bsd_addr.h +++ b/freebsd/sys/netinet/sctp_bsd_addr.h @@ -28,12 +28,12 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_bsd_addr_h__ #define __sctp_bsd_addr_h__ -#include +#include #if defined(_KERNEL) || defined(__Userspace__) diff --git a/freebsd/sys/netinet/sctp_cc_functions.c b/freebsd/sys/netinet/sctp_cc_functions.c index 668fd673..e0f8beae 100644 --- a/freebsd/sys/netinet/sctp_cc_functions.c +++ b/freebsd/sys/netinet/sctp_cc_functions.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -30,21 +30,21 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include __FBSDID("$FreeBSD$"); void diff --git a/freebsd/sys/netinet/sctp_cc_functions.h b/freebsd/sys/netinet/sctp_cc_functions.h index 3b95d7de..1a681ada 100644 --- a/freebsd/sys/netinet/sctp_cc_functions.h +++ b/freebsd/sys/netinet/sctp_cc_functions.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_cc_functions_h__ diff --git a/freebsd/sys/netinet/sctp_constants.h b/freebsd/sys/netinet/sctp_constants.h index c4f4be23..212a2f9e 100644 --- a/freebsd/sys/netinet/sctp_constants.h +++ b/freebsd/sys/netinet/sctp_constants.h @@ -30,7 +30,7 @@ /* $KAME: sctp_constants.h,v 1.17 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_constants_h__ diff --git a/freebsd/sys/netinet/sctp_crc32.c b/freebsd/sys/netinet/sctp_crc32.c index aa4c08cf..3d07f505 100644 --- a/freebsd/sys/netinet/sctp_crc32.c +++ b/freebsd/sys/netinet/sctp_crc32.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -33,13 +33,13 @@ /* $KAME: sctp_crc32.c,v 1.12 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include #if !defined(SCTP_WITH_NO_CSUM) diff --git a/freebsd/sys/netinet/sctp_crc32.h b/freebsd/sys/netinet/sctp_crc32.h index 768b25d5..eb7a1bc7 100644 --- a/freebsd/sys/netinet/sctp_crc32.h +++ b/freebsd/sys/netinet/sctp_crc32.h @@ -30,7 +30,7 @@ /* $KAME: sctp_crc32.h,v 1.5 2004/08/17 04:06:16 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __crc32c_h__ diff --git a/freebsd/sys/netinet/sctp_header.h b/freebsd/sys/netinet/sctp_header.h index 141bfcda..980845dc 100644 --- a/freebsd/sys/netinet/sctp_header.h +++ b/freebsd/sys/netinet/sctp_header.h @@ -30,15 +30,15 @@ /* $KAME: sctp_header.h,v 1.14 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_header_h__ #define __sctp_header_h__ -#include -#include -#include +#include +#include +#include #define SCTP_PACKED __attribute__((packed)) diff --git a/freebsd/sys/netinet/sctp_indata.c b/freebsd/sys/netinet/sctp_indata.c index 963b3205..082e43b8 100644 --- a/freebsd/sys/netinet/sctp_indata.c +++ b/freebsd/sys/netinet/sctp_indata.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -32,20 +32,20 @@ /* $KAME: sctp_indata.c,v 1.36 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* diff --git a/freebsd/sys/netinet/sctp_indata.h b/freebsd/sys/netinet/sctp_indata.h index a231ecaf..79978a5c 100644 --- a/freebsd/sys/netinet/sctp_indata.h +++ b/freebsd/sys/netinet/sctp_indata.h @@ -30,7 +30,7 @@ /* $KAME: sctp_indata.h,v 1.9 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_indata_h__ diff --git a/freebsd/sys/netinet/sctp_input.c b/freebsd/sys/netinet/sctp_input.c index 080813b4..965bec86 100644 --- a/freebsd/sys/netinet/sctp_input.c +++ b/freebsd/sys/netinet/sctp_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -32,24 +32,24 @@ /* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/freebsd/sys/netinet/sctp_input.h b/freebsd/sys/netinet/sctp_input.h index 90cd098a..39f64207 100644 --- a/freebsd/sys/netinet/sctp_input.h +++ b/freebsd/sys/netinet/sctp_input.h @@ -30,7 +30,7 @@ /* $KAME: sctp_input.h,v 1.6 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_input_h__ diff --git a/freebsd/sys/netinet/sctp_lock_bsd.h b/freebsd/sys/netinet/sctp_lock_bsd.h index 81e4a35f..dd9c2ce5 100644 --- a/freebsd/sys/netinet/sctp_lock_bsd.h +++ b/freebsd/sys/netinet/sctp_lock_bsd.h @@ -68,7 +68,7 @@ * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to * the SCTP_BASE_INFO() list's we will do a SCTP_INP_INFO_WLOCK(). */ -#include +#include __FBSDID("$FreeBSD$"); diff --git a/freebsd/sys/netinet/sctp_os.h b/freebsd/sys/netinet/sctp_os.h index c1a392f0..fb7c5360 100644 --- a/freebsd/sys/netinet/sctp_os.h +++ b/freebsd/sys/netinet/sctp_os.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_os_h__ #define __sctp_os_h__ @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); * SCTP_ZONE_DESTROY(zone) */ -#include +#include diff --git a/freebsd/sys/netinet/sctp_os_bsd.h b/freebsd/sys/netinet/sctp_os_bsd.h index cf29776f..991daca2 100644 --- a/freebsd/sys/netinet/sctp_os_bsd.h +++ b/freebsd/sys/netinet/sctp_os_bsd.h @@ -27,78 +27,78 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_os_bsd_h__ #define __sctp_os_bsd_h__ /* * includes */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC */ #ifdef INET6 -#include +#include #ifdef IPSEC -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif /* INET6 */ -#include +#include #ifndef in6pcb #define in6pcb inpcb @@ -249,7 +249,7 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT); /* * zone allocation functions */ -#include +#include /* SCTP_ZONE_INIT: initialize the zone */ typedef struct uma_zone *sctp_zone_t; @@ -278,7 +278,7 @@ typedef struct uma_zone *sctp_zone_t; /* * timers */ -#include +#include typedef struct callout sctp_os_timer_t; @@ -466,9 +466,9 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, #define SCTP_READ_RANDOM(buf, len) read_random(buf, len) #ifdef USE_SCTP_SHA1 -#include +#include #else -#include +#include /* map standard crypto API names */ #define SHA1_Init SHA1Init #define SHA1_Update SHA1Update @@ -476,7 +476,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, #endif #if defined(HAVE_SHA2) -#include +#include #endif #endif diff --git a/freebsd/sys/netinet/sctp_output.c b/freebsd/sys/netinet/sctp_output.c index 9acd3288..648a87a2 100644 --- a/freebsd/sys/netinet/sctp_output.c +++ b/freebsd/sys/netinet/sctp_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -32,28 +32,28 @@ /* $KAME: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/freebsd/sys/netinet/sctp_output.h b/freebsd/sys/netinet/sctp_output.h index d9051ee7..d655c3aa 100644 --- a/freebsd/sys/netinet/sctp_output.h +++ b/freebsd/sys/netinet/sctp_output.h @@ -30,13 +30,13 @@ /* $KAME: sctp_output.h,v 1.14 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_output_h__ #define __sctp_output_h__ -#include +#include #if defined(_KERNEL) || defined(__Userspace__) diff --git a/freebsd/sys/netinet/sctp_pcb.c b/freebsd/sys/netinet/sctp_pcb.c index fccbda00..98c5b707 100644 --- a/freebsd/sys/netinet/sctp_pcb.c +++ b/freebsd/sys/netinet/sctp_pcb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -32,22 +32,22 @@ /* $KAME: sctp_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include VNET_DEFINE(struct sctp_base_info, system_base_info); diff --git a/freebsd/sys/netinet/sctp_pcb.h b/freebsd/sys/netinet/sctp_pcb.h index a4f4d30c..23ebc4f1 100644 --- a/freebsd/sys/netinet/sctp_pcb.h +++ b/freebsd/sys/netinet/sctp_pcb.h @@ -30,16 +30,16 @@ /* $KAME: sctp_pcb.h,v 1.21 2005/07/16 01:18:47 suz Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_pcb_h__ #define __sctp_pcb_h__ -#include -#include -#include -#include +#include +#include +#include +#include LIST_HEAD(sctppcbhead, sctp_inpcb); LIST_HEAD(sctpasochead, sctp_tcb); @@ -51,8 +51,8 @@ LIST_HEAD(sctp_ifalist, sctp_ifa); TAILQ_HEAD(sctp_readhead, sctp_queued_to_read); TAILQ_HEAD(sctp_streamhead, sctp_stream_queue_pending); -#include -#include +#include +#include #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask) #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask) @@ -450,7 +450,7 @@ struct sctp_tcb { -#include +#include /* TODO where to put non-_KERNEL things for __Userspace__? */ diff --git a/freebsd/sys/netinet/sctp_peeloff.c b/freebsd/sys/netinet/sctp_peeloff.c index 7b859bba..bc5f8a4f 100644 --- a/freebsd/sys/netinet/sctp_peeloff.c +++ b/freebsd/sys/netinet/sctp_peeloff.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -33,19 +33,19 @@ /* $KAME: sctp_peeloff.c,v 1.13 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include int diff --git a/freebsd/sys/netinet/sctp_peeloff.h b/freebsd/sys/netinet/sctp_peeloff.h index 57fd5fef..db61db3b 100644 --- a/freebsd/sys/netinet/sctp_peeloff.h +++ b/freebsd/sys/netinet/sctp_peeloff.h @@ -30,7 +30,7 @@ /* $KAME: sctp_peeloff.h,v 1.6 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_peeloff_h__ diff --git a/freebsd/sys/netinet/sctp_structs.h b/freebsd/sys/netinet/sctp_structs.h index 2050c581..94d0395c 100644 --- a/freebsd/sys/netinet/sctp_structs.h +++ b/freebsd/sys/netinet/sctp_structs.h @@ -30,15 +30,15 @@ /* $KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_structs_h__ #define __sctp_structs_h__ -#include -#include -#include +#include +#include +#include struct sctp_timer { sctp_os_timer_t timer; diff --git a/freebsd/sys/netinet/sctp_sysctl.c b/freebsd/sys/netinet/sctp_sysctl.c index b5700e4e..6fcf4964 100644 --- a/freebsd/sys/netinet/sctp_sysctl.c +++ b/freebsd/sys/netinet/sctp_sysctl.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. @@ -30,17 +30,17 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /* * sysctl tunable variables diff --git a/freebsd/sys/netinet/sctp_sysctl.h b/freebsd/sys/netinet/sctp_sysctl.h index 5f7f270d..9dbc9ed2 100644 --- a/freebsd/sys/netinet/sctp_sysctl.h +++ b/freebsd/sys/netinet/sctp_sysctl.h @@ -28,14 +28,14 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_sysctl_h__ #define __sctp_sysctl_h__ -#include -#include +#include +#include struct sctp_sysctl { uint32_t sctp_sendspace; diff --git a/freebsd/sys/netinet/sctp_timer.c b/freebsd/sys/netinet/sctp_timer.c index 090689b1..4fbded33 100644 --- a/freebsd/sys/netinet/sctp_timer.c +++ b/freebsd/sys/netinet/sctp_timer.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -32,26 +32,26 @@ /* $KAME: sctp_timer.c,v 1.29 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #define _IP_VHL -#include -#include +#include +#include #ifdef INET6 #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include void diff --git a/freebsd/sys/netinet/sctp_timer.h b/freebsd/sys/netinet/sctp_timer.h index 34abbace..a26ad728 100644 --- a/freebsd/sys/netinet/sctp_timer.h +++ b/freebsd/sys/netinet/sctp_timer.h @@ -29,7 +29,7 @@ */ /* $KAME: sctp_timer.h,v 1.6 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_timer_h__ diff --git a/freebsd/sys/netinet/sctp_uio.h b/freebsd/sys/netinet/sctp_uio.h index 734447ed..4d72b1ca 100644 --- a/freebsd/sys/netinet/sctp_uio.h +++ b/freebsd/sys/netinet/sctp_uio.h @@ -29,7 +29,7 @@ */ /* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctp_uio_h__ @@ -37,11 +37,11 @@ __FBSDID("$FreeBSD$"); #if ! defined(_KERNEL) -#include +#include #endif -#include -#include -#include +#include +#include +#include typedef uint32_t sctp_assoc_t; @@ -999,12 +999,12 @@ union sctp_sockstore { /***********************************/ #ifndef ntohll -#include +#include #define ntohll(x) be64toh(x) #endif #ifndef htonll -#include +#include #define htonll(x) htobe64(x) #endif /***********************************/ diff --git a/freebsd/sys/netinet/sctp_usrreq.c b/freebsd/sys/netinet/sctp_usrreq.c index bb60795c..e901cf97 100644 --- a/freebsd/sys/netinet/sctp_usrreq.c +++ b/freebsd/sys/netinet/sctp_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -32,26 +32,26 @@ /* $KAME: sctp_usrreq.c,v 1.48 2005/03/07 23:26:08 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #if defined(INET6) #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/freebsd/sys/netinet/sctp_var.h b/freebsd/sys/netinet/sctp_var.h index 93b92038..bff7f5de 100644 --- a/freebsd/sys/netinet/sctp_var.h +++ b/freebsd/sys/netinet/sctp_var.h @@ -30,13 +30,13 @@ /* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#ifndef _NETINET_SCTP_VAR_HH_ -#define _NETINET_SCTP_VAR_HH_ +#ifndef _NETINET_SCTP_VAR_H_ +#define _NETINET_SCTP_VAR_H_ -#include +#include #if defined(_KERNEL) || defined(__Userspace__) @@ -333,4 +333,4 @@ __P((struct sctp_inpcb *, struct ip *ip, struct sctphdr *, #endif /* _KERNEL */ -#endif /* !_NETINET_SCTP_VAR_HH_ */ +#endif /* !_NETINET_SCTP_VAR_H_ */ diff --git a/freebsd/sys/netinet/sctputil.c b/freebsd/sys/netinet/sctputil.c index 7e8ac1ea..e9a279c9 100644 --- a/freebsd/sys/netinet/sctputil.c +++ b/freebsd/sys/netinet/sctputil.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. @@ -32,25 +32,25 @@ /* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef INET6 #endif -#include -#include -#include -#include -#include /* for sctp_deliver_data() */ -#include -#include -#include -#include +#include +#include +#include +#include +#include /* for sctp_deliver_data() */ +#include +#include +#include +#include #ifndef KTR_SCTP @@ -6813,11 +6813,11 @@ sctp_log_trace(uint32_t subsys, const char *str SCTP_UNUSED, uint32_t a, uint32_ * so we can do UDP tunneling. In * the mean-time, we return error */ -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif static void diff --git a/freebsd/sys/netinet/sctputil.h b/freebsd/sys/netinet/sctputil.h index b1bee3a4..d109ec23 100644 --- a/freebsd/sys/netinet/sctputil.h +++ b/freebsd/sys/netinet/sctputil.h @@ -31,7 +31,7 @@ /* $KAME: sctputil.h,v 1.15 2005/03/06 16:04:19 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); #ifndef __sctputil_h__ #define __sctputil_h__ diff --git a/freebsd/sys/netinet/tcp.h b/freebsd/sys/netinet/tcp.h index 19b1c57f..8779582a 100644 --- a/freebsd/sys/netinet/tcp.h +++ b/freebsd/sys/netinet/tcp.h @@ -1,2 +1,226 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NETINET_TCP_H_ +#define _NETINET_TCP_H_ + +#include + +#if __BSD_VISIBLE + +typedef u_int32_t tcp_seq; + +#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ +#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ + +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + u_short th_sport; /* source port */ + u_short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#if BYTE_ORDER == LITTLE_ENDIAN + u_int th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + u_int th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + u_char th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 +#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR) +#define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR" + + u_short th_win; /* window */ + u_short th_sum; /* checksum */ + u_short th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOLEN_EOL 1 +#define TCPOPT_PAD 0 /* padding after EOL */ +#define TCPOLEN_PAD 1 +#define TCPOPT_NOP 1 +#define TCPOLEN_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOLEN_MAXSEG 4 +#define TCPOPT_WINDOW 3 +#define TCPOLEN_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOPT_SACK 5 +#define TCPOLEN_SACKHDR 2 +#define TCPOLEN_SACK 8 /* 2*sizeof(tcp_seq) */ +#define TCPOPT_TIMESTAMP 8 +#define TCPOLEN_TIMESTAMP 10 +#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ +#define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */ +#define TCPOLEN_SIGNATURE 18 + +/* Miscellaneous constants */ +#define MAX_SACK_BLKS 6 /* Max # SACK blocks stored at receiver side */ +#define TCP_MAX_SACK 4 /* MAX # SACKs sent in any segment */ + + +/* + * Default maximum segment size for TCP. + * With an IP MTU of 576, this is 536, + * but 512 is probably more convenient. + * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + */ +#define TCP_MSS 512 +/* + * TCP_MINMSS is defined to be 216 which is fine for the smallest + * link MTU (256 bytes, AX.25 packet radio) in the Internet. + * However it is very unlikely to come across such low MTU interfaces + * these days (anno dato 2003). + * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. + * Setting this to "0" disables the minmss check. + */ +#define TCP_MINMSS 216 + +/* + * Default maximum segment size for TCP6. + * With an IP6 MSS of 1280, this is 1220, + * but 1024 is probably more convenient. (xxx kazu in doubt) + * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) + */ +#define TCP6_MSS 1024 + +#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ +#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ + +#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +#define TCP_MAXBURST 4 /* maximum segments in a burst */ + +#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ +#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) + /* max space left for options */ +#endif /* __BSD_VISIBLE */ + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#if __BSD_VISIBLE +#define TCP_MAXSEG 0x02 /* set maximum segment size */ +#define TCP_NOPUSH 0x04 /* don't push last block of write */ +#define TCP_NOOPT 0x08 /* don't use TCP options */ +#define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */ +#define TCP_INFO 0x20 /* retrieve tcp_info structure */ +#define TCP_CONGESTION 0x40 /* get/set congestion control algorithm */ + +#define TCP_CA_NAME_MAX 16 /* max congestion control name length */ + +#define TCPI_OPT_TIMESTAMPS 0x01 +#define TCPI_OPT_SACK 0x02 +#define TCPI_OPT_WSCALE 0x04 +#define TCPI_OPT_ECN 0x08 +#define TCPI_OPT_TOE 0x10 + +/* + * The TCP_INFO socket option comes from the Linux 2.6 TCP API, and permits + * the caller to query certain information about the state of a TCP + * connection. We provide an overlapping set of fields with the Linux + * implementation, but since this is a fixed size structure, room has been + * left for growth. In order to maximize potential future compatibility with + * the Linux API, the same variable names and order have been adopted, and + * padding left to make room for omitted fields in case they are added later. + * + * XXX: This is currently an unstable ABI/API, in that it is expected to + * change. + */ +struct tcp_info { + u_int8_t tcpi_state; /* TCP FSM state. */ + u_int8_t __tcpi_ca_state; + u_int8_t __tcpi_retransmits; + u_int8_t __tcpi_probes; + u_int8_t __tcpi_backoff; + u_int8_t tcpi_options; /* Options enabled on conn. */ + u_int8_t tcpi_snd_wscale:4, /* RFC1323 send shift value. */ + tcpi_rcv_wscale:4; /* RFC1323 recv shift value. */ + + u_int32_t tcpi_rto; /* Retransmission timeout (usec). */ + u_int32_t __tcpi_ato; + u_int32_t tcpi_snd_mss; /* Max segment size for send. */ + u_int32_t tcpi_rcv_mss; /* Max segment size for receive. */ + + u_int32_t __tcpi_unacked; + u_int32_t __tcpi_sacked; + u_int32_t __tcpi_lost; + u_int32_t __tcpi_retrans; + u_int32_t __tcpi_fackets; + + /* Times; measurements in usecs. */ + u_int32_t __tcpi_last_data_sent; + u_int32_t __tcpi_last_ack_sent; /* Also unimpl. on Linux? */ + u_int32_t tcpi_last_data_recv; /* Time since last recv data. */ + u_int32_t __tcpi_last_ack_recv; + + /* Metrics; variable units. */ + u_int32_t __tcpi_pmtu; + u_int32_t __tcpi_rcv_ssthresh; + u_int32_t tcpi_rtt; /* Smoothed RTT in usecs. */ + u_int32_t tcpi_rttvar; /* RTT variance in usecs. */ + u_int32_t tcpi_snd_ssthresh; /* Slow start threshold. */ + u_int32_t tcpi_snd_cwnd; /* Send congestion window. */ + u_int32_t __tcpi_advmss; + u_int32_t __tcpi_reordering; + + u_int32_t __tcpi_rcv_rtt; + u_int32_t tcpi_rcv_space; /* Advertised recv window. */ + + /* FreeBSD extensions to tcp_info. */ + u_int32_t tcpi_snd_wnd; /* Advertised send window. */ + u_int32_t tcpi_snd_bwnd; /* Bandwidth send window. */ + u_int32_t tcpi_snd_nxt; /* Next egress seqno */ + u_int32_t tcpi_rcv_nxt; /* Next ingress seqno */ + u_int32_t tcpi_toe_tid; /* HWTID for TOE endpoints */ + + /* Padding to grow without breaking ABI. */ + u_int32_t __tcpi_pad[29]; /* Padding. */ +}; +#endif + +#endif /* !_NETINET_TCP_H_ */ diff --git a/freebsd/sys/netinet/tcp_debug.c b/freebsd/sys/netinet/tcp_debug.c index 52a82193..5d4b992a 100644 --- a/freebsd/sys/netinet/tcp_debug.c +++ b/freebsd/sys/netinet/tcp_debug.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1993 @@ -32,12 +32,12 @@ * @(#)tcp_debug.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include #ifdef TCPDEBUG /* load symbolic names */ @@ -47,28 +47,28 @@ __FBSDID("$FreeBSD$"); #define TANAMES #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG static int tcpconsdebug = 0; diff --git a/freebsd/sys/netinet/tcp_debug.h b/freebsd/sys/netinet/tcp_debug.h index 0c103958..c4d38da9 100644 --- a/freebsd/sys/netinet/tcp_debug.h +++ b/freebsd/sys/netinet/tcp_debug.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_DEBUG_HH_ -#define _NETINET_TCP_DEBUG_HH_ +#ifndef _NETINET_TCP_DEBUG_H_ +#define _NETINET_TCP_DEBUG_H_ struct tcp_debug { uint32_t td_time; /* network format */ @@ -77,4 +77,4 @@ struct tcp_debug tcp_debug[TCP_NDEBUG]; int tcp_debx; #endif -#endif /* !_NETINET_TCP_DEBUG_HH_ */ +#endif /* !_NETINET_TCP_DEBUG_H_ */ diff --git a/freebsd/sys/netinet/tcp_fsm.h b/freebsd/sys/netinet/tcp_fsm.h index 253e53d4..61fd0c1f 100644 --- a/freebsd/sys/netinet/tcp_fsm.h +++ b/freebsd/sys/netinet/tcp_fsm.h @@ -31,8 +31,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_FSM_HH_ -#define _NETINET_TCP_FSM_HH_ +#ifndef _NETINET_TCP_FSM_H_ +#define _NETINET_TCP_FSM_H_ /* * TCP FSM state definitions. diff --git a/freebsd/sys/netinet/tcp_hostcache.c b/freebsd/sys/netinet/tcp_hostcache.c index 07b78cfe..352df1dd 100644 --- a/freebsd/sys/netinet/tcp_hostcache.c +++ b/freebsd/sys/netinet/tcp_hostcache.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG @@ -64,43 +64,43 @@ * followed here. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include /* Arbitrary values */ #define TCP_HOSTCACHE_HASHSIZE 512 diff --git a/freebsd/sys/netinet/tcp_hostcache.h b/freebsd/sys/netinet/tcp_hostcache.h index a494ed03..8569edcc 100644 --- a/freebsd/sys/netinet/tcp_hostcache.h +++ b/freebsd/sys/netinet/tcp_hostcache.h @@ -34,8 +34,8 @@ * followed here. */ -#ifndef _NETINET_TCP_HOSTCACHE_HH_ -#define _NETINET_TCP_HOSTCACHE_HH_ +#ifndef _NETINET_TCP_HOSTCACHE_H_ +#define _NETINET_TCP_HOSTCACHE_H_ TAILQ_HEAD(hc_qhead, hc_metrics); @@ -79,4 +79,4 @@ struct tcp_hostcache { int purgeall; }; -#endif /* !_NETINET_TCP_HOSTCACHE_HH_*/ +#endif /* !_NETINET_TCP_HOSTCACHE_H_*/ diff --git a/freebsd/sys/netinet/tcp_input.c b/freebsd/sys/netinet/tcp_input.c index 85daf203..8feb571f 100644 --- a/freebsd/sys/netinet/tcp_input.c +++ b/freebsd/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 @@ -31,72 +31,72 @@ * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include /* for ipfw_fwd */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include /* for proc0 declaration */ -#include -#include -#include -#include -#include -#include -#include - -#include /* before tcp_seq.h, for tcp_random18() */ - -#include - -#include -#include -#include +#include /* for ipfw_fwd */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include /* for proc0 declaration */ +#include +#include +#include +#include +#include +#include +#include + +#include /* before tcp_seq.h, for tcp_random18() */ + +#include + +#include +#include +#include #define TCPSTATES /* for logging */ -#include -#include -#include -#include -#include -#include /* required for icmp_var.h */ -#include /* for ICMP_BANDLIM */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* required for icmp_var.h */ +#include /* for ICMP_BANDLIM */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif /* TCPDEBUG */ #ifdef IPSEC -#include -#include +#include +#include #endif /*IPSEC*/ -#include +#include -#include +#include static const int tcprexmtthresh = 3; diff --git a/freebsd/sys/netinet/tcp_lro.c b/freebsd/sys/netinet/tcp_lro.c index 6aaff4a5..bbb98e60 100644 --- a/freebsd/sys/netinet/tcp_lro.c +++ b/freebsd/sys/netinet/tcp_lro.c @@ -1,4 +1,4 @@ -#include +#include /****************************************************************************** @@ -35,25 +35,25 @@ POSSIBILITY OF SUCH DAMAGE. $FreeBSD$ ***************************************************************************/ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include static uint16_t do_csum_data(uint16_t *raw, int len) diff --git a/freebsd/sys/netinet/tcp_lro.h b/freebsd/sys/netinet/tcp_lro.h index 20cfb7cf..08aac690 100644 --- a/freebsd/sys/netinet/tcp_lro.h +++ b/freebsd/sys/netinet/tcp_lro.h @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. $FreeBSD$ ***************************************************************************/ -#ifndef _TCP_LRO_HH_ -#define _TCP_LRO_HH_ +#ifndef _TCP_LRO_H_ +#define _TCP_LRO_H_ struct lro_entry; struct lro_entry @@ -82,4 +82,4 @@ int tcp_lro_rx(struct lro_ctrl *, struct mbuf *, uint32_t); /* Number of LRO entries - these are per rx queue */ #define LRO_ENTRIES 8 -#endif /* _TCP_LRO_HH_ */ +#endif /* _TCP_LRO_H_ */ diff --git a/freebsd/sys/netinet/tcp_offload.c b/freebsd/sys/netinet/tcp_offload.c index 9c73992b..3c663a47 100644 --- a/freebsd/sys/netinet/tcp_offload.c +++ b/freebsd/sys/netinet/tcp_offload.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2007, Chelsio Inc. @@ -27,32 +27,32 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include uint32_t toedev_registration_count; diff --git a/freebsd/sys/netinet/tcp_offload.h b/freebsd/sys/netinet/tcp_offload.h index f2a35a58..48f35ff6 100644 --- a/freebsd/sys/netinet/tcp_offload.h +++ b/freebsd/sys/netinet/tcp_offload.h @@ -27,8 +27,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_OFFLOAD_HH_ -#define _NETINET_TCP_OFFLOAD_HH_ +#ifndef _NETINET_TCP_OFFLOAD_H_ +#define _NETINET_TCP_OFFLOAD_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -247,7 +247,7 @@ int tcp_offload_connect(struct socket *so, struct sockaddr *nam); * hackish way of allowing this file to also be included by TOE * which needs to be kept ignorant of socket implementation details */ -#ifdef _SYS_SOCKETVAR_HH_ +#ifdef _SYS_SOCKETVAR_H_ /* * The socket has not been marked as "do not offload" */ @@ -344,11 +344,11 @@ tcp_offload_listen_close(struct tcpcb *tp) #endif } #undef SO_OFFLOADABLE -#endif /* _SYS_SOCKETVAR_HH_ */ +#endif /* _SYS_SOCKETVAR_H_ */ #undef tp_offload void tcp_offload_twstart(struct tcpcb *tp); struct tcpcb *tcp_offload_close(struct tcpcb *tp); struct tcpcb *tcp_offload_drop(struct tcpcb *tp, int error); -#endif /* _NETINET_TCP_OFFLOAD_HH_ */ +#endif /* _NETINET_TCP_OFFLOAD_H_ */ diff --git a/freebsd/sys/netinet/tcp_output.c b/freebsd/sys/netinet/tcp_output.c index bebab1f1..55a1f6e4 100644 --- a/freebsd/sys/netinet/tcp_output.c +++ b/freebsd/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -31,59 +31,59 @@ * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include +#include #define TCPOUTFLAGS -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif #ifdef IPSEC -#include +#include #endif /*IPSEC*/ -#include +#include -#include +#include #ifdef notyet extern struct mbuf *m_copypack(); diff --git a/freebsd/sys/netinet/tcp_reass.c b/freebsd/sys/netinet/tcp_reass.c index aea58740..64aeca84 100644 --- a/freebsd/sys/netinet/tcp_reass.c +++ b/freebsd/sys/netinet/tcp_reass.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 @@ -31,49 +31,49 @@ * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif /* TCPDEBUG */ static int tcp_reass_sysctl_maxseg(SYSCTL_HANDLER_ARGS); diff --git a/freebsd/sys/netinet/tcp_sack.c b/freebsd/sys/netinet/tcp_sack.c index 94bae57b..7a7df0bb 100644 --- a/freebsd/sys/netinet/tcp_sack.c +++ b/freebsd/sys/netinet/tcp_sack.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 @@ -72,57 +72,57 @@ * Research Laboratory (NRL). */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include /* for proc0 declaration */ -#include -#include -#include -#include -#include - -#include /* before tcp_seq.h, for tcp_random18() */ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include /* for proc0 declaration */ +#include +#include +#include +#include +#include + +#include /* before tcp_seq.h, for tcp_random18() */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif /* TCPDEBUG */ -#include +#include VNET_DECLARE(struct uma_zone *, sack_hole_zone); #define V_sack_hole_zone VNET(sack_hole_zone) diff --git a/freebsd/sys/netinet/tcp_seq.h b/freebsd/sys/netinet/tcp_seq.h index 8af7b0ab..f58b537c 100644 --- a/freebsd/sys/netinet/tcp_seq.h +++ b/freebsd/sys/netinet/tcp_seq.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_SEQ_HH_ -#define _NETINET_TCP_SEQ_HH_ +#ifndef _NETINET_TCP_SEQ_H_ +#define _NETINET_TCP_SEQ_H_ /* * TCP sequence numbers are 32 bit integers operated * on with modular arithmetic. These macros can be @@ -65,4 +65,4 @@ #define TCP_PAWS_IDLE (24 * 24 * 60 * 60 * hz) /* timestamp wrap-around time */ -#endif /* _NETINET_TCP_SEQ_HH_ */ +#endif /* _NETINET_TCP_SEQ_H_ */ diff --git a/freebsd/sys/netinet/tcp_subr.c b/freebsd/sys/netinet/tcp_subr.c index 83777450..55e5806f 100644 --- a/freebsd/sys/netinet/tcp_subr.c +++ b/freebsd/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -31,87 +31,87 @@ * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef TCPDEBUG -#include +#include #endif -#include +#include #ifdef IPSEC -#include -#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #endif /*IPSEC*/ -#include -#include +#include +#include -#include +#include VNET_DEFINE(int, tcp_mssdflt) = TCP_MSS; #ifdef INET6 diff --git a/freebsd/sys/netinet/tcp_syncache.c b/freebsd/sys/netinet/tcp_syncache.c index 78790cc8..04f321ab 100644 --- a/freebsd/sys/netinet/tcp_syncache.c +++ b/freebsd/sys/netinet/tcp_syncache.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001 McAfee, Inc. @@ -32,72 +32,72 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for proc0 declaration */ -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for proc0 declaration */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif #ifdef IPSEC -#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #endif /*IPSEC*/ -#include +#include -#include +#include static VNET_DEFINE(int, tcp_syncookies) = 1; #define V_tcp_syncookies VNET(tcp_syncookies) diff --git a/freebsd/sys/netinet/tcp_syncache.h b/freebsd/sys/netinet/tcp_syncache.h index 96ba1535..93c7aaa2 100644 --- a/freebsd/sys/netinet/tcp_syncache.h +++ b/freebsd/sys/netinet/tcp_syncache.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_SYNCACHE_HH_ -#define _NETINET_TCP_SYNCACHE_HH_ +#ifndef _NETINET_TCP_SYNCACHE_H_ +#define _NETINET_TCP_SYNCACHE_H_ #ifdef _KERNEL struct toeopt; @@ -124,4 +124,4 @@ struct tcp_syncache { }; #endif /* _KERNEL */ -#endif /* !_NETINET_TCP_SYNCACHE_HH_ */ +#endif /* !_NETINET_TCP_SYNCACHE_H_ */ diff --git a/freebsd/sys/netinet/tcp_timer.c b/freebsd/sys/netinet/tcp_timer.c index 36e2bec2..cbf9206f 100644 --- a/freebsd/sys/netinet/tcp_timer.c +++ b/freebsd/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -31,41 +31,41 @@ * @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif int tcp_keepinit; diff --git a/freebsd/sys/netinet/tcp_timer.h b/freebsd/sys/netinet/tcp_timer.h index 1514a293..ff455b6b 100644 --- a/freebsd/sys/netinet/tcp_timer.h +++ b/freebsd/sys/netinet/tcp_timer.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_TIMER_HH_ -#define _NETINET_TCP_TIMER_HH_ +#ifndef _NETINET_TCP_TIMER_H_ +#define _NETINET_TCP_TIMER_H_ /* * The TCPT_REXMT timer is used to force retransmissions. @@ -180,4 +180,4 @@ void tcp_timer_delack(void *xtp); #endif /* _KERNEL */ -#endif /* !_NETINET_TCP_TIMER_HH_ */ +#endif /* !_NETINET_TCP_TIMER_H_ */ diff --git a/freebsd/sys/netinet/tcp_timewait.c b/freebsd/sys/netinet/tcp_timewait.c index 92643d0a..de321e3f 100644 --- a/freebsd/sys/netinet/tcp_timewait.c +++ b/freebsd/sys/netinet/tcp_timewait.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -31,68 +31,68 @@ * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef TCPDEBUG -#include +#include #endif -#include +#include -#include +#include -#include +#include static VNET_DEFINE(uma_zone_t, tcptw_zone); #define V_tcptw_zone VNET(tcptw_zone) diff --git a/freebsd/sys/netinet/tcp_usrreq.c b/freebsd/sys/netinet/tcp_usrreq.c index fc083e05..3d803987 100644 --- a/freebsd/sys/netinet/tcp_usrreq.c +++ b/freebsd/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -33,62 +33,62 @@ * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif /* INET6 */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef DDB -#include +#include #endif -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef TCPDEBUG -#include +#include #endif -#include +#include /* * TCP protocol interface to socket abstraction. diff --git a/freebsd/sys/netinet/tcp_var.h b/freebsd/sys/netinet/tcp_var.h index 77586144..9de0ca89 100644 --- a/freebsd/sys/netinet/tcp_var.h +++ b/freebsd/sys/netinet/tcp_var.h @@ -30,13 +30,13 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_VAR_HH_ -#define _NETINET_TCP_VAR_HH_ +#ifndef _NETINET_TCP_VAR_H_ +#define _NETINET_TCP_VAR_H_ -#include +#include #ifdef _KERNEL -#include +#include /* * Kernel variables for tcp. @@ -298,9 +298,9 @@ struct hc_metrics_lite { /* must stay in sync with hc_metrics */ u_long rmx_recvpipe; /* inbound delay-bandwidth product */ }; -#ifndef _NETINET_IN_PCB_HH_ +#ifndef _NETINET_IN_PCB_H_ struct in_conninfo; -#endif /* _NETINET_IN_PCB_HH_ */ +#endif /* _NETINET_IN_PCB_H_ */ struct tcptw { struct inpcb *tw_inpcb; /* XXX back pointer to internet pcb */ @@ -490,7 +490,7 @@ void kmod_tcpstat_inc(int statnum); * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been * included. Not all of our clients do. */ -#if defined(_NETINET_IN_PCB_HH_) && defined(_SYS_SOCKETVAR_HH_) +#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_) struct xtcpcb { size_t xt_len; struct inpcb xt_inp; @@ -684,4 +684,4 @@ u_long tcp_seq_subtract(u_long, u_long ); #endif /* _KERNEL */ -#endif /* _NETINET_TCP_VAR_HH_ */ +#endif /* _NETINET_TCP_VAR_H_ */ diff --git a/freebsd/sys/netinet/tcpip.h b/freebsd/sys/netinet/tcpip.h index 337c07a6..3a89d5d5 100644 --- a/freebsd/sys/netinet/tcpip.h +++ b/freebsd/sys/netinet/tcpip.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCPIP_HH_ -#define _NETINET_TCPIP_HH_ +#ifndef _NETINET_TCPIP_H_ +#define _NETINET_TCPIP_H_ /* * Tcp+ip header, after ip options removed. diff --git a/freebsd/sys/netinet/toedev.h b/freebsd/sys/netinet/toedev.h index 4623845c..7edaca12 100644 --- a/freebsd/sys/netinet/toedev.h +++ b/freebsd/sys/netinet/toedev.h @@ -27,8 +27,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TOEDEV_HH_ -#define _NETINET_TOEDEV_HH_ +#ifndef _NETINET_TOEDEV_H_ +#define _NETINET_TOEDEV_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -159,4 +159,4 @@ toe_enslave(struct ifnet *bond_ifp, struct ifnet *slave_ifp) return (0); } -#endif /* _NETINET_TOEDEV_HH_ */ +#endif /* _NETINET_TOEDEV_H_ */ diff --git a/freebsd/sys/netinet/udp.h b/freebsd/sys/netinet/udp.h index e7010ac5..6841683f 100644 --- a/freebsd/sys/netinet/udp.h +++ b/freebsd/sys/netinet/udp.h @@ -1,2 +1,67 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)udp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +#ifndef _NETINET_UDP_H_ +#define _NETINET_UDP_H_ + +/* + * UDP protocol header. + * Per RFC 768, September, 1981. + */ +struct udphdr { + u_short uh_sport; /* source port */ + u_short uh_dport; /* destination port */ + u_short uh_ulen; /* udp length */ + u_short uh_sum; /* udp checksum */ +}; + +/* + * User-settable options (used with setsockopt). + */ +#define UDP_ENCAP 0x01 + + +/* + * UDP Encapsulation of IPsec Packets options. + */ +/* Encapsulation types. */ +#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ +#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-02+ */ + +/* Default ESP in UDP encapsulation port. */ +#define UDP_ENCAP_ESPINUDP_PORT 500 + +/* Maximum UDP fragment size for ESP over UDP. */ +#define UDP_ENCAP_ESPINUDP_MAXFRAGLEN 552 + +#endif diff --git a/freebsd/sys/netinet/udp_usrreq.c b/freebsd/sys/netinet/udp_usrreq.c index f992f5f6..26bdfed2 100644 --- a/freebsd/sys/netinet/udp_usrreq.c +++ b/freebsd/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 @@ -33,63 +33,63 @@ * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif -#include +#include -#include +#include /* * UDP protocol implementation. diff --git a/freebsd/sys/netinet/udp_var.h b/freebsd/sys/netinet/udp_var.h index 0bff6ea9..aa7ee470 100644 --- a/freebsd/sys/netinet/udp_var.h +++ b/freebsd/sys/netinet/udp_var.h @@ -31,8 +31,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_UDP_VAR_HH_ -#define _NETINET_UDP_VAR_HH_ +#ifndef _NETINET_UDP_VAR_H_ +#define _NETINET_UDP_VAR_H_ /* * UDP kernel structures and variables. diff --git a/freebsd/sys/netinet6/dest6.c b/freebsd/sys/netinet6/dest6.c index 6774dc86..aacfdec5 100644 --- a/freebsd/sys/netinet6/dest6.c +++ b/freebsd/sys/netinet6/dest6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,31 +31,31 @@ * $KAME: dest6.c,v 1.59 2003/07/11 13:21:16 t-momose Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* * Destination options header processing. diff --git a/freebsd/sys/netinet6/frag6.c b/freebsd/sys/netinet6/frag6.c index bdb0f198..391f2a78 100644 --- a/freebsd/sys/netinet6/frag6.c +++ b/freebsd/sys/netinet6/frag6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,34 +31,34 @@ * $KAME: frag6.c,v 1.33 2002/01/07 11:34:48 kjc Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include /* for ECN definitions */ -#include /* for ECN definitions */ - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include /* for ECN definitions */ +#include /* for ECN definitions */ + +#include /* * Define it to get a correct behavior on per-interface statistics. diff --git a/freebsd/sys/netinet6/icmp6.c b/freebsd/sys/netinet6/icmp6.c index 3df7f7b1..407e91d0 100644 --- a/freebsd/sys/netinet6/icmp6.c +++ b/freebsd/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,55 +62,55 @@ * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif extern struct domain inet6domain; diff --git a/freebsd/sys/netinet6/in6.c b/freebsd/sys/netinet6/in6.c index 826213af..1ed8b138 100644 --- a/freebsd/sys/netinet6/in6.c +++ b/freebsd/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,50 +62,50 @@ * @(#)in.c 8.2 (Berkeley) 11/15/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include /* * Definitions of some costant IP6 addresses. @@ -2310,7 +2310,7 @@ in6_if2idlen(struct ifnet *ifp) } } -#include +#include struct in6_llentry { struct llentry base; diff --git a/freebsd/sys/netinet6/in6.h b/freebsd/sys/netinet6/in6.h index 8d241116..d0331f43 100644 --- a/freebsd/sys/netinet6/in6.h +++ b/freebsd/sys/netinet6/in6.h @@ -65,8 +65,8 @@ #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" #endif -#ifndef _NETINET6_IN6_HH_ -#define _NETINET6_IN6_HH_ +#ifndef _NETINET6_IN6_H_ +#define _NETINET6_IN6_H_ /* * Identification of the network protocol stack @@ -705,4 +705,4 @@ __END_DECLS #endif /* __BSD_VISIBLE */ -#endif /* !_NETINET6_IN6_HH_ */ +#endif /* !_NETINET6_IN6_H_ */ diff --git a/freebsd/sys/netinet6/in6_cksum.c b/freebsd/sys/netinet6/in6_cksum.c index 1bd215b9..fb8e044d 100644 --- a/freebsd/sys/netinet6/in6_cksum.c +++ b/freebsd/sys/netinet6/in6_cksum.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,15 +62,15 @@ * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * Checksum routine for Internet Protocol family headers (Portable Version). diff --git a/freebsd/sys/netinet6/in6_gif.c b/freebsd/sys/netinet6/in6_gif.c index 482181db..be915827 100644 --- a/freebsd/sys/netinet6/in6_gif.c +++ b/freebsd/sys/netinet6/in6_gif.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,47 +31,47 @@ * $KAME: in6_gif.c,v 1.49 2001/05/14 14:02:17 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include #ifdef INET -#include +#include #endif -#include +#include #ifdef INET6 -#include -#include -#include -#include +#include +#include +#include +#include #endif -#include -#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include VNET_DEFINE(int, ip6_gif_hlim) = GIF_HLIM; #define V_ip6_gif_hlim VNET(ip6_gif_hlim) diff --git a/freebsd/sys/netinet6/in6_gif.h b/freebsd/sys/netinet6/in6_gif.h index ed566112..f9520898 100644 --- a/freebsd/sys/netinet6/in6_gif.h +++ b/freebsd/sys/netinet6/in6_gif.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IN6_GIF_HH_ -#define _NETINET6_IN6_GIF_HH_ +#ifndef _NETINET6_IN6_GIF_H_ +#define _NETINET6_IN6_GIF_H_ #define GIF_HLIM 30 @@ -42,4 +42,4 @@ int gif_encapcheck6 __P((const struct mbuf *, int, int, void *)); int in6_gif_attach __P((struct gif_softc *)); int in6_gif_detach __P((struct gif_softc *)); -#endif /* _NETINET6_IN6_GIF_HH_ */ +#endif /* _NETINET6_IN6_GIF_H_ */ diff --git a/freebsd/sys/netinet6/in6_ifattach.c b/freebsd/sys/netinet6/in6_ifattach.c index 7942d5af..1063ed43 100644 --- a/freebsd/sys/netinet6/in6_ifattach.c +++ b/freebsd/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,43 +31,43 @@ * $KAME: in6_ifattach.c,v 1.118 2001/05/24 07:44:00 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include VNET_DEFINE(unsigned long, in6_maxmtu) = 0; diff --git a/freebsd/sys/netinet6/in6_ifattach.h b/freebsd/sys/netinet6/in6_ifattach.h index d7db4e47..441eb755 100644 --- a/freebsd/sys/netinet6/in6_ifattach.h +++ b/freebsd/sys/netinet6/in6_ifattach.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IN6_IFATTACH_HH_ -#define _NETINET6_IN6_IFATTACH_HH_ +#ifndef _NETINET6_IN6_IFATTACH_H_ +#define _NETINET6_IN6_IFATTACH_H_ #ifdef _KERNEL void in6_ifattach __P((struct ifnet *, struct ifnet *)); @@ -42,4 +42,4 @@ int in6_get_hw_ifid __P((struct ifnet *, struct in6_addr *)); int in6_nigroup __P((struct ifnet *, const char *, int, struct in6_addr *)); #endif /* _KERNEL */ -#endif /* _NETINET6_IN6_IFATTACH_HH_ */ +#endif /* _NETINET6_IN6_IFATTACH_H_ */ diff --git a/freebsd/sys/netinet6/in6_mcast.c b/freebsd/sys/netinet6/in6_mcast.c index a75a4ed3..4d0637aa 100644 --- a/freebsd/sys/netinet6/in6_mcast.c +++ b/freebsd/sys/netinet6/in6_mcast.c @@ -1,4 +1,4 @@ -#include +#include /* * Copyright (c) 2009 Bruce Simpson. @@ -34,41 +34,41 @@ * Normative references: RFC 2292, RFC 3492, RFC 3542, RFC 3678, RFC 3810. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef KTR_MLD #define KTR_MLD KTR_INET6 diff --git a/freebsd/sys/netinet6/in6_pcb.c b/freebsd/sys/netinet6/in6_pcb.c index 5faccefd..a5475914 100644 --- a/freebsd/sys/netinet6/in6_pcb.c +++ b/freebsd/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,48 +62,48 @@ * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include struct in6_addr zeroin6_addr; diff --git a/freebsd/sys/netinet6/in6_pcb.h b/freebsd/sys/netinet6/in6_pcb.h index abc4a318..6ea63903 100644 --- a/freebsd/sys/netinet6/in6_pcb.h +++ b/freebsd/sys/netinet6/in6_pcb.h @@ -61,8 +61,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IN6_PCB_HH_ -#define _NETINET6_IN6_PCB_HH_ +#ifndef _NETINET6_IN6_PCB_H_ +#define _NETINET6_IN6_PCB_H_ #ifdef _KERNEL #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) @@ -106,4 +106,4 @@ int in6_pcbsetport __P((struct in6_addr *, struct inpcb *, struct ucred *)); void init_sin6 __P((struct sockaddr_in6 *sin6, struct mbuf *m)); #endif /* _KERNEL */ -#endif /* !_NETINET6_IN6_PCB_HH_ */ +#endif /* !_NETINET6_IN6_PCB_H_ */ diff --git a/freebsd/sys/netinet6/in6_proto.c b/freebsd/sys/netinet6/in6_proto.c index 0cd0858d..39611537 100644 --- a/freebsd/sys/netinet6/in6_proto.c +++ b/freebsd/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,70 +62,70 @@ * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef SCTP -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif /* SCTP */ #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC */ -#include +#include /* * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. diff --git a/freebsd/sys/netinet6/in6_rmx.c b/freebsd/sys/netinet6/in6_rmx.c index de867c36..fee58221 100644 --- a/freebsd/sys/netinet6/in6_rmx.c +++ b/freebsd/sys/netinet6/in6_rmx.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -74,39 +74,39 @@ * indefinitely. See in6_rtqtimo() below for the exact mechanism. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include extern int in6_inithead(void **head, int off); #ifdef VIMAGE diff --git a/freebsd/sys/netinet6/in6_src.c b/freebsd/sys/netinet6/in6_src.c index a3914c3f..f7cd642e 100644 --- a/freebsd/sys/netinet6/in6_src.c +++ b/freebsd/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,53 +62,53 @@ * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include static struct mtx addrsel_lock; #define ADDRSEL_LOCK_INIT() mtx_init(&addrsel_lock, "addrsel_lock", NULL, MTX_DEF) diff --git a/freebsd/sys/netinet6/in6_var.h b/freebsd/sys/netinet6/in6_var.h index f77a3271..00342fde 100644 --- a/freebsd/sys/netinet6/in6_var.h +++ b/freebsd/sys/netinet6/in6_var.h @@ -61,13 +61,13 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IN6_VAR_HH_ -#define _NETINET6_IN6_VAR_HH_ +#ifndef _NETINET6_IN6_VAR_H_ +#define _NETINET6_IN6_VAR_H_ -#include +#include #ifdef _KERNEL -#include +#include #endif /* @@ -783,4 +783,4 @@ struct inpcb; int in6_src_ioctl __P((u_long, caddr_t)); #endif /* _KERNEL */ -#endif /* _NETINET6_IN6_VAR_HH_ */ +#endif /* _NETINET6_IN6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/ip6_forward.c b/freebsd/sys/netinet6/ip6_forward.c index f1d19737..2f9073c8 100644 --- a/freebsd/sys/netinet6/ip6_forward.c +++ b/freebsd/sys/netinet6/ip6_forward.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,51 +31,51 @@ * $KAME: ip6_forward.c,v 1.69 2001/05/17 03:48:30 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #ifdef IPSEC -#include -#include -#include +#include +#include +#include #endif /* IPSEC */ -#include +#include /* * Forward a packet. If some error occurs return the sender diff --git a/freebsd/sys/netinet6/ip6_id.c b/freebsd/sys/netinet6/ip6_id.c index 090e66fa..d504cb2d 100644 --- a/freebsd/sys/netinet6/ip6_id.c +++ b/freebsd/sys/netinet6/ip6_id.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 2003 WIDE Project. @@ -68,7 +68,7 @@ * $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -91,17 +91,17 @@ __FBSDID("$FreeBSD$"); * This avoids reuse issues caused by reseeding. */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifndef INT32_MAX #define INT32_MAX 0x7fffffffU diff --git a/freebsd/sys/netinet6/ip6_input.c b/freebsd/sys/netinet6/ip6_input.c index 323bb2a8..425ed2f0 100644 --- a/freebsd/sys/netinet6/ip6_input.c +++ b/freebsd/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,58 +62,58 @@ * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #ifdef INET -#include -#include +#include +#include #endif /* INET */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include -#include +#include +#include +#include #endif /* IPSEC */ -#include +#include extern struct domain inet6domain; diff --git a/freebsd/sys/netinet6/ip6_ipsec.c b/freebsd/sys/netinet6/ip6_ipsec.c index a50c22c5..e1477123 100644 --- a/freebsd/sys/netinet6/ip6_ipsec.c +++ b/freebsd/sys/netinet6/ip6_ipsec.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1982, 1986, 1988, 1993 @@ -29,52 +29,52 @@ * SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #ifdef IPSEC -#include -#include -#include -#include +#include +#include +#include +#include #ifdef IPSEC_DEBUG -#include +#include #else #define KEYDEBUG(lev,arg) #endif #endif /*IPSEC*/ -#include -#include +#include +#include extern struct protosw inet6sw[]; diff --git a/freebsd/sys/netinet6/ip6_ipsec.h b/freebsd/sys/netinet6/ip6_ipsec.h index e3049534..86d1b005 100644 --- a/freebsd/sys/netinet6/ip6_ipsec.h +++ b/freebsd/sys/netinet6/ip6_ipsec.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_IP6_IPSEC_HH_ -#define _NETINET_IP6_IPSEC_HH_ +#ifndef _NETINET_IP6_IPSEC_H_ +#define _NETINET_IP6_IPSEC_H_ int ip6_ipsec_filtertunnel(struct mbuf *); int ip6_ipsec_fwd(struct mbuf *); diff --git a/freebsd/sys/netinet6/ip6_mroute.c b/freebsd/sys/netinet6/ip6_mroute.c index 661cd1c0..3be1d480 100644 --- a/freebsd/sys/netinet6/ip6_mroute.c +++ b/freebsd/sys/netinet6/ip6_mroute.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1998 WIDE Project. @@ -80,50 +80,50 @@ * MROUTING Revision: 3.5.1.2 + PIM-SMv2 (pimd) Support */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include static MALLOC_DEFINE(M_MRTABLE6, "mf6c", "multicast forwarding cache entry"); diff --git a/freebsd/sys/netinet6/ip6_mroute.h b/freebsd/sys/netinet6/ip6_mroute.h index 198659fa..701d5345 100644 --- a/freebsd/sys/netinet6/ip6_mroute.h +++ b/freebsd/sys/netinet6/ip6_mroute.h @@ -44,8 +44,8 @@ * MROUTING Revision: 1.2 */ -#ifndef _NETINET6_IP6_MROUTE_HH_ -#define _NETINET6_IP6_MROUTE_HH_ +#ifndef _NETINET6_IP6_MROUTE_H_ +#define _NETINET6_IP6_MROUTE_H_ /* * Multicast Routing set/getsockopt commands. @@ -242,7 +242,7 @@ struct mf6c { /* * Argument structure used for pkt info. while upcall is made */ -#ifndef _NETINET_IP_MROUTE_HH_ +#ifndef _NETINET_IP_MROUTE_H_ struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ struct mbuf *m; /* A copy of the packet */ struct ifnet *ifp; /* Interface pkt came in on */ @@ -251,7 +251,7 @@ struct rtdetq { /* XXX: rtdetq is also defined in ip_mroute.h */ #endif /* UPCALL_TIMING */ struct rtdetq *next; }; -#endif /* _NETINET_IP_MROUTE_HH_ */ +#endif /* _NETINET_IP_MROUTE_H_ */ #define MF6CTBLSIZ 256 #if (MF6CTBLSIZ & (MF6CTBLSIZ - 1)) == 0 /* from sys:route.h */ @@ -268,4 +268,4 @@ extern int (*ip6_mrouter_done)(void); extern int (*mrt6_ioctl)(u_long, caddr_t); #endif /* _KERNEL */ -#endif /* !_NETINET6_IP6_MROUTE_HH_ */ +#endif /* !_NETINET6_IP6_MROUTE_H_ */ diff --git a/freebsd/sys/netinet6/ip6_output.c b/freebsd/sys/netinet6/ip6_output.c index 0d762cc0..d6d7eb6e 100644 --- a/freebsd/sys/netinet6/ip6_output.c +++ b/freebsd/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -62,56 +62,56 @@ * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include -#include -#include +#include +#include +#include +#include #endif /* IPSEC */ #ifdef SCTP -#include -#include +#include +#include #endif -#include -#include +#include +#include extern int in6_mcast_loop; diff --git a/freebsd/sys/netinet6/ip6_var.h b/freebsd/sys/netinet6/ip6_var.h index 50d8adcb..51ae1f74 100644 --- a/freebsd/sys/netinet6/ip6_var.h +++ b/freebsd/sys/netinet6/ip6_var.h @@ -61,8 +61,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IP6_VAR_HH_ -#define _NETINET6_IP6_VAR_HH_ +#ifndef _NETINET6_IP6_VAR_H_ +#define _NETINET6_IP6_VAR_H_ /* * IP6 reassembly queue structure. Each fragment @@ -441,4 +441,4 @@ u_int32_t ip6_randomid __P((void)); u_int32_t ip6_randomflowlabel __P((void)); #endif /* _KERNEL */ -#endif /* !_NETINET6_IP6_VAR_HH_ */ +#endif /* !_NETINET6_IP6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/ip6protosw.h b/freebsd/sys/netinet6/ip6protosw.h index ebb38c8d..1fae44c8 100644 --- a/freebsd/sys/netinet6/ip6protosw.h +++ b/freebsd/sys/netinet6/ip6protosw.h @@ -62,8 +62,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_IP6PROTOSW_HH_ -#define _NETINET6_IP6PROTOSW_HH_ +#ifndef _NETINET6_IP6PROTOSW_H_ +#define _NETINET6_IP6PROTOSW_H_ /* * Protocol switch table for IPv6. @@ -145,4 +145,4 @@ struct ip6protosw { extern struct ip6protosw inet6sw[]; #endif -#endif /* !_NETINET6_IP6PROTOSW_HH_ */ +#endif /* !_NETINET6_IP6PROTOSW_H_ */ diff --git a/freebsd/sys/netinet6/mld6.c b/freebsd/sys/netinet6/mld6.c index a08f0f16..b1133d69 100644 --- a/freebsd/sys/netinet6/mld6.c +++ b/freebsd/sys/netinet6/mld6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2009 Bruce Simpson. @@ -65,39 +65,39 @@ * @(#)igmp.c 8.1 (Berkeley) 7/19/93 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #ifndef KTR_MLD #define KTR_MLD KTR_INET6 diff --git a/freebsd/sys/netinet6/mld6.h b/freebsd/sys/netinet6/mld6.h index 1839b4f7..64d6b8d7 100644 --- a/freebsd/sys/netinet6/mld6.h +++ b/freebsd/sys/netinet6/mld6.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_MLD6_HH_ -#define _NETINET6_MLD6_HH_ +#ifndef _NETINET6_MLD6_H_ +#define _NETINET6_MLD6_H_ /* * Multicast Listener Discovery (MLD) definitions. @@ -109,4 +109,4 @@ struct mldv2_record { */ #define MLD_TIMER_SCALE 1000 -#endif /* _NETINET6_MLD6_HH_ */ +#endif /* _NETINET6_MLD6_H_ */ diff --git a/freebsd/sys/netinet6/mld6_var.h b/freebsd/sys/netinet6/mld6_var.h index 40d70e51..e62ec236 100644 --- a/freebsd/sys/netinet6/mld6_var.h +++ b/freebsd/sys/netinet6/mld6_var.h @@ -27,8 +27,8 @@ * * $FreeBSD$ */ -#ifndef _NETINET6_MLD6_VAR_HH_ -#define _NETINET6_MLD6_VAR_HH_ +#ifndef _NETINET6_MLD6_VAR_H_ +#define _NETINET6_MLD6_VAR_H_ /* * Multicast Listener Discovery (MLD) @@ -161,4 +161,4 @@ SYSCTL_DECL(_net_inet6_mld); #endif /* _KERNEL */ -#endif /* _NETINET6_MLD6_VAR_HH_ */ +#endif /* _NETINET6_MLD6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/nd6.c b/freebsd/sys/netinet6/nd6.c index bc7ed57e..999855ca 100644 --- a/freebsd/sys/netinet6/nd6.c +++ b/freebsd/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,52 +31,52 @@ * $KAME: nd6.c,v 1.144 2001/05/24 07:44:00 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define L3_ADDR_SIN6(le) ((struct sockaddr_in6 *) L3_ADDR(le)) -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include +#include #define ND6_SLOWTIMER_INTERVAL (60 * 60) /* 1 hour */ #define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */ diff --git a/freebsd/sys/netinet6/nd6.h b/freebsd/sys/netinet6/nd6.h index 2da061df..9874f6ad 100644 --- a/freebsd/sys/netinet6/nd6.h +++ b/freebsd/sys/netinet6/nd6.h @@ -30,16 +30,16 @@ * $FreeBSD$ */ -#ifndef _NETINET6_ND6_HH_ -#define _NETINET6_ND6_HH_ +#ifndef _NETINET6_ND6_H_ +#define _NETINET6_ND6_H_ /* see net/route.h, or net/if_inarp.h */ #ifndef RTF_ANNOUNCE #define RTF_ANNOUNCE RTF_PROTO2 #endif -#include -#include +#include +#include struct llentry; @@ -452,4 +452,4 @@ int in6_tmpifadd __P((const struct in6_ifaddr *, int, int)); #endif /* _KERNEL */ -#endif /* _NETINET6_ND6_HH_ */ +#endif /* _NETINET6_ND6_H_ */ diff --git a/freebsd/sys/netinet6/nd6_nbr.c b/freebsd/sys/netinet6/nd6_nbr.c index 44dd3cf1..599c133f 100644 --- a/freebsd/sys/netinet6/nd6_nbr.c +++ b/freebsd/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,50 +31,50 @@ * $KAME: nd6_nbr.c,v 1.86 2002/01/21 02:33:04 jinmei Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef RADIX_MPATH -#include +#include #endif -#include -#include -#include +#include +#include +#include #define L3_ADDR_SIN6(le) ((struct sockaddr_in6 *) L3_ADDR(le)) -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define SDL(s) ((struct sockaddr_dl *)s) diff --git a/freebsd/sys/netinet6/nd6_rtr.c b/freebsd/sys/netinet6/nd6_rtr.c index 97aa15fb..f2a07d96 100644 --- a/freebsd/sys/netinet6/nd6_rtr.c +++ b/freebsd/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,42 +31,42 @@ * $KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include static int rtpref(struct nd_defrouter *); static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *); diff --git a/freebsd/sys/netinet6/pim6_var.h b/freebsd/sys/netinet6/pim6_var.h index 8c63b5cc..19d0e900 100644 --- a/freebsd/sys/netinet6/pim6_var.h +++ b/freebsd/sys/netinet6/pim6_var.h @@ -38,8 +38,8 @@ * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 */ -#ifndef _NETINET6_PIM6_VAR_HH_ -#define _NETINET6_PIM6_VAR_HH_ +#ifndef _NETINET6_PIM6_VAR_H_ +#define _NETINET6_PIM6_VAR_H_ struct pim6stat { u_quad_t pim6s_rcv_total; /* total PIM messages received */ @@ -65,4 +65,4 @@ int pim6_input __P((struct mbuf **, int*, int)); { 0, 0 }, \ { 0, 0 }, \ } -#endif /* _NETINET6_PIM6_VAR_HH_ */ +#endif /* _NETINET6_PIM6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/raw_ip6.c b/freebsd/sys/netinet6/raw_ip6.c index 71a8add8..9ea1895d 100644 --- a/freebsd/sys/netinet6/raw_ip6.c +++ b/freebsd/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,53 +61,53 @@ * @(#)raw_ip.c 8.2 (Berkeley) 1/4/94 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC */ -#include +#include #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) diff --git a/freebsd/sys/netinet6/raw_ip6.h b/freebsd/sys/netinet6/raw_ip6.h index c4491d01..23395a67 100644 --- a/freebsd/sys/netinet6/raw_ip6.h +++ b/freebsd/sys/netinet6/raw_ip6.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_RAW_IP6_HH_ -#define _NETINET6_RAW_IP6_HH_ +#ifndef _NETINET6_RAW_IP6_H_ +#define _NETINET6_RAW_IP6_H_ /* * ICMPv6 stat is counted separately. see netinet/icmp6.h diff --git a/freebsd/sys/netinet6/route6.c b/freebsd/sys/netinet6/route6.c index 72ad9fae..a674b45e 100644 --- a/freebsd/sys/netinet6/route6.c +++ b/freebsd/sys/netinet6/route6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -31,27 +31,27 @@ * $KAME: route6.c,v 1.24 2001/03/14 03:07:05 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include /* * proto - is unused diff --git a/freebsd/sys/netinet6/scope6.c b/freebsd/sys/netinet6/scope6.c index d9a19d56..655022d6 100644 --- a/freebsd/sys/netinet6/scope6.c +++ b/freebsd/sys/netinet6/scope6.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 2000 WIDE Project. @@ -31,26 +31,26 @@ * $KAME: scope6.c,v 1.10 2000/07/24 13:29:31 itojun Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef ENABLE_DEFAULT_SCOPE VNET_DEFINE(int, ip6_use_defzone) = 1; diff --git a/freebsd/sys/netinet6/scope6_var.h b/freebsd/sys/netinet6/scope6_var.h index a87aa57c..55e0c8ed 100644 --- a/freebsd/sys/netinet6/scope6_var.h +++ b/freebsd/sys/netinet6/scope6_var.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_SCOPE6_VAR_HH_ -#define _NETINET6_SCOPE6_VAR_HH_ +#ifndef _NETINET6_SCOPE6_VAR_H_ +#define _NETINET6_SCOPE6_VAR_H_ #ifdef _KERNEL struct scope6_id { @@ -57,4 +57,4 @@ int in6_setscope __P((struct in6_addr *, struct ifnet *, u_int32_t *)); int in6_clearscope __P((struct in6_addr *)); #endif /* _KERNEL */ -#endif /* _NETINET6_SCOPE6_VAR_HH_ */ +#endif /* _NETINET6_SCOPE6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/sctp6_usrreq.c b/freebsd/sys/netinet6/sctp6_usrreq.c index 178f0d84..6cdd340e 100644 --- a/freebsd/sys/netinet6/sctp6_usrreq.c +++ b/freebsd/sys/netinet6/sctp6_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. @@ -31,35 +31,35 @@ */ /* $KAME: sctp6_usrreq.c,v 1.38 2005/08/24 08:08:56 suz Exp $ */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #if defined(INET6) -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef IPSEC -#include +#include #if defined(INET6) -#include +#include #endif /* INET6 */ #endif /* IPSEC */ diff --git a/freebsd/sys/netinet6/sctp6_var.h b/freebsd/sys/netinet6/sctp6_var.h index b692fdbd..a05f6b03 100644 --- a/freebsd/sys/netinet6/sctp6_var.h +++ b/freebsd/sys/netinet6/sctp6_var.h @@ -29,10 +29,10 @@ */ /* $KAME: sctp6_var.h,v 1.7 2004/08/17 04:06:22 itojun Exp $ */ -#ifndef _NETINET6_SCTP6_VAR_HH_ -#define _NETINET6_SCTP6_VAR_HH_ +#ifndef _NETINET6_SCTP6_VAR_H_ +#define _NETINET6_SCTP6_VAR_H_ -#include +#include __FBSDID("$FreeBSD$"); /* TODO __Userspace__ IPv6 stuff... */ diff --git a/freebsd/sys/netinet6/tcp6_var.h b/freebsd/sys/netinet6/tcp6_var.h index e0373b3d..7da325a1 100644 --- a/freebsd/sys/netinet6/tcp6_var.h +++ b/freebsd/sys/netinet6/tcp6_var.h @@ -59,8 +59,8 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP6_VAR_HH_ -#define _NETINET_TCP6_VAR_HH_ +#ifndef _NETINET_TCP6_VAR_H_ +#define _NETINET_TCP6_VAR_H_ #ifdef _KERNEL #ifdef SYSCTL_DECL @@ -80,4 +80,4 @@ extern struct pr_usrreqs tcp6_usrreqs; #endif /* _KERNEL */ -#endif /* _NETINET_TCP6_VAR_HH_ */ +#endif /* _NETINET_TCP6_VAR_H_ */ diff --git a/freebsd/sys/netinet6/udp6_usrreq.c b/freebsd/sys/netinet6/udp6_usrreq.c index 735c795b..941b3950 100644 --- a/freebsd/sys/netinet6/udp6_usrreq.c +++ b/freebsd/sys/netinet6/udp6_usrreq.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -64,58 +64,58 @@ * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef IPSEC -#include -#include +#include +#include #endif /* IPSEC */ -#include +#include /* * UDP protocol implementation. diff --git a/freebsd/sys/netinet6/udp6_var.h b/freebsd/sys/netinet6/udp6_var.h index f52503cd..ae53c5a8 100644 --- a/freebsd/sys/netinet6/udp6_var.h +++ b/freebsd/sys/netinet6/udp6_var.h @@ -60,8 +60,8 @@ * $FreeBSD$ */ -#ifndef _NETINET6_UDP6_VAR_HH_ -#define _NETINET6_UDP6_VAR_HH_ +#ifndef _NETINET6_UDP6_VAR_H_ +#define _NETINET6_UDP6_VAR_H_ #ifdef _KERNEL SYSCTL_DECL(_net_inet6_udp6); @@ -72,4 +72,4 @@ void udp6_ctlinput(int, struct sockaddr *, void *); int udp6_input(struct mbuf **, int *, int); #endif -#endif /*_NETINET6_UDP6_VAR_HH_*/ +#endif /*_NETINET6_UDP6_VAR_H_*/ diff --git a/freebsd/sys/netipsec/ah.h b/freebsd/sys/netipsec/ah.h index 6a35089b..1ffeacdc 100644 --- a/freebsd/sys/netipsec/ah.h +++ b/freebsd/sys/netipsec/ah.h @@ -34,8 +34,8 @@ * RFC1826/2402 authentication header. */ -#ifndef _NETIPSEC_AH_HH_ -#define _NETIPSEC_AH_HH_ +#ifndef _NETIPSEC_AH_H_ +#define _NETIPSEC_AH_H_ struct ah { u_int8_t ah_nxt; /* Next Header */ @@ -53,4 +53,4 @@ struct newah { u_int32_t ah_seq; /* Sequence number field */ /* variable size, 32bit bound*/ /* Authentication data */ }; -#endif /*_NETIPSEC_AH_HH_*/ +#endif /*_NETIPSEC_AH_H_*/ diff --git a/freebsd/sys/netipsec/ah_var.h b/freebsd/sys/netipsec/ah_var.h index f82ea401..6145dba9 100644 --- a/freebsd/sys/netipsec/ah_var.h +++ b/freebsd/sys/netipsec/ah_var.h @@ -36,8 +36,8 @@ * PURPOSE. */ -#ifndef _NETIPSEC_AH_VAR_HH_ -#define _NETIPSEC_AH_VAR_HH_ +#ifndef _NETIPSEC_AH_VAR_H_ +#define _NETIPSEC_AH_VAR_H_ /* * These define the algorithm indices into the histogram. They're @@ -79,4 +79,4 @@ VNET_DECLARE(struct ahstat, ahstat); #define V_ah_cleartos VNET(ah_cleartos) #define V_ahstat VNET(ahstat) #endif /* _KERNEL */ -#endif /*_NETIPSEC_AH_VAR_HH_*/ +#endif /*_NETIPSEC_AH_VAR_H_*/ diff --git a/freebsd/sys/netipsec/esp.h b/freebsd/sys/netipsec/esp.h index 282883b2..eb373970 100644 --- a/freebsd/sys/netipsec/esp.h +++ b/freebsd/sys/netipsec/esp.h @@ -34,8 +34,8 @@ * RFC1827/2406 Encapsulated Security Payload. */ -#ifndef _NETIPSEC_ESP_HH_ -#define _NETIPSEC_ESP_HH_ +#ifndef _NETIPSEC_ESP_H_ +#define _NETIPSEC_ESP_H_ struct esp { u_int32_t esp_spi; /* ESP */ @@ -66,4 +66,4 @@ struct esptail { }; #define ESP_ALEN 12 /* 96-bit authenticator */ -#endif /*_NETIPSEC_ESP_HH_*/ +#endif /*_NETIPSEC_ESP_H_*/ diff --git a/freebsd/sys/netipsec/esp_var.h b/freebsd/sys/netipsec/esp_var.h index eda4033b..477dcbf5 100644 --- a/freebsd/sys/netipsec/esp_var.h +++ b/freebsd/sys/netipsec/esp_var.h @@ -36,8 +36,8 @@ * PURPOSE. */ -#ifndef _NETIPSEC_ESP_VAR_HH_ -#define _NETIPSEC_ESP_VAR_HH_ +#ifndef _NETIPSEC_ESP_VAR_H_ +#define _NETIPSEC_ESP_VAR_H_ /* * These define the algorithm indices into the histogram. They're @@ -78,4 +78,4 @@ VNET_DECLARE(struct espstat, espstat); #define V_esp_enable VNET(esp_enable) #define V_espstat VNET(espstat) #endif /* _KERNEL */ -#endif /*_NETIPSEC_ESP_VAR_HH_*/ +#endif /*_NETIPSEC_ESP_VAR_H_*/ diff --git a/freebsd/sys/netipsec/ipcomp.h b/freebsd/sys/netipsec/ipcomp.h index a43bf2e8..47e9305e 100644 --- a/freebsd/sys/netipsec/ipcomp.h +++ b/freebsd/sys/netipsec/ipcomp.h @@ -34,8 +34,8 @@ * RFC2393 IP payload compression protocol (IPComp). */ -#ifndef _NETIPSEC_IPCOMP_HH_ -#define _NETIPSEC_IPCOMP_HH_ +#ifndef _NETIPSEC_IPCOMP_H_ +#define _NETIPSEC_IPCOMP_H_ struct ipcomp { u_int8_t comp_nxt; /* Next Header */ @@ -52,4 +52,4 @@ struct ipcomp { #define IPCOMP_MAX 4 #define IPCOMP_CPI_NEGOTIATE_MIN 256 -#endif /*_NETIPSEC_IPCOMP_HH_*/ +#endif /*_NETIPSEC_IPCOMP_H_*/ diff --git a/freebsd/sys/netipsec/ipcomp_var.h b/freebsd/sys/netipsec/ipcomp_var.h index bf4598f4..c99a3be7 100644 --- a/freebsd/sys/netipsec/ipcomp_var.h +++ b/freebsd/sys/netipsec/ipcomp_var.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_IPCOMP_VAR_HH_ -#define _NETIPSEC_IPCOMP_VAR_HH_ +#ifndef _NETIPSEC_IPCOMP_VAR_H_ +#define _NETIPSEC_IPCOMP_VAR_H_ /* * These define the algorithm indices into the histogram. They're @@ -71,4 +71,4 @@ VNET_DECLARE(struct ipcompstat, ipcompstat); #define V_ipcomp_enable VNET(ipcomp_enable) #define V_ipcompstat VNET(ipcompstat) #endif /* _KERNEL */ -#endif /*_NETIPSEC_IPCOMP_VAR_HH_*/ +#endif /*_NETIPSEC_IPCOMP_VAR_H_*/ diff --git a/freebsd/sys/netipsec/ipip_var.h b/freebsd/sys/netipsec/ipip_var.h index 51d8a554..3c8c3974 100644 --- a/freebsd/sys/netipsec/ipip_var.h +++ b/freebsd/sys/netipsec/ipip_var.h @@ -36,8 +36,8 @@ * PURPOSE. */ -#ifndef _NETINET_IPIP_HH_ -#define _NETINET_IPIP_HH_ +#ifndef _NETINET_IPIP_H_ +#define _NETINET_IPIP_H_ /* * IP-inside-IP processing. @@ -65,4 +65,4 @@ VNET_DECLARE(struct ipipstat, ipipstat); #define V_ipip_allow VNET(ipip_allow) #define V_ipipstat VNET(ipipstat) #endif /* _KERNEL */ -#endif /* _NETINET_IPIP_HH_ */ +#endif /* _NETINET_IPIP_H_ */ diff --git a/freebsd/sys/netipsec/ipsec.c b/freebsd/sys/netipsec/ipsec.c index 95aefca3..4c19caec 100644 --- a/freebsd/sys/netipsec/ipsec.c +++ b/freebsd/sys/netipsec/ipsec.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */ @@ -36,68 +36,68 @@ * IPsec controller part. */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include +#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include /*XXX*/ -#include +#include +#include +#include /*XXX*/ +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include +#include -#include +#include #ifdef IPSEC_DEBUG VNET_DEFINE(int, ipsec_debug) = 1; diff --git a/freebsd/sys/netipsec/ipsec.h b/freebsd/sys/netipsec/ipsec.h index ca9a52f3..d54e7cff 100644 --- a/freebsd/sys/netipsec/ipsec.h +++ b/freebsd/sys/netipsec/ipsec.h @@ -34,16 +34,16 @@ * IPsec controller part. */ -#ifndef _NETIPSEC_IPSEC_HH_ -#define _NETIPSEC_IPSEC_HH_ +#ifndef _NETIPSEC_IPSEC_H_ +#define _NETIPSEC_IPSEC_H_ #if defined(_KERNEL) && !defined(_LKM) && !defined(KLD_MODULE) -#include -#include +#include +#include #endif -#include -#include +#include +#include #ifdef _KERNEL @@ -450,4 +450,4 @@ extern const char *ipsec_strerror __P((void)); #endif /* ! KERNEL */ -#endif /* _NETIPSEC_IPSEC_HH_ */ +#endif /* _NETIPSEC_IPSEC_H_ */ diff --git a/freebsd/sys/netipsec/ipsec6.h b/freebsd/sys/netipsec/ipsec6.h index 7213fce7..c004220e 100644 --- a/freebsd/sys/netipsec/ipsec6.h +++ b/freebsd/sys/netipsec/ipsec6.h @@ -34,11 +34,11 @@ * IPsec controller part. */ -#ifndef _NETIPSEC_IPSEC6_HH_ -#define _NETIPSEC_IPSEC6_HH_ +#ifndef _NETIPSEC_IPSEC6_H_ +#define _NETIPSEC_IPSEC6_H_ -#include -#include +#include +#include #ifdef _KERNEL VNET_DECLARE(struct ipsecstat, ipsec6stat); @@ -75,4 +75,4 @@ extern int ipsec6_output_tunnel __P((struct ipsec_output_state *, struct secpolicy *, int)); #endif /*_KERNEL*/ -#endif /*_NETIPSEC_IPSEC6_HH_*/ +#endif /*_NETIPSEC_IPSEC6_H_*/ diff --git a/freebsd/sys/netipsec/ipsec_input.c b/freebsd/sys/netipsec/ipsec_input.c index d8714348..ace3eaea 100644 --- a/freebsd/sys/netipsec/ipsec_input.c +++ b/freebsd/sys/netipsec/ipsec_input.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $ */ @@ -42,62 +42,62 @@ * IPsec input processing. */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #ifdef DEV_ENC -#include +#include #endif diff --git a/freebsd/sys/netipsec/ipsec_mbuf.c b/freebsd/sys/netipsec/ipsec_mbuf.c index f888e60d..24e1ea81 100644 --- a/freebsd/sys/netipsec/ipsec_mbuf.c +++ b/freebsd/sys/netipsec/ipsec_mbuf.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting @@ -32,19 +32,19 @@ * IPsec-specific mbuf routines. */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include -#include +#include /* * Make space for a new header of length hlen at skip bytes diff --git a/freebsd/sys/netipsec/ipsec_output.c b/freebsd/sys/netipsec/ipsec_output.c index 5fdaa0e5..d477b5f4 100644 --- a/freebsd/sys/netipsec/ipsec_output.c +++ b/freebsd/sys/netipsec/ipsec_output.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting @@ -31,66 +31,66 @@ /* * IPsec output processing. */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include +#include #ifdef INET6 -#include +#include #endif -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include #ifdef IPSEC_NAT_T -#include +#include #endif #ifdef DEV_ENC -#include +#include #endif diff --git a/freebsd/sys/netipsec/key.c b/freebsd/sys/netipsec/key.c index 1bf41660..b6fb97a0 100644 --- a/freebsd/sys/netipsec/key.c +++ b/freebsd/sys/netipsec/key.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */ @@ -36,69 +36,69 @@ * This code is referd to RFC 2367 */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif /* INET6 */ #ifdef INET -#include +#include #endif #ifdef INET6 -#include +#include #endif /* INET6 */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include #ifdef INET6 -#include +#include #endif -#include +#include -#include +#include /* randomness */ -#include +#include #define FULLMASK 0xff #define _BITS(bytes) ((bytes) << 3) @@ -3962,7 +3962,7 @@ key_ismyaddr(sa) * 0: other * NOTE: derived ip6_input() in KAME. This is necessary to modify more. */ -#include +#include static int key_ismyaddr6(sin6) diff --git a/freebsd/sys/netipsec/key.h b/freebsd/sys/netipsec/key.h index 4d2b3083..e85acd1e 100644 --- a/freebsd/sys/netipsec/key.h +++ b/freebsd/sys/netipsec/key.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_KEY_HH_ -#define _NETIPSEC_KEY_HH_ +#ifndef _NETIPSEC_KEY_H_ +#define _NETIPSEC_KEY_H_ #ifdef _KERNEL @@ -124,4 +124,4 @@ MALLOC_DECLARE(M_IPSEC_INPCB); #endif /* MALLOC_DECLARE */ #endif /* defined(_KERNEL) */ -#endif /* _NETIPSEC_KEY_HH_ */ +#endif /* _NETIPSEC_KEY_H_ */ diff --git a/freebsd/sys/netipsec/key_debug.c b/freebsd/sys/netipsec/key_debug.c index b8d909b3..0fc9308f 100644 --- a/freebsd/sys/netipsec/key_debug.c +++ b/freebsd/sys/netipsec/key_debug.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */ @@ -33,36 +33,36 @@ */ #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #endif -#include -#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #endif -#include +#include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #ifdef _KERNEL -#include +#include #endif #ifndef _KERNEL -#include -#include -#include +#include +#include +#include #endif /* !_KERNEL */ static void kdebug_sadb_prop __P((struct sadb_ext *)); diff --git a/freebsd/sys/netipsec/key_debug.h b/freebsd/sys/netipsec/key_debug.h index 26dfdbcf..1a3782b1 100644 --- a/freebsd/sys/netipsec/key_debug.h +++ b/freebsd/sys/netipsec/key_debug.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_KEY_DEBUG_HH_ -#define _NETIPSEC_KEY_DEBUG_HH_ +#ifndef _NETIPSEC_KEY_DEBUG_H_ +#define _NETIPSEC_KEY_DEBUG_H_ #ifdef _KERNEL /* debug flags */ @@ -86,4 +86,4 @@ extern void kdebug_sockaddr __P((struct sockaddr *)); extern void ipsec_hexdump __P((caddr_t, int)); extern void ipsec_bindump __P((caddr_t, int)); -#endif /* _NETIPSEC_KEY_DEBUG_HH_ */ +#endif /* _NETIPSEC_KEY_DEBUG_H_ */ diff --git a/freebsd/sys/netipsec/key_var.h b/freebsd/sys/netipsec/key_var.h index 127b6abf..edf232d8 100644 --- a/freebsd/sys/netipsec/key_var.h +++ b/freebsd/sys/netipsec/key_var.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_KEY_VAR_HH_ -#define _NETIPSEC_KEY_VAR_HH_ +#ifndef _NETIPSEC_KEY_VAR_H_ +#define _NETIPSEC_KEY_VAR_H_ /* sysctl */ #define KEYCTL_DEBUG_LEVEL 1 @@ -71,4 +71,4 @@ #define _KEYBUF(key) ((caddr_t)((caddr_t)(key) + sizeof(struct sadb_key))) #endif /*_KERNEL*/ -#endif /* _NETIPSEC_KEY_VAR_HH_ */ +#endif /* _NETIPSEC_KEY_VAR_H_ */ diff --git a/freebsd/sys/netipsec/keydb.h b/freebsd/sys/netipsec/keydb.h index 7fe8ab39..f16d1ea2 100644 --- a/freebsd/sys/netipsec/keydb.h +++ b/freebsd/sys/netipsec/keydb.h @@ -30,12 +30,12 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_KEYDB_HH_ -#define _NETIPSEC_KEYDB_HH_ +#ifndef _NETIPSEC_KEYDB_H_ +#define _NETIPSEC_KEYDB_H_ #ifdef _KERNEL -#include +#include #ifndef _SOCKADDR_UNION_DEFINED #define _SOCKADDR_UNION_DEFINED @@ -224,4 +224,4 @@ extern void keydb_delsecreg __P((struct secreg *)); #endif /* _KERNEL */ -#endif /* _NETIPSEC_KEYDB_HH_ */ +#endif /* _NETIPSEC_KEYDB_H_ */ diff --git a/freebsd/sys/netipsec/keysock.c b/freebsd/sys/netipsec/keysock.c index bd8d2170..21502bb9 100644 --- a/freebsd/sys/netipsec/keysock.c +++ b/freebsd/sys/netipsec/keysock.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ @@ -32,41 +32,41 @@ * SUCH DAMAGE. */ -#include +#include /* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include struct key_cb { int key_count; diff --git a/freebsd/sys/netipsec/keysock.h b/freebsd/sys/netipsec/keysock.h index 2d147b7a..3c0cc8b8 100644 --- a/freebsd/sys/netipsec/keysock.h +++ b/freebsd/sys/netipsec/keysock.h @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ -#ifndef _NETIPSEC_KEYSOCK_HH_ -#define _NETIPSEC_KEYSOCK_HH_ +#ifndef _NETIPSEC_KEYSOCK_H_ +#define _NETIPSEC_KEYSOCK_H_ /* statistics for pfkey socket */ struct pfkeystat { @@ -80,4 +80,4 @@ extern int key_sendup __P((struct socket *, struct sadb_msg *, u_int, int)); extern int key_sendup_mbuf __P((struct socket *, struct mbuf *, int)); #endif /* _KERNEL */ -#endif /*_NETIPSEC_KEYSOCK_HH_*/ +#endif /*_NETIPSEC_KEYSOCK_H_*/ diff --git a/freebsd/sys/netipsec/xform.h b/freebsd/sys/netipsec/xform.h index d229e17d..fc259c91 100644 --- a/freebsd/sys/netipsec/xform.h +++ b/freebsd/sys/netipsec/xform.h @@ -38,12 +38,12 @@ * PURPOSE. */ -#ifndef _NETIPSEC_XFORM_HH_ -#define _NETIPSEC_XFORM_HH_ +#ifndef _NETIPSEC_XFORM_H_ +#define _NETIPSEC_XFORM_H_ -#include -#include -#include +#include +#include +#include #define AH_HMAC_HASHLEN 12 /* 96 bits of authenticator */ #define AH_HMAC_INITIAL_RPL 1 /* replay counter initial value */ @@ -126,4 +126,4 @@ extern size_t esp_hdrsiz(struct secasvar *sav); extern struct comp_algo *ipcomp_algorithm_lookup(int alg); #endif /* _KERNEL */ -#endif /* _NETIPSEC_XFORM_HH_ */ +#endif /* _NETIPSEC_XFORM_H_ */ diff --git a/freebsd/sys/netipsec/xform_ah.c b/freebsd/sys/netipsec/xform_ah.c index 34014eef..f5c0929b 100644 --- a/freebsd/sys/netipsec/xform_ah.c +++ b/freebsd/sys/netipsec/xform_ah.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */ @@ -38,42 +38,42 @@ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR * PURPOSE. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include -#include +#include +#include -#include +#include /* * Return header size in bytes. The old protocol did not support diff --git a/freebsd/sys/netipsec/xform_esp.c b/freebsd/sys/netipsec/xform_esp.c index 3a550d17..04d7bd51 100644 --- a/freebsd/sys/netipsec/xform_esp.c +++ b/freebsd/sys/netipsec/xform_esp.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */ @@ -37,46 +37,46 @@ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR * PURPOSE. */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef INET6 -#include -#include -#include +#include +#include +#include #endif -#include -#include +#include +#include -#include -#include +#include +#include VNET_DEFINE(int, esp_enable) = 1; VNET_DEFINE(struct espstat, espstat); diff --git a/freebsd/sys/netipsec/xform_ipcomp.c b/freebsd/sys/netipsec/xform_ipcomp.c index a4a65953..2c0f961f 100644 --- a/freebsd/sys/netipsec/xform_ipcomp.c +++ b/freebsd/sys/netipsec/xform_ipcomp.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */ @@ -31,44 +31,44 @@ */ /* IP payload compression protocol (IPComp), see RFC 2393 */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include VNET_DEFINE(int, ipcomp_enable) = 1; VNET_DEFINE(struct ipcompstat, ipcompstat); diff --git a/freebsd/sys/netipsec/xform_ipip.c b/freebsd/sys/netipsec/xform_ipip.c index cf89239a..87214ec0 100644 --- a/freebsd/sys/netipsec/xform_ipip.c +++ b/freebsd/sys/netipsec/xform_ipip.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */ @@ -41,52 +41,52 @@ /* * IP-inside-IP processing */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifdef MROUTING -#include +#include #endif -#include -#include +#include +#include -#include +#include #ifdef INET6 -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif -#include -#include +#include +#include -#include +#include /* * We can control the acceptance of IP4 packets by altering the sysctl diff --git a/freebsd/sys/netipsec/xform_tcp.c b/freebsd/sys/netipsec/xform_tcp.c index 2b099639..ca1a3a1b 100644 --- a/freebsd/sys/netipsec/xform_tcp.c +++ b/freebsd/sys/netipsec/xform_tcp.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ @@ -30,38 +30,38 @@ */ /* TCP MD5 Signature Option (RFC2385) */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include #ifdef INET6 -#include -#include +#include +#include #endif -#include -#include +#include +#include /* * Initialize a TCP-MD5 SA. Called when the SA is being set up. diff --git a/freebsd/sys/nios2/include/machine/in_cksum.h b/freebsd/sys/nios2/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/nios2/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/nios2/include/machine/legacyvar.h b/freebsd/sys/nios2/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/nios2/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/nios2/include/machine/pci_cfgreg.h b/freebsd/sys/nios2/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/nios2/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/nios2/nios2/in_cksum.c b/freebsd/sys/nios2/nios2/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/nios2/nios2/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/nios2/nios2/legacy.c b/freebsd/sys/nios2/nios2/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/nios2/nios2/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/nios2/pci/pci_bus.c b/freebsd/sys/nios2/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/nios2/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/opencrypto/cast.c b/freebsd/sys/opencrypto/cast.c index fde6352c..53fe23b1 100644 --- a/freebsd/sys/opencrypto/cast.c +++ b/freebsd/sys/opencrypto/cast.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: cast.c,v 1.2 2000/06/06 06:49:47 deraadt Exp $ */ /*- @@ -8,12 +8,12 @@ * Released 1997.10.11 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include /* Macros to access 8-bit bytes out of a 32-bit word */ #define U_INT8_Ta(x) ( (u_int8_t) (x>>24) ) diff --git a/freebsd/sys/opencrypto/cast.h b/freebsd/sys/opencrypto/cast.h index 25d6c763..8e2d0d19 100644 --- a/freebsd/sys/opencrypto/cast.h +++ b/freebsd/sys/opencrypto/cast.h @@ -8,8 +8,8 @@ * Released 1997.10.11 */ -#ifndef _CAST_HH_ -#define _CAST_HH_ +#ifndef _CAST_H_ +#define _CAST_H_ typedef struct { u_int32_t xkey[32]; /* Key, after expansion */ @@ -20,4 +20,4 @@ void cast_setkey(cast_key * key, u_int8_t * rawkey, int keybytes); void cast_encrypt(cast_key * key, u_int8_t * inblock, u_int8_t * outblock); void cast_decrypt(cast_key * key, u_int8_t * inblock, u_int8_t * outblock); -#endif /* ifndef _CAST_HH_ */ +#endif /* ifndef _CAST_H_ */ diff --git a/freebsd/sys/opencrypto/criov.c b/freebsd/sys/opencrypto/criov.c index 1e389c1d..63ba4c66 100644 --- a/freebsd/sys/opencrypto/criov.c +++ b/freebsd/sys/opencrypto/criov.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: criov.c,v 1.9 2002/01/29 15:48:29 jason Exp $ */ @@ -29,19 +29,19 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include /* * This macro is only for avoiding code duplication, as we need to skip diff --git a/freebsd/sys/opencrypto/crypto.c b/freebsd/sys/opencrypto/crypto.c index 597bbc94..006d33ea 100644 --- a/freebsd/sys/opencrypto/crypto.c +++ b/freebsd/sys/opencrypto/crypto.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2006 Sam Leffler. All rights reserved. @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include __FBSDID("$FreeBSD$"); /* @@ -58,34 +58,34 @@ __FBSDID("$FreeBSD$"); #define CRYPTO_TIMING /* enable timing support */ -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include /* XXX for M_XDATA */ +#include +#include +#include /* XXX for M_XDATA */ -#include -#include -#include +#include +#include +#include #if defined(__i386__) || defined(__amd64__) -#include +#include #endif SDT_PROVIDER_DEFINE(opencrypto); diff --git a/freebsd/sys/opencrypto/cryptodev.c b/freebsd/sys/opencrypto/cryptodev.c index fed4f5df..71cc5b23 100644 --- a/freebsd/sys/opencrypto/cryptodev.c +++ b/freebsd/sys/opencrypto/cryptodev.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */ @@ -34,35 +34,35 @@ * Materiel Command, USAF, under agreement number F30602-01-2-0537. */ -#include +#include __FBSDID("$FreeBSD$"); -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #ifdef COMPAT_FREEBSD32 -#include -#include +#include +#include struct session_op32 { u_int32_t cipher; diff --git a/freebsd/sys/opencrypto/cryptodev.h b/freebsd/sys/opencrypto/cryptodev.h index 2ca71802..e2995221 100644 --- a/freebsd/sys/opencrypto/cryptodev.h +++ b/freebsd/sys/opencrypto/cryptodev.h @@ -53,10 +53,10 @@ * */ -#ifndef _CRYPTO_CRYPTO_HH_ -#define _CRYPTO_CRYPTO_HH_ +#ifndef _CRYPTO_CRYPTO_H_ +#define _CRYPTO_CRYPTO_H_ -#include +#include /* Some initial values */ #define CRYPTO_DRIVERS_INITIAL 4 @@ -429,4 +429,4 @@ extern void crypto_copydata(int flags, caddr_t buf, int off, int size, extern int crypto_apply(int flags, caddr_t buf, int off, int len, int (*f)(void *, void *, u_int), void *arg); #endif /* _KERNEL */ -#endif /* _CRYPTO_CRYPTO_HH_ */ +#endif /* _CRYPTO_CRYPTO_H_ */ diff --git a/freebsd/sys/opencrypto/cryptosoft.c b/freebsd/sys/opencrypto/cryptosoft.c index 69b2d656..cee58527 100644 --- a/freebsd/sys/opencrypto/cryptosoft.c +++ b/freebsd/sys/opencrypto/cryptosoft.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */ @@ -24,34 +24,34 @@ * PURPOSE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include static int32_t swcr_id; static struct swcr_data **swcr_sessions = NULL; diff --git a/freebsd/sys/opencrypto/cryptosoft.h b/freebsd/sys/opencrypto/cryptosoft.h index 363fdbba..af78dc18 100644 --- a/freebsd/sys/opencrypto/cryptosoft.h +++ b/freebsd/sys/opencrypto/cryptosoft.h @@ -22,8 +22,8 @@ * PURPOSE. */ -#ifndef _CRYPTO_CRYPTOSOFT_HH_ -#define _CRYPTO_CRYPTOSOFT_HH_ +#ifndef _CRYPTO_CRYPTOSOFT_H_ +#define _CRYPTO_CRYPTOSOFT_H_ /* Software session entry */ struct swcr_data { @@ -64,4 +64,4 @@ extern u_int8_t hmac_ipad_buffer[]; extern u_int8_t hmac_opad_buffer[]; #endif /* _KERNEL */ -#endif /* _CRYPTO_CRYPTO_HH_ */ +#endif /* _CRYPTO_CRYPTO_H_ */ diff --git a/freebsd/sys/opencrypto/deflate.c b/freebsd/sys/opencrypto/deflate.c index ddf8239e..5806d33e 100644 --- a/freebsd/sys/opencrypto/deflate.c +++ b/freebsd/sys/opencrypto/deflate.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: deflate.c,v 1.3 2001/08/20 02:45:22 hugh Exp $ */ @@ -34,22 +34,22 @@ * functions using the zlib library (see net/zlib.{c,h}) */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include SDT_PROVIDER_DECLARE(opencrypto); SDT_PROBE_DEFINE2(opencrypto, deflate, deflate_global, entry, diff --git a/freebsd/sys/opencrypto/deflate.h b/freebsd/sys/opencrypto/deflate.h index 732620b5..dcf7a844 100644 --- a/freebsd/sys/opencrypto/deflate.h +++ b/freebsd/sys/opencrypto/deflate.h @@ -33,10 +33,10 @@ * algorithm used in /sys/crypto */ -#ifndef _CRYPTO_DEFLATE_HH_ -#define _CRYPTO_DEFLATE_HH_ +#ifndef _CRYPTO_DEFLATE_H_ +#define _CRYPTO_DEFLATE_H_ -#include +#include #define Z_METHOD 8 #define Z_MEMLEVEL 8 @@ -57,4 +57,4 @@ struct deflate_buf { uint8_t data[]; }; -#endif /* _CRYPTO_DEFLATE_HH_ */ +#endif /* _CRYPTO_DEFLATE_H_ */ diff --git a/freebsd/sys/opencrypto/rmd160.c b/freebsd/sys/opencrypto/rmd160.c index 99f987ee..92b5c2e7 100644 --- a/freebsd/sys/opencrypto/rmd160.c +++ b/freebsd/sys/opencrypto/rmd160.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: rmd160.c,v 1.3 2001/09/26 21:40:13 markus Exp $ */ /*- @@ -31,13 +31,13 @@ * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include +#include +#include +#include #define PUT_64BIT_LE(cp, value) do { \ (cp)[7] = (value) >> 56; \ diff --git a/freebsd/sys/opencrypto/skipjack.c b/freebsd/sys/opencrypto/skipjack.c index ae06dc1b..08edc4c2 100644 --- a/freebsd/sys/opencrypto/skipjack.c +++ b/freebsd/sys/opencrypto/skipjack.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: skipjack.c,v 1.3 2001/05/05 00:31:34 angelos Exp $ */ /*- @@ -14,12 +14,12 @@ * 29 May 1998 */ -#include +#include __FBSDID("$FreeBSD$"); -#include +#include -#include +#include static const u_int8_t ftable[0x100] = { diff --git a/freebsd/sys/opencrypto/xform.c b/freebsd/sys/opencrypto/xform.c index e54a6740..7fceb4ec 100644 --- a/freebsd/sys/opencrypto/xform.c +++ b/freebsd/sys/opencrypto/xform.c @@ -1,4 +1,4 @@ -#include +#include /* $OpenBSD: xform.c,v 1.16 2001/08/28 12:20:43 ben Exp $ */ /*- @@ -38,33 +38,33 @@ * PURPOSE. */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include static int null_setkey(u_int8_t **, u_int8_t *, int); static int des1_setkey(u_int8_t **, u_int8_t *, int); diff --git a/freebsd/sys/opencrypto/xform.h b/freebsd/sys/opencrypto/xform.h index 7c70ca90..0a7f981d 100644 --- a/freebsd/sys/opencrypto/xform.h +++ b/freebsd/sys/opencrypto/xform.h @@ -22,13 +22,13 @@ * PURPOSE. */ -#ifndef _CRYPTO_XFORM_HH_ -#define _CRYPTO_XFORM_HH_ +#ifndef _CRYPTO_XFORM_H_ +#define _CRYPTO_XFORM_H_ -#include -#include -#include -#include +#include +#include +#include +#include /* Declarations */ struct auth_hash { @@ -98,7 +98,7 @@ extern struct auth_hash auth_hash_hmac_sha2_512; extern struct comp_algo comp_algo_deflate; #ifdef _KERNEL -#include +#include MALLOC_DECLARE(M_XDATA); #endif -#endif /* _CRYPTO_XFORM_HH_ */ +#endif /* _CRYPTO_XFORM_H_ */ diff --git a/freebsd/sys/powerpc/include/machine/cpufunc.h b/freebsd/sys/powerpc/include/machine/cpufunc.h index 7c240e2e..f028b62c 100644 --- a/freebsd/sys/powerpc/include/machine/cpufunc.h +++ b/freebsd/sys/powerpc/include/machine/cpufunc.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_CPUFUNC_HH_ -#define _MACHINE_CPUFUNC_HH_ +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ /* * Required for user-space atomic.h includes @@ -41,10 +41,10 @@ powerpc_mb(void) #ifdef _KERNEL -#include +#include -#include -#include +#include +#include struct thread; @@ -196,4 +196,4 @@ powerpc_get_pcpup(void) #endif /* _KERNEL */ -#endif /* !_MACHINE_CPUFUNC_HH_ */ +#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/freebsd/sys/powerpc/include/machine/in_cksum.h b/freebsd/sys/powerpc/include/machine/in_cksum.h new file mode 100644 index 00000000..09920062 --- /dev/null +++ b/freebsd/sys/powerpc/include/machine/in_cksum.h @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/powerpc/include/machine/legacyvar.h b/freebsd/sys/powerpc/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/powerpc/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/powerpc/include/machine/pci_cfgreg.h b/freebsd/sys/powerpc/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/powerpc/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/powerpc/include/machine/psl.h b/freebsd/sys/powerpc/include/machine/psl.h index 4764c626..ec3975a0 100644 --- a/freebsd/sys/powerpc/include/machine/psl.h +++ b/freebsd/sys/powerpc/include/machine/psl.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_PSL_HH_ -#define _MACHINE_PSL_HH_ +#ifndef _MACHINE_PSL_H_ +#define _MACHINE_PSL_H_ #if defined(E500) /* @@ -117,4 +117,4 @@ #define PSL_USERSTATIC (PSL_USERSET | PSL_IP | 0x87c0008c) #endif /* if defined(E500) */ -#endif /* _MACHINE_PSL_HH_ */ +#endif /* _MACHINE_PSL_H_ */ diff --git a/freebsd/sys/powerpc/include/machine/spr.h b/freebsd/sys/powerpc/include/machine/spr.h index b24a6ade..586a57be 100644 --- a/freebsd/sys/powerpc/include/machine/spr.h +++ b/freebsd/sys/powerpc/include/machine/spr.h @@ -33,8 +33,8 @@ * $NetBSD: spr.h,v 1.25 2002/08/14 15:38:40 matt Exp $ * $FreeBSD$ */ -#ifndef _POWERPC_SPR_HH_ -#define _POWERPC_SPR_HH_ +#ifndef _POWERPC_SPR_H_ +#define _POWERPC_SPR_H_ #ifndef _LOCORE #define mtspr(reg, val) \ @@ -695,4 +695,4 @@ #endif /* #elif defined(E500) */ -#endif /* !_POWERPC_SPR_HH_ */ +#endif /* !_POWERPC_SPR_H_ */ diff --git a/freebsd/sys/powerpc/pci/pci_bus.c b/freebsd/sys/powerpc/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/powerpc/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/powerpc/powerpc/in_cksum.c b/freebsd/sys/powerpc/powerpc/in_cksum.c index ede39fc3..62e45e18 100644 --- a/freebsd/sys/powerpc/powerpc/in_cksum.c +++ b/freebsd/sys/powerpc/powerpc/in_cksum.c @@ -1,4 +1,4 @@ -#include +#include /* $FreeBSD$ */ /* $NetBSD: in_cksum.c,v 1.7 1997/09/02 13:18:15 thorpej Exp $ */ @@ -40,15 +40,15 @@ * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 */ -#include /* RCS ID & Copyright macro defns */ +#include /* RCS ID & Copyright macro defns */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* * Checksum routine for Internet Protocol family headers diff --git a/freebsd/sys/powerpc/powerpc/legacy.c b/freebsd/sys/powerpc/powerpc/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/powerpc/powerpc/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/rpc/types.h b/freebsd/sys/rpc/types.h index b476ada3..5634c4dd 100644 --- a/freebsd/sys/rpc/types.h +++ b/freebsd/sys/rpc/types.h @@ -39,7 +39,7 @@ #ifndef _RPC_TYPES_H #define _RPC_TYPES_H -#include +#include #include typedef int32_t bool_t; @@ -72,7 +72,7 @@ MALLOC_DECLARE(M_RPC); #define mem_free(ptr, bsize) free(ptr) #endif -#include +#include #ifdef _KERNEL #include #else diff --git a/freebsd/sys/sched.h b/freebsd/sys/sched.h deleted file mode 100644 index 936ffd88..00000000 --- a/freebsd/sys/sched.h +++ /dev/null @@ -1 +0,0 @@ -/* EMPTY */ diff --git a/freebsd/sys/security/mac/mac_framework.h b/freebsd/sys/security/mac/mac_framework.h index c827e713..70fb7c99 100644 --- a/freebsd/sys/security/mac/mac_framework.h +++ b/freebsd/sys/security/mac/mac_framework.h @@ -46,8 +46,8 @@ * interact with the TrustedBSD MAC Framework. */ -#ifndef _SECURITY_MAC_MAC_FRAMEWORK_HH_ -#define _SECURITY_MAC_MAC_FRAMEWORK_HH_ +#ifndef _SECURITY_MAC_MAC_FRAMEWORK_H_ +#define _SECURITY_MAC_MAC_FRAMEWORK_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -89,8 +89,8 @@ struct vattr; struct vnode; struct vop_setlabel_args; -#include /* XXX acl_type_t */ -#include /* accmode_t */ +#include /* XXX acl_type_t */ +#include /* accmode_t */ /* * Entry points to the TrustedBSD MAC Framework from the remainder of the @@ -438,4 +438,4 @@ void mac_vnode_relabel(struct ucred *cred, struct vnode *vp, */ int vop_stdsetlabel_ea(struct vop_setlabel_args *ap); -#endif /* !_SECURITY_MAC_MAC_FRAMEWORK_HH_ */ +#endif /* !_SECURITY_MAC_MAC_FRAMEWORK_H_ */ diff --git a/freebsd/sys/select.h b/freebsd/sys/select.h deleted file mode 100644 index 936ffd88..00000000 --- a/freebsd/sys/select.h +++ /dev/null @@ -1 +0,0 @@ -/* EMPTY */ diff --git a/freebsd/sys/sh/include/machine/in_cksum.h b/freebsd/sys/sh/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/sh/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/sh/include/machine/legacyvar.h b/freebsd/sys/sh/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/sh/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/sh/include/machine/pci_cfgreg.h b/freebsd/sys/sh/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/sh/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/sh/pci/pci_bus.c b/freebsd/sys/sh/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/sh/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/sh/sh/in_cksum.c b/freebsd/sys/sh/sh/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/sh/sh/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/sh/sh/legacy.c b/freebsd/sys/sh/sh/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/sh/sh/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/socket.h b/freebsd/sys/socket.h deleted file mode 100644 index a5a43db1..00000000 --- a/freebsd/sys/socket.h +++ /dev/null @@ -1,691 +0,0 @@ -/*- - * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)socket.h 8.4 (Berkeley) 2/21/94 - * $FreeBSD$ - */ - -#ifndef _SYS_SOCKET_HH_ -#define _SYS_SOCKET_HH_ - -#include -#include -#include -#define _NO_NAMESPACE_POLLUTION -#include -#undef _NO_NAMESPACE_POLLUTION - -/* - * Definitions related to sockets: types, address families, options. - */ - -/* - * Data types. - */ -#if __BSD_VISIBLE -#ifndef _GID_T_DECLARED -typedef __gid_t gid_t; -#define _GID_T_DECLARED -#endif - -#ifndef _OFF_T_DECLARED -typedef __off_t off_t; -#define _OFF_T_DECLARED -#endif - -#ifndef _PID_T_DECLARED -typedef __pid_t pid_t; -#define _PID_T_DECLARED -#endif -#endif - -#ifndef _SA_FAMILY_T_DECLARED -typedef __sa_family_t sa_family_t; -#define _SA_FAMILY_T_DECLARED -#endif - -#ifndef _SOCKLEN_T_DECLARED -typedef __socklen_t socklen_t; -#define _SOCKLEN_T_DECLARED -#endif - -#ifndef _SSIZE_T_DECLARED -typedef __ssize_t ssize_t; -#define _SSIZE_T_DECLARED -#endif - -#if __BSD_VISIBLE -#ifndef _UID_T_DECLARED -typedef __uid_t uid_t; -#define _UID_T_DECLARED -#endif -#endif - -/* - * Types - */ -#define SOCK_STREAM 1 /* stream socket */ -#define SOCK_DGRAM 2 /* datagram socket */ -#define SOCK_RAW 3 /* raw-protocol interface */ -#if __BSD_VISIBLE -#define SOCK_RDM 4 /* reliably-delivered message */ -#endif -#define SOCK_SEQPACKET 5 /* sequenced packet stream */ - -/* - * Option flags per-socket. - */ -#define SO_DEBUG 0x0001 /* turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ -#if __BSD_VISIBLE -#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ -#endif -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ -#if __BSD_VISIBLE -#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ -#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ -#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ -#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ -#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */ -#endif -#define SO_NO_OFFLOAD 0x4000 /* socket cannot be offloaded */ -#define SO_NO_DDP 0x8000 /* disable direct data placement */ - -/* - * Additional options, not kept in so_options. - */ -#define SO_SNDBUF 0x1001 /* send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ -#if __BSD_VISIBLE -#define SO_LABEL 0x1009 /* socket's MAC label */ -#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */ -#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ -#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ -#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ -#define SO_SETFIB 0x1014 /* use this FIB to route */ -#endif - -/* - * Structure used for manipulating linger option. - */ -struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time */ -}; - -#if __BSD_VISIBLE -struct accept_filter_arg { - char af_name[16]; - char af_arg[256-16]; -}; -#endif - -/* - * Level number for (get/set)sockopt() to apply to socket itself. - */ -#define SOL_SOCKET 0xffff /* options for socket level */ - -/* - * Address families. - */ -#define AF_UNSPEC 0 /* unspecified */ -#if __BSD_VISIBLE -#define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */ -#endif -#define AF_UNIX 1 /* standardized name for AF_LOCAL */ -#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ -#if __BSD_VISIBLE -#define AF_IMPLINK 3 /* arpanet imp addresses */ -#define AF_PUP 4 /* pup protocols: e.g. BSP */ -#define AF_CHAOS 5 /* mit CHAOS protocols */ -#define AF_NETBIOS 6 /* SMB protocols */ -#define AF_ISO 7 /* ISO protocols */ -#define AF_OSI AF_ISO -#define AF_ECMA 8 /* European computer manufacturers */ -#define AF_DATAKIT 9 /* datakit protocols */ -#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ -#define AF_SNA 11 /* IBM SNA */ -#define AF_DECnet 12 /* DECnet */ -#define AF_DLI 13 /* DEC Direct data link interface */ -#define AF_LAT 14 /* LAT */ -#define AF_HYLINK 15 /* NSC Hyperchannel */ -#define AF_APPLETALK 16 /* Apple Talk */ -#define AF_ROUTE 17 /* Internal Routing Protocol */ -#define AF_LINK 18 /* Link layer interface */ -#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ -#define AF_COIP 20 /* connection-oriented IP, aka ST II */ -#define AF_CNT 21 /* Computer Network Technology */ -#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ -#define AF_IPX 23 /* Novell Internet Protocol */ -#define AF_SIP 24 /* Simple Internet Protocol */ -#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ -#define AF_ISDN 26 /* Integrated Services Digital Network*/ -#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ -#define pseudo_AF_KEY 27 /* Internal key-management function */ -#endif -#define AF_INET6 28 /* IPv6 */ -#if __BSD_VISIBLE -#define AF_NATM 29 /* native ATM access */ -#define AF_ATM 30 /* ATM */ -#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers - * in interface output routine - */ -#define AF_NETGRAPH 32 /* Netgraph sockets */ -#define AF_SLOW 33 /* 802.3ad slow protocol */ -#define AF_SCLUSTER 34 /* Sitara cluster protocol */ -#define AF_ARP 35 -#define AF_BLUETOOTH 36 /* Bluetooth sockets */ -#define AF_IEEE80211 37 /* IEEE 802.11 protocol */ -#define AF_MAX 38 -/* - * When allocating a new AF_ constant, please only allocate - * even numbered constants for FreeBSD until 134 as odd numbered AF_ - * constants 39-133 are now reserved for vendors. - */ -#define AF_VENDOR00 39 -#define AF_VENDOR01 41 -#define AF_VENDOR02 43 -#define AF_VENDOR03 45 -#define AF_VENDOR04 47 -#define AF_VENDOR05 49 -#define AF_VENDOR06 51 -#define AF_VENDOR07 53 -#define AF_VENDOR08 55 -#define AF_VENDOR09 57 -#define AF_VENDOR10 59 -#define AF_VENDOR11 61 -#define AF_VENDOR12 63 -#define AF_VENDOR13 65 -#define AF_VENDOR14 67 -#define AF_VENDOR15 69 -#define AF_VENDOR16 71 -#define AF_VENDOR17 73 -#define AF_VENDOR18 75 -#define AF_VENDOR19 77 -#define AF_VENDOR20 79 -#define AF_VENDOR21 81 -#define AF_VENDOR22 83 -#define AF_VENDOR23 85 -#define AF_VENDOR24 87 -#define AF_VENDOR25 89 -#define AF_VENDOR26 91 -#define AF_VENDOR27 93 -#define AF_VENDOR28 95 -#define AF_VENDOR29 97 -#define AF_VENDOR30 99 -#define AF_VENDOR31 101 -#define AF_VENDOR32 103 -#define AF_VENDOR33 105 -#define AF_VENDOR34 107 -#define AF_VENDOR35 109 -#define AF_VENDOR36 111 -#define AF_VENDOR37 113 -#define AF_VENDOR38 115 -#define AF_VENDOR39 117 -#define AF_VENDOR40 119 -#define AF_VENDOR41 121 -#define AF_VENDOR42 123 -#define AF_VENDOR43 125 -#define AF_VENDOR44 127 -#define AF_VENDOR45 129 -#define AF_VENDOR46 131 -#define AF_VENDOR47 133 -#endif - -/* - * Structure used by kernel to store most - * addresses. - */ -struct sockaddr { - unsigned char sa_len; /* total length */ - sa_family_t sa_family; /* address family */ - char sa_data[14]; /* actually longer; address value */ -}; -#if __BSD_VISIBLE -#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ - -/* - * Structure used by kernel to pass protocol - * information in raw sockets. - */ -struct sockproto { - unsigned short sp_family; /* address family */ - unsigned short sp_protocol; /* protocol */ -}; -#endif - -#ifndef _STRUCT_SOCKADDR_STORAGE_DECLARED -/* - * RFC 2553: protocol-independent placeholder for socket addresses - */ -#define _SS_MAXSIZE 128U -#define _SS_ALIGNSIZE (sizeof(__int64_t)) -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ - sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) - -struct sockaddr_storage { - unsigned char ss_len; /* address length */ - sa_family_t ss_family; /* address family */ - char __ss_pad1[_SS_PAD1SIZE]; - __int64_t __ss_align; /* force desired struct alignment */ - char __ss_pad2[_SS_PAD2SIZE]; -}; -#define _STRUCT_SOCKADDR_STORAGE_DECLARED -#endif - -#if __BSD_VISIBLE -/* - * Protocol families, same as address families for now. - */ -#define PF_UNSPEC AF_UNSPEC -#define PF_LOCAL AF_LOCAL -#define PF_UNIX PF_LOCAL /* backward compatibility */ -#define PF_INET AF_INET -#define PF_IMPLINK AF_IMPLINK -#define PF_PUP AF_PUP -#define PF_CHAOS AF_CHAOS -#define PF_NETBIOS AF_NETBIOS -#define PF_ISO AF_ISO -#define PF_OSI AF_ISO -#define PF_ECMA AF_ECMA -#define PF_DATAKIT AF_DATAKIT -#define PF_CCITT AF_CCITT -#define PF_SNA AF_SNA -#define PF_DECnet AF_DECnet -#define PF_DLI AF_DLI -#define PF_LAT AF_LAT -#define PF_HYLINK AF_HYLINK -#define PF_APPLETALK AF_APPLETALK -#define PF_ROUTE AF_ROUTE -#define PF_LINK AF_LINK -#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ -#define PF_COIP AF_COIP -#define PF_CNT AF_CNT -#define PF_SIP AF_SIP -#define PF_IPX AF_IPX -#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ -#define PF_PIP pseudo_AF_PIP -#define PF_ISDN AF_ISDN -#define PF_KEY pseudo_AF_KEY -#define PF_INET6 AF_INET6 -#define PF_NATM AF_NATM -#define PF_ATM AF_ATM -#define PF_NETGRAPH AF_NETGRAPH -#define PF_SLOW AF_SLOW -#define PF_SCLUSTER AF_SCLUSTER -#define PF_ARP AF_ARP -#define PF_BLUETOOTH AF_BLUETOOTH - -#define PF_MAX AF_MAX - -/* - * Definitions for network related sysctl, CTL_NET. - * - * Second level is protocol family. - * Third level is protocol number. - * - * Further levels are defined by the individual families below. - */ -#define NET_MAXID AF_MAX - -#define CTL_NET_NAMES { \ - { 0, 0 }, \ - { "unix", CTLTYPE_NODE }, \ - { "inet", CTLTYPE_NODE }, \ - { "implink", CTLTYPE_NODE }, \ - { "pup", CTLTYPE_NODE }, \ - { "chaos", CTLTYPE_NODE }, \ - { "xerox_ns", CTLTYPE_NODE }, \ - { "iso", CTLTYPE_NODE }, \ - { "emca", CTLTYPE_NODE }, \ - { "datakit", CTLTYPE_NODE }, \ - { "ccitt", CTLTYPE_NODE }, \ - { "ibm_sna", CTLTYPE_NODE }, \ - { "decnet", CTLTYPE_NODE }, \ - { "dec_dli", CTLTYPE_NODE }, \ - { "lat", CTLTYPE_NODE }, \ - { "hylink", CTLTYPE_NODE }, \ - { "appletalk", CTLTYPE_NODE }, \ - { "route", CTLTYPE_NODE }, \ - { "link_layer", CTLTYPE_NODE }, \ - { "xtp", CTLTYPE_NODE }, \ - { "coip", CTLTYPE_NODE }, \ - { "cnt", CTLTYPE_NODE }, \ - { "rtip", CTLTYPE_NODE }, \ - { "ipx", CTLTYPE_NODE }, \ - { "sip", CTLTYPE_NODE }, \ - { "pip", CTLTYPE_NODE }, \ - { "isdn", CTLTYPE_NODE }, \ - { "key", CTLTYPE_NODE }, \ - { "inet6", CTLTYPE_NODE }, \ - { "natm", CTLTYPE_NODE }, \ - { "atm", CTLTYPE_NODE }, \ - { "hdrcomplete", CTLTYPE_NODE }, \ - { "netgraph", CTLTYPE_NODE }, \ - { "snp", CTLTYPE_NODE }, \ - { "scp", CTLTYPE_NODE }, \ -} - -/* - * PF_ROUTE - Routing table - * - * Three additional levels are defined: - * Fourth: address family, 0 is wildcard - * Fifth: type of info, defined below - * Sixth: flag(s) to mask with for NET_RT_FLAGS - */ -#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ -#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ -#define NET_RT_IFLIST 3 /* survey interface list */ -#define NET_RT_IFMALIST 4 /* return multicast address list */ -#define NET_RT_MAXID 5 - -#define CTL_NET_RT_NAMES { \ - { 0, 0 }, \ - { "dump", CTLTYPE_STRUCT }, \ - { "flags", CTLTYPE_STRUCT }, \ - { "iflist", CTLTYPE_STRUCT }, \ - { "ifmalist", CTLTYPE_STRUCT }, \ -} -#endif /* __BSD_VISIBLE */ - -/* - * Maximum queue length specifiable by listen. - */ -#define SOMAXCONN 128 - -/* - * Message header for recvmsg and sendmsg calls. - * Used value-result for recvmsg, value only for sendmsg. - */ -struct msghdr { - void *msg_name; /* optional address */ - socklen_t msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - int msg_iovlen; /* # elements in msg_iov */ - void *msg_control; /* ancillary data, see below */ - socklen_t msg_controllen; /* ancillary data buffer len */ - int msg_flags; /* flags on received message */ -}; - -#define MSG_OOB 0x1 /* process out-of-band data */ -#define MSG_PEEK 0x2 /* peek at incoming message */ -#define MSG_DONTROUTE 0x4 /* send without using routing tables */ -#define MSG_EOR 0x8 /* data completes record */ -#define MSG_TRUNC 0x10 /* data discarded before delivery */ -#define MSG_CTRUNC 0x20 /* control data lost before delivery */ -#define MSG_WAITALL 0x40 /* wait for full request or error */ -#define MSG_NOTIFICATION 0x2000 /* SCTP notification */ -#if __BSD_VISIBLE -#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ -#define MSG_EOF 0x100 /* data completes connection */ -#define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */ -#define MSG_COMPAT 0x8000 /* used in sendit() */ -#endif -#ifdef _KERNEL -#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */ -#endif -#if __BSD_VISIBLE -#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */ -#endif - -/* - * Header for ancillary data objects in msg_control buffer. - * Used for additional information with/about a datagram - * not expressible by flags. The format is a sequence - * of message elements headed by cmsghdr structures. - */ -struct cmsghdr { - socklen_t cmsg_len; /* data byte count, including hdr */ - int cmsg_level; /* originating protocol */ - int cmsg_type; /* protocol-specific type */ -/* followed by u_char cmsg_data[]; */ -}; - -#if __BSD_VISIBLE -/* - * While we may have more groups than this, the cmsgcred struct must - * be able to fit in an mbuf and we have historically supported a - * maximum of 16 groups. -*/ -#define CMGROUP_MAX 16 - -/* - * Credentials structure, used to verify the identity of a peer - * process that has sent us a message. This is allocated by the - * peer process but filled in by the kernel. This prevents the - * peer from lying about its identity. (Note that cmcred_groups[0] - * is the effective GID.) - */ -struct cmsgcred { - pid_t cmcred_pid; /* PID of sending process */ - uid_t cmcred_uid; /* real UID of sending process */ - uid_t cmcred_euid; /* effective UID of sending process */ - gid_t cmcred_gid; /* real GID of sending process */ - short cmcred_ngroups; /* number or groups */ - gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ -}; - -/* - * Socket credentials. - */ -struct sockcred { - uid_t sc_uid; /* real user id */ - uid_t sc_euid; /* effective user id */ - gid_t sc_gid; /* real group id */ - gid_t sc_egid; /* effective group id */ - int sc_ngroups; /* number of supplemental groups */ - gid_t sc_groups[1]; /* variable length */ -}; - -/* - * Compute size of a sockcred structure with groups. - */ -#define SOCKCREDSIZE(ngrps) \ - (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) - -#endif /* __BSD_VISIBLE */ - -/* given pointer to struct cmsghdr, return pointer to data */ -#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ - _ALIGN(sizeof(struct cmsghdr))) - -/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ -#define CMSG_NXTHDR(mhdr, cmsg) \ - ((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \ - ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \ - _ALIGN(sizeof(struct cmsghdr)) > \ - (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ - (struct cmsghdr *)0 : \ - (struct cmsghdr *)((char *)(cmsg) + \ - _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))) - -/* - * RFC 2292 requires to check msg_controllen, in case that the kernel returns - * an empty list for some reasons. - */ -#define CMSG_FIRSTHDR(mhdr) \ - ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ - (struct cmsghdr *)(mhdr)->msg_control : \ - (struct cmsghdr *)NULL) - -#if __BSD_VISIBLE -/* RFC 2292 additions */ -#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) -#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) -#endif - -#ifdef _KERNEL -#define CMSG_ALIGN(n) _ALIGN(n) -#endif - -/* "Socket"-level control message types: */ -#define SCM_RIGHTS 0x01 /* access rights (array of int) */ -#if __BSD_VISIBLE -#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ -#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ -#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */ -#endif - -#if __BSD_VISIBLE -/* - * 4.3 compat sockaddr, move to compat file later - */ -struct osockaddr { - unsigned short sa_family; /* address family */ - char sa_data[14]; /* up to 14 bytes of direct address */ -}; - -/* - * 4.3-compat message header (move to compat file later). - */ -struct omsghdr { - char *msg_name; /* optional address */ - int msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - int msg_iovlen; /* # elements in msg_iov */ - char *msg_accrights; /* access rights sent/received */ - int msg_accrightslen; -}; -#endif - -/* - * howto arguments for shutdown(2), specified by Posix.1g. - */ -#define SHUT_RD 0 /* shut down the reading side */ -#define SHUT_WR 1 /* shut down the writing side */ -#define SHUT_RDWR 2 /* shut down both sides */ - -/* we cheat and use the SHUT_XX defines for these */ -#define PRU_FLUSH_RD SHUT_RD -#define PRU_FLUSH_WR SHUT_WR -#define PRU_FLUSH_RDWR SHUT_RDWR - - -#if __BSD_VISIBLE -/* - * sendfile(2) header/trailer struct - */ -struct sf_hdtr { - struct iovec *headers; /* pointer to an array of header struct iovec's */ - int hdr_cnt; /* number of header iovec's */ - struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ - int trl_cnt; /* number of trailer iovec's */ -}; - -/* - * Sendfile-specific flag(s) - */ -#define SF_NODISKIO 0x00000001 -#define SF_MNOWAIT 0x00000002 -#define SF_SYNC 0x00000004 -#endif - -#ifndef _KERNEL - -#include - -__BEGIN_DECLS -int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); -int bind(int, const struct sockaddr *, socklen_t); -int connect(int, const struct sockaddr *, socklen_t); -int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); -int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); -int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); -int listen(int, int); -ssize_t recv(int, void *, size_t, int); -ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); -ssize_t recvmsg(int, struct msghdr *, int); -ssize_t send(int, const void *, size_t, int); -ssize_t sendto(int, const void *, - size_t, int, const struct sockaddr *, socklen_t); -ssize_t sendmsg(int, const struct msghdr *, int); -#if __BSD_VISIBLE -int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); -int setfib(int); -#endif -int setsockopt(int, int, int, const void *, socklen_t); -int shutdown(int, int); -int sockatmark(int); -int socket(int, int, int); -int socketpair(int, int, int, int *); -__END_DECLS - -#endif /* !_KERNEL */ - -#ifdef _KERNEL -struct socket; - -struct tcpcb *so_sototcpcb(struct socket *so); -struct inpcb *so_sotoinpcb(struct socket *so); -struct sockbuf *so_sockbuf_snd(struct socket *); -struct sockbuf *so_sockbuf_rcv(struct socket *); - -int so_state_get(const struct socket *); -void so_state_set(struct socket *, int); - -int so_options_get(const struct socket *); -void so_options_set(struct socket *, int); - -int so_error_get(const struct socket *); -void so_error_set(struct socket *, int); - -int so_linger_get(const struct socket *); -void so_linger_set(struct socket *, int); - -struct protosw *so_protosw_get(const struct socket *); -void so_protosw_set(struct socket *, struct protosw *); - -void so_sorwakeup_locked(struct socket *so); -void so_sowwakeup_locked(struct socket *so); - -void so_sorwakeup(struct socket *so); -void so_sowwakeup(struct socket *so); - -void so_lock(struct socket *so); -void so_unlock(struct socket *so); - -void so_listeners_apply_all(struct socket *so, void (*func)(struct socket *, void *), void *arg); - -#endif - - -#endif /* !_SYS_SOCKET_HH_ */ diff --git a/freebsd/sys/socketvar.h b/freebsd/sys/socketvar.h deleted file mode 100644 index 6eeec9b6..00000000 --- a/freebsd/sys/socketvar.h +++ /dev/null @@ -1,393 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 - * - * $FreeBSD$ - */ - -#ifndef _SYS_SOCKETVAR_HH_ -#define _SYS_SOCKETVAR_HH_ - -#include /* for TAILQ macros */ -#include /* for struct selinfo */ -#include -#include -#include -#include -#include -#ifdef _KERNEL -#include -#endif - -struct vnet; - -/* - * Kernel structure per socket. - * Contains send and receive buffer queues, - * handle on protocol and pointer to protocol - * private data and error information. - */ -typedef u_quad_t so_gen_t; - -struct socket; - -/*- - * Locking key to struct socket: - * (a) constant after allocation, no locking required. - * (b) locked by SOCK_LOCK(so). - * (c) locked by SOCKBUF_LOCK(&so->so_rcv). - * (d) locked by SOCKBUF_LOCK(&so->so_snd). - * (e) locked by ACCEPT_LOCK(). - * (f) not locked since integer reads/writes are atomic. - * (g) used only as a sleep/wakeup address, no value. - * (h) locked by global mutex so_global_mtx. - */ -struct socket { - int so_count; /* (b) reference count */ - short so_type; /* (a) generic type, see socket.h */ - short so_options; /* from socket call, see socket.h */ - short so_linger; /* time to linger while closing */ - short so_state; /* (b) internal state flags SS_* */ - int so_qstate; /* (e) internal state flags SQ_* */ - void *so_pcb; /* protocol control block */ - struct vnet *so_vnet; /* network stack instance */ - struct protosw *so_proto; /* (a) protocol handle */ -/* - * Variables for connection queuing. - * Socket where accepts occur is so_head in all subsidiary sockets. - * If so_head is 0, socket is not related to an accept. - * For head socket so_incomp queues partially completed connections, - * while so_comp is a queue of connections ready to be accepted. - * If a connection is aborted and it has so_head set, then - * it has to be pulled out of either so_incomp or so_comp. - * We allow connections to queue up based on current queue lengths - * and limit on number of queued connections for this socket. - */ - struct socket *so_head; /* (e) back pointer to listen socket */ - TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted connections */ - TAILQ_HEAD(, socket) so_comp; /* (e) queue of complete unaccepted connections */ - TAILQ_ENTRY(socket) so_list; /* (e) list of unaccepted connections */ - u_short so_qlen; /* (e) number of unaccepted connections */ - u_short so_incqlen; /* (e) number of unaccepted incomplete - connections */ - u_short so_qlimit; /* (e) max number queued connections */ - short so_timeo; /* (g) connection timeout */ - u_short so_error; /* (f) error affecting connection */ - struct sigio *so_sigio; /* [sg] information for async I/O or - out of band data (SIGURG) */ - u_long so_oobmark; /* (c) chars to oob mark */ - TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */ - - struct sockbuf so_rcv, so_snd; - - struct ucred *so_cred; /* (a) user credentials */ - struct label *so_label; /* (b) MAC label for socket */ - struct label *so_peerlabel; /* (b) cached MAC label for peer */ - /* NB: generation count must not be first. */ - so_gen_t so_gencnt; /* (h) generation count */ - void *so_emuldata; /* (b) private data for emulators */ - struct so_accf { - struct accept_filter *so_accept_filter; - void *so_accept_filter_arg; /* saved filter args */ - char *so_accept_filter_str; /* saved user args */ - } *so_accf; - int so_fibnum; /* routing domain for this socket */ -}; - -/* - * Global accept mutex to serialize access to accept queues and - * fields associated with multiple sockets. This allows us to - * avoid defining a lock order between listen and accept sockets - * until such time as it proves to be a good idea. - */ -extern struct mtx accept_mtx; -#define ACCEPT_LOCK_ASSERT() mtx_assert(&accept_mtx, MA_OWNED) -#define ACCEPT_UNLOCK_ASSERT() mtx_assert(&accept_mtx, MA_NOTOWNED) -#define ACCEPT_LOCK() mtx_lock(&accept_mtx) -#define ACCEPT_UNLOCK() mtx_unlock(&accept_mtx) - -/* - * Per-socket mutex: we reuse the receive socket buffer mutex for space - * efficiency. This decision should probably be revisited as we optimize - * locking for the socket code. - */ -#define SOCK_MTX(_so) SOCKBUF_MTX(&(_so)->so_rcv) -#define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv) -#define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv) -#define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv) -#define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv) - -/* - * Socket state bits stored in so_qstate. - */ -#define SQ_INCOMP 0x0800 /* unaccepted, incomplete connection */ -#define SQ_COMP 0x1000 /* unaccepted, complete connection */ - -/* - * Externalized form of struct socket used by the sysctl(3) interface. - */ -struct xsocket { - size_t xso_len; /* length of this structure */ - struct socket *xso_so; /* makes a convenient handle sometimes */ - short so_type; - short so_options; - short so_linger; - short so_state; - caddr_t so_pcb; /* another convenient handle */ - int xso_protocol; - int xso_family; - u_short so_qlen; - u_short so_incqlen; - u_short so_qlimit; - short so_timeo; - u_short so_error; - pid_t so_pgid; - u_long so_oobmark; - struct xsockbuf so_rcv, so_snd; - uid_t so_uid; /* XXX */ -}; - -#ifdef _KERNEL - -/* - * Macros for sockets and socket buffering. - */ - -/* - * Flags to sblock(). - */ -#define SBL_WAIT 0x00000001 /* Wait if not immediately available. */ -#define SBL_NOINTR 0x00000002 /* Force non-interruptible sleep. */ -#define SBL_VALID (SBL_WAIT | SBL_NOINTR) - -/* - * Do we need to notify the other side when I/O is possible? - */ -#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \ - SB_UPCALL | SB_AIO | SB_KNOTE)) != 0) - -/* do we have to send all at once on a socket? */ -#define sosendallatonce(so) \ - ((so)->so_proto->pr_flags & PR_ATOMIC) - -/* can we read something from so? */ -#define soreadabledata(so) \ - ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \ - !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error) -#define soreadable(so) \ - (soreadabledata(so) || ((so)->so_rcv.sb_state & SBS_CANTRCVMORE)) - -/* can we write something to so? */ -#define sowriteable(so) \ - ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \ - (((so)->so_state&SS_ISCONNECTED) || \ - ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \ - ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \ - (so)->so_error) - -/* - * soref()/sorele() ref-count the socket structure. Note that you must - * still explicitly close the socket, but the last ref count will free - * the structure. - */ -#define soref(so) do { \ - SOCK_LOCK_ASSERT(so); \ - ++(so)->so_count; \ -} while (0) - -#define sorele(so) do { \ - ACCEPT_LOCK_ASSERT(); \ - SOCK_LOCK_ASSERT(so); \ - if ((so)->so_count <= 0) \ - panic("sorele"); \ - if (--(so)->so_count == 0) \ - sofree(so); \ - else { \ - SOCK_UNLOCK(so); \ - ACCEPT_UNLOCK(); \ - } \ -} while (0) - -#define sotryfree(so) do { \ - ACCEPT_LOCK_ASSERT(); \ - SOCK_LOCK_ASSERT(so); \ - if ((so)->so_count == 0) \ - sofree(so); \ - else { \ - SOCK_UNLOCK(so); \ - ACCEPT_UNLOCK(); \ - } \ -} while(0) - -/* - * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to - * avoid a non-atomic test-and-wakeup. However, sowakeup is - * responsible for releasing the lock if it is called. We unlock only - * if we don't call into sowakeup. If any code is introduced that - * directly invokes the underlying sowakeup() primitives, it must - * maintain the same semantics. - */ -#define sorwakeup_locked(so) do { \ - SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \ - if (sb_notify(&(so)->so_rcv)) \ - sowakeup((so), &(so)->so_rcv); \ - else \ - SOCKBUF_UNLOCK(&(so)->so_rcv); \ -} while (0) - -#define sorwakeup(so) do { \ - SOCKBUF_LOCK(&(so)->so_rcv); \ - sorwakeup_locked(so); \ -} while (0) - -#define sowwakeup_locked(so) do { \ - SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \ - if (sb_notify(&(so)->so_snd)) \ - sowakeup((so), &(so)->so_snd); \ - else \ - SOCKBUF_UNLOCK(&(so)->so_snd); \ -} while (0) - -#define sowwakeup(so) do { \ - SOCKBUF_LOCK(&(so)->so_snd); \ - sowwakeup_locked(so); \ -} while (0) - -struct accept_filter { - char accf_name[16]; - int (*accf_callback) - (struct socket *so, void *arg, int waitflag); - void * (*accf_create) - (struct socket *so, char *arg); - void (*accf_destroy) - (struct socket *so); - SLIST_ENTRY(accept_filter) accf_next; -}; - -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_ACCF); -MALLOC_DECLARE(M_PCB); -MALLOC_DECLARE(M_SONAME); -#endif - -extern int maxsockets; -extern u_long sb_max; -extern struct uma_zone *socket_zone; -extern so_gen_t so_gencnt; - -struct mbuf; -struct sockaddr; -struct ucred; -struct uio; - -/* 'which' values for socket upcalls. */ -#define SO_RCV 1 -#define SO_SND 2 - -/* Return values for socket upcalls. */ -#define SU_OK 0 -#define SU_ISCONNECTED 1 - -/* - * From uipc_socket and friends - */ -int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type); -int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len); -void soabort(struct socket *so); -int soaccept(struct socket *so, struct sockaddr **nam); -int socheckuid(struct socket *so, uid_t uid); -int sobind(struct socket *so, struct sockaddr *nam, struct thread *td); -int soclose(struct socket *so); -int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td); -int soconnect2(struct socket *so1, struct socket *so2); -int socow_setup(struct mbuf *m0, struct uio *uio); -int socreate(int dom, struct socket **aso, int type, int proto, - struct ucred *cred, struct thread *td); -int sodisconnect(struct socket *so); -struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags); -void sofree(struct socket *so); -void sohasoutofband(struct socket *so); -int solisten(struct socket *so, int backlog, struct thread *td); -void solisten_proto(struct socket *so, int backlog); -int solisten_proto_check(struct socket *so); -struct socket * - sonewconn(struct socket *head, int connstatus); - - -int sopoll(struct socket *so, int events, struct ucred *active_cred, - struct thread *td); -int sopoll_generic(struct socket *so, int events, - struct ucred *active_cred, struct thread *td); -int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio, - struct mbuf **mp0, struct mbuf **controlp, int *flagsp); -int soreceive_stream(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); -int soreceive_dgram(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); -int soreceive_generic(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); -int soreserve(struct socket *so, u_long sndcc, u_long rcvcc); -void sorflush(struct socket *so); -int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, - struct mbuf *top, struct mbuf *control, int flags, - struct thread *td); -int sosend_dgram(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, - int flags, struct thread *td); -int sosend_generic(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, - int flags, struct thread *td); -int soshutdown(struct socket *so, int how); -void sotoxsocket(struct socket *so, struct xsocket *xso); -void soupcall_clear(struct socket *so, int which); -void soupcall_set(struct socket *so, int which, - int (*func)(struct socket *, void *, int), void *arg); -void sowakeup(struct socket *so, struct sockbuf *sb); -int selsocket(struct socket *so, int events, struct timeval *tv, - struct thread *td); - -/* - * Accept filter functions (duh). - */ -int accept_filt_add(struct accept_filter *filt); -int accept_filt_del(char *name); -struct accept_filter *accept_filt_get(char *name); -#ifdef ACCEPT_FILTER_MOD -#ifdef SYSCTL_DECL -SYSCTL_DECL(_net_inet_accf); -#endif -int accept_filt_generic_mod_event(module_t mod, int event, void *data); -#endif - -#endif /* _KERNEL */ - -#endif /* !_SYS_SOCKETVAR_HH_ */ diff --git a/freebsd/sys/sparc/include/machine/in_cksum.h b/freebsd/sys/sparc/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/sparc/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/sparc/include/machine/legacyvar.h b/freebsd/sys/sparc/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/sparc/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/sparc/include/machine/pci_cfgreg.h b/freebsd/sys/sparc/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/sparc/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/sparc/pci/pci_bus.c b/freebsd/sys/sparc/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/sparc/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/sparc/sparc/in_cksum.c b/freebsd/sys/sparc/sparc/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/sparc/sparc/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/sparc/sparc/legacy.c b/freebsd/sys/sparc/sparc/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/sparc/sparc/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/sparc64/include/machine/asi.h b/freebsd/sys/sparc64/include/machine/asi.h index 83a42ff3..e5769c12 100644 --- a/freebsd/sys/sparc64/include/machine/asi.h +++ b/freebsd/sys/sparc64/include/machine/asi.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_ASI_HH_ -#define _MACHINE_ASI_HH_ +#ifndef _MACHINE_ASI_H_ +#define _MACHINE_ASI_H_ /* * Standard v9 ASIs @@ -257,4 +257,4 @@ #define ASI_BLK_PL 0xf8 #define ASI_BLK_SL 0xf9 -#endif /* !_MACHINE_ASI_HH_ */ +#endif /* !_MACHINE_ASI_H_ */ diff --git a/freebsd/sys/sparc64/include/machine/cpufunc.h b/freebsd/sys/sparc64/include/machine/cpufunc.h index 7805abc4..60533f83 100644 --- a/freebsd/sys/sparc64/include/machine/cpufunc.h +++ b/freebsd/sys/sparc64/include/machine/cpufunc.h @@ -26,11 +26,11 @@ * $FreeBSD$ */ -#ifndef _MACHINE_CPUFUNC_HH_ -#define _MACHINE_CPUFUNC_HH_ +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ -#include -#include +#include +#include struct thread; @@ -265,4 +265,4 @@ ffs(int mask) #undef LDNC_GEN #undef STNC_GEN -#endif /* !_MACHINE_CPUFUNC_HH_ */ +#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/freebsd/sys/sparc64/include/machine/in_cksum.h b/freebsd/sys/sparc64/include/machine/in_cksum.h new file mode 100644 index 00000000..ae06a4cb --- /dev/null +++ b/freebsd/sys/sparc64/include/machine/in_cksum.h @@ -0,0 +1,171 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + */ +/*- + * Copyright (c) 2001 by Thomas Moestl . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: FreeBSD: src/sys/alpha/include/in_cksum.h,v 1.5 2000/05/06 + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmp; + + __tmp = (int)ip->ip_sum + 1; + ip->ip_sum = __tmp + (__tmp >> 16); +} + +static __inline u_short +in_addword(u_short sum, u_short b) +{ + u_long __ret, __tmp; + + __asm( + "sll %2, 16, %0\n" + "sll %3, 16, %1\n" + "addcc %0, %1, %0\n" + "srl %0, 16, %0\n" + "addc %0, 0, %0\n" + : "=&r" (__ret), "=&r" (__tmp) : "r" (sum), "r" (b) : "cc"); + return (__ret); +} + +static __inline u_short +in_pseudo(u_int sum, u_int b, u_int c) +{ + u_long __tmp; + + __asm( + "addcc %0, %3, %0\n" + "addccc %0, %4, %0\n" + "addc %0, 0, %0\n" + "sll %0, 16, %1\n" + "addcc %0, %1, %0\n" + "srl %0, 16, %0\n" + "addc %0, 0, %0\n" + : "=r" (sum), "=&r" (__tmp) : "0" (sum), "r" (b), "r" (c) : "cc"); + return (sum); +} + +static __inline u_int +in_cksum_hdr(struct ip *ip) +{ + u_long __ret, __tmp1, __tmp2, __tmp3, __tmp4; + + /* + * Use 32-bit memory accesses and additions - addition with carry only + * works for 32 bits, and fixing up alignment issues for 64 is probably + * more trouble than it's worth. + * This may read outside of the ip header, but does not cross a page + * boundary in doing so, so that should be OK. + * Actually, this specialized implementation might be overkill - using + * a generic implementation for both in_cksum_skip and in_cksum_hdr + * should not be too much more expensive. + */ +#define __LD_ADD(addr, tmp, sum, offs, mod) \ + "lduw [" #addr " + " #offs "], " #tmp "\n" \ + "add" # mod " " #sum ", " #tmp ", " #sum "\n" + + __asm( + "and %5, 3, %3\n" + "andn %5, 3, %1\n" + "brz,pt %3, 0f\n" + " lduw [%1], %0\n" + "mov 4, %4\n" + "sub %4, %3, %4\n" + "sll %4, 3, %4\n" /* fix up unaligned buffers */ + "mov 1, %2\n" + "sll %2, %4, %4\n" + "sub %4, 1, %4\n" + "lduw [%1 + 20], %2\n" + "andn %2, %4, %2\n" + "and %0, %4, %0\n" + "or %0, %2, %0\n" + "0:\n" + __LD_ADD(%1, %2, %0, 4, cc) + __LD_ADD(%1, %2, %0, 8, ccc) + __LD_ADD(%1, %2, %0, 12, ccc) + __LD_ADD(%1, %2, %0, 16, ccc) + "addc %0, 0, %0\n" /* reduce */ + "1:\n" + "sll %0, 16, %2\n" + "addcc %0, %2, %0\n" + "srl %0, 16, %0\n" + "addc %0, 0, %0\n" + "andcc %3, 1, %3\n" /* need to byte-swap? */ + "clr %3\n" + "bne,a,pn %%xcc, 1b\n" + " sll %0, 8, %0\n" + "not %0\n" + "sll %0, 16, %0\n" + "srl %0, 16, %0\n" + : "=&r" (__ret), "=r" (__tmp1), "=&r" (__tmp2), "=&r" (__tmp3), + "=&r" (__tmp4) : "1" (ip) : "cc"); +#undef __LD_ADD + return (__ret); +} + +#ifdef _KERNEL +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/sparc64/include/machine/legacyvar.h b/freebsd/sys/sparc64/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/sparc64/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/sparc64/include/machine/pci_cfgreg.h b/freebsd/sys/sparc64/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/sparc64/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/sparc64/include/machine/pstate.h b/freebsd/sys/sparc64/include/machine/pstate.h index 19d98be5..4f536303 100644 --- a/freebsd/sys/sparc64/include/machine/pstate.h +++ b/freebsd/sys/sparc64/include/machine/pstate.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _MACHINE_PSTATE_HH_ -#define _MACHINE_PSTATE_HH_ +#ifndef _MACHINE_PSTATE_H_ +#define _MACHINE_PSTATE_H_ #define PSTATE_AG (1<<0) #define PSTATE_IE (1<<1) @@ -60,4 +60,4 @@ #define PSTATE_SECURE(pstate) \ (((pstate) & ~(PSTATE_AM|PSTATE_MM_MASK)) == (PSTATE_IE|PSTATE_PEF)) -#endif /* !_MACHINE_PSTATE_HH_ */ +#endif /* !_MACHINE_PSTATE_H_ */ diff --git a/freebsd/sys/sparc64/pci/pci_bus.c b/freebsd/sys/sparc64/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/sparc64/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/sparc64/sparc64/in_cksum.c b/freebsd/sys/sparc64/sparc64/in_cksum.c index 5490d005..f023f767 100644 --- a/freebsd/sys/sparc64/sparc64/in_cksum.c +++ b/freebsd/sys/sparc64/sparc64/in_cksum.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 1990 The Regents of the University of California. @@ -57,18 +57,18 @@ * from: FreeBSD: src/sys/i386/i386/in_cksum.c,v 1.22 2000/11/25 */ -#include +#include __FBSDID("$FreeBSD$"); -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -#include +#include /* * Checksum routine for Internet Protocol family headers. diff --git a/freebsd/sys/sparc64/sparc64/legacy.c b/freebsd/sys/sparc64/sparc64/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/sparc64/sparc64/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/stat.h b/freebsd/sys/stat.h deleted file mode 100644 index 936ffd88..00000000 --- a/freebsd/sys/stat.h +++ /dev/null @@ -1 +0,0 @@ -/* EMPTY */ diff --git a/freebsd/sys/sys/_bus_dma.h b/freebsd/sys/sys/_bus_dma.h index 8d60c957..91318d01 100644 --- a/freebsd/sys/sys/_bus_dma.h +++ b/freebsd/sys/sys/_bus_dma.h @@ -27,8 +27,8 @@ * */ -#ifndef _SYS__BUS_DMA_HH_ -#define _SYS__BUS_DMA_HH_ +#ifndef _SYS__BUS_DMA_H_ +#define _SYS__BUS_DMA_H_ typedef int bus_dmasync_op_t; @@ -60,4 +60,4 @@ typedef enum { typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t); -#endif /* !_SYS__BUS_DMA_HH_ */ +#endif /* !_SYS__BUS_DMA_H_ */ diff --git a/freebsd/sys/sys/_lock.h b/freebsd/sys/sys/_lock.h index eb13f2aa..457ffd4d 100644 --- a/freebsd/sys/sys/_lock.h +++ b/freebsd/sys/sys/_lock.h @@ -28,9 +28,13 @@ * $FreeBSD$ */ -#ifndef _SYS__LOCK_HH_ -#define _SYS__LOCK_HH_ +#ifndef _SYS__LOCK_H_ +#define _SYS__LOCK_H_ +#ifdef __rtems__ +#include +#include +#endif struct lock_object { #ifdef __rtems__ rtems_chain_node lo_node; @@ -44,4 +48,4 @@ struct lock_object { #endif /* __rtems__ */ }; -#endif /* !_SYS__LOCK_HH_ */ +#endif /* !_SYS__LOCK_H_ */ diff --git a/freebsd/sys/sys/_lockmgr.h b/freebsd/sys/sys/_lockmgr.h index 616cae4e..0b99e1a4 100644 --- a/freebsd/sys/sys/_lockmgr.h +++ b/freebsd/sys/sys/_lockmgr.h @@ -28,11 +28,11 @@ * $FreeBSD$ */ -#ifndef _SYS__LOCKMGR_HH_ -#define _SYS__LOCKMGR_HH_ +#ifndef _SYS__LOCKMGR_H_ +#define _SYS__LOCKMGR_H_ #ifdef DEBUG_LOCKS -#include +#include #endif struct lock { diff --git a/freebsd/sys/sys/_mutex.h b/freebsd/sys/sys/_mutex.h index eac45780..9bf2d39f 100644 --- a/freebsd/sys/sys/_mutex.h +++ b/freebsd/sys/sys/_mutex.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS__MUTEX_HH_ -#define _SYS__MUTEX_HH_ +#ifndef _SYS__MUTEX_H_ +#define _SYS__MUTEX_H_ /* * Sleep/spin mutex. @@ -41,4 +41,4 @@ struct mtx { #endif /* __rtems__ */ }; -#endif /* !_SYS__MUTEX_HH_ */ +#endif /* !_SYS__MUTEX_H_ */ diff --git a/freebsd/sys/sys/_rmlock.h b/freebsd/sys/sys/_rmlock.h index 87fe1ee8..dba7affd 100644 --- a/freebsd/sys/sys/_rmlock.h +++ b/freebsd/sys/sys/_rmlock.h @@ -29,14 +29,14 @@ * $FreeBSD$ */ -#ifndef _SYS__RMLOCK_HH_ -#define _SYS__RMLOCK_HH_ +#ifndef _SYS__RMLOCK_H_ +#define _SYS__RMLOCK_H_ /* * XXXUPS remove as soon as we have per cpu variable * linker sets and can define rm_queue in _rm_lock.h */ -#include +#include /* * Mostly reader/occasional writer lock. */ @@ -52,7 +52,7 @@ struct rmlock { }; #else /* __rtems__ */ - #include + #include #define rmlock rwlock #endif /* __rtems__ */ @@ -64,4 +64,4 @@ struct rm_priotracker { LIST_ENTRY(rm_priotracker) rmp_qentry; }; -#endif /* !_SYS__RMLOCK_HH_ */ +#endif /* !_SYS__RMLOCK_H_ */ diff --git a/freebsd/sys/sys/_rwlock.h b/freebsd/sys/sys/_rwlock.h index 536ba1dd..c5adac0e 100644 --- a/freebsd/sys/sys/_rwlock.h +++ b/freebsd/sys/sys/_rwlock.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef _SYS__RWLOCK_HH_ -#define _SYS__RWLOCK_HH_ +#ifndef _SYS__RWLOCK_H_ +#define _SYS__RWLOCK_H_ /* * Reader/writer lock. @@ -40,4 +40,4 @@ struct rwlock { volatile uintptr_t rw_lock; }; -#endif /* !_SYS__RWLOCK_HH_ */ +#endif /* !_SYS__RWLOCK_H_ */ diff --git a/freebsd/sys/sys/_semaphore.h b/freebsd/sys/sys/_semaphore.h index e0d5eff2..df3c5da1 100644 --- a/freebsd/sys/sys/_semaphore.h +++ b/freebsd/sys/sys/_semaphore.h @@ -25,15 +25,15 @@ * * $FreeBSD$ */ -#ifndef __SEMAPHORE_HH_ -#define __SEMAPHORE_HH_ +#ifndef __SEMAPHORE_H_ +#define __SEMAPHORE_H_ typedef intptr_t semid_t; struct timespec; #ifndef _KERNEL -#include +#include /* * Semaphore definitions. @@ -70,4 +70,4 @@ __END_DECLS #endif /* !_KERNEL */ -#endif /* __SEMAPHORE_HH_ */ +#endif /* __SEMAPHORE_H_ */ diff --git a/freebsd/sys/sys/_sigset.h b/freebsd/sys/sys/_sigset.h index 52028110..06826701 100644 --- a/freebsd/sys/sys/_sigset.h +++ b/freebsd/sys/sys/_sigset.h @@ -35,8 +35,8 @@ * $FreeBSD$ */ -#ifndef _SYS__SIGSET_HH_ -#define _SYS__SIGSET_HH_ +#ifndef _SYS__SIGSET_H_ +#define _SYS__SIGSET_H_ /* * sigset_t macros. @@ -56,4 +56,4 @@ typedef struct __sigset { typedef unsigned int osigset_t; #endif -#endif /* !_SYS__SIGSET_HH_ */ +#endif /* !_SYS__SIGSET_H_ */ diff --git a/freebsd/sys/sys/_sx.h b/freebsd/sys/sys/_sx.h index ff8f821e..699316b6 100644 --- a/freebsd/sys/sys/_sx.h +++ b/freebsd/sys/sys/_sx.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS__SX_HH_ -#define _SYS__SX_HH_ +#ifndef _SYS__SX_H_ +#define _SYS__SX_H_ /* * Shared/exclusive lock main structure definition. @@ -41,4 +41,4 @@ struct sx { #endif /* __rtems__ */ }; -#endif /* !_SYS__SX_HH_ */ +#endif /* !_SYS__SX_H_ */ diff --git a/freebsd/sys/sys/_task.h b/freebsd/sys/sys/_task.h index efea7fc8..2a51e1b0 100644 --- a/freebsd/sys/sys/_task.h +++ b/freebsd/sys/sys/_task.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS__TASK_HH_ -#define _SYS__TASK_HH_ +#ifndef _SYS__TASK_H_ +#define _SYS__TASK_H_ -#include +#include /* * Each task includes a function which is called from @@ -47,4 +47,4 @@ struct task { void *ta_context; /* argument for handler */ }; -#endif /* !_SYS__TASK_HH_ */ +#endif /* !_SYS__TASK_H_ */ diff --git a/freebsd/sys/sys/_timeval.h b/freebsd/sys/sys/_timeval.h index 936ffd88..c1edd5c8 100644 --- a/freebsd/sys/sys/_timeval.h +++ b/freebsd/sys/sys/_timeval.h @@ -1 +1,56 @@ -/* EMPTY */ +/*- + * Copyright (c) 2002 Mike Barcroft + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS__TIMEVAL_H_ +#define _SYS__TIMEVAL_H_ + +#ifndef __rtems__ +#include + +#ifndef _SUSECONDS_T_DECLARED +typedef __suseconds_t suseconds_t; +#define _SUSECONDS_T_DECLARED +#endif + +#ifndef _TIME_T_DECLARED +typedef __time_t time_t; +#define _TIME_T_DECLARED +#endif + +/* + * Structure returned by gettimeofday(2) system call, and used in other calls. + */ +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* and microseconds */ +}; +#else /* __rtems__ */ +#include +#endif /* __rtems__ */ + +#endif /* !_SYS__TIMEVAL_H_ */ diff --git a/freebsd/sys/sys/acl.h b/freebsd/sys/sys/acl.h index f8c20c73..ec2e025b 100644 --- a/freebsd/sys/sys/acl.h +++ b/freebsd/sys/sys/acl.h @@ -33,12 +33,12 @@ * Support for POSIX.1e and NFSv4 access control lists. */ -#ifndef _SYS_ACL_HH_ -#define _SYS_ACL_HH_ +#ifndef _SYS_ACL_H_ +#define _SYS_ACL_H_ -#include -#include -#include +#include +#include +#include /* * POSIX.1e and NFSv4 ACL types and related constants. @@ -404,4 +404,4 @@ __END_DECLS #endif /* !_KERNEL */ -#endif /* !_SYS_ACL_HH_ */ +#endif /* !_SYS_ACL_H_ */ diff --git a/freebsd/sys/sys/aio.h b/freebsd/sys/sys/aio.h index cff3d78c..03f6b34e 100644 --- a/freebsd/sys/sys/aio.h +++ b/freebsd/sys/sys/aio.h @@ -16,11 +16,11 @@ * $FreeBSD$ */ -#ifndef _SYS_AIO_HH_ -#define _SYS_AIO_HH_ +#ifndef _SYS_AIO_H_ +#define _SYS_AIO_H_ -#include -#include +#include +#include /* * Returned by aio_cancel: diff --git a/freebsd/sys/sys/ata.h b/freebsd/sys/sys/ata.h index df4cea71..cacb1ea0 100644 --- a/freebsd/sys/sys/ata.h +++ b/freebsd/sys/sys/ata.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_ATA_HH_ -#define _SYS_ATA_HH_ +#ifndef _SYS_ATA_H_ +#define _SYS_ATA_H_ -#include +#include /* ATA/ATAPI device parameters */ struct ata_params { @@ -557,4 +557,4 @@ struct ata_ioc_raid_status { #define IOCATARAIDADDSPARE _IOW('a', 203, struct ata_ioc_raid_config) #define IOCATARAIDREBUILD _IOW('a', 204, int) -#endif /* _SYS_ATA_HH_ */ +#endif /* _SYS_ATA_H_ */ diff --git a/freebsd/sys/sys/bitstring.h b/freebsd/sys/sys/bitstring.h index a2b70ba8..125ef51d 100644 --- a/freebsd/sys/sys/bitstring.h +++ b/freebsd/sys/sys/bitstring.h @@ -32,8 +32,8 @@ * $FreeBSD$ */ -#ifndef _SYS_BITSTRING_HH_ -#define _SYS_BITSTRING_HH_ +#ifndef _SYS_BITSTRING_H_ +#define _SYS_BITSTRING_H_ typedef unsigned char bitstr_t; @@ -143,4 +143,4 @@ typedef unsigned char bitstr_t; *(value) = _value; \ } while (0) -#endif /* !_SYS_BITSTRING_HH_ */ +#endif /* !_SYS_BITSTRING_H_ */ diff --git a/freebsd/sys/sys/buf.h b/freebsd/sys/sys/buf.h index 88e55d95..6cc68ee9 100644 --- a/freebsd/sys/sys/buf.h +++ b/freebsd/sys/sys/buf.h @@ -35,13 +35,13 @@ * $FreeBSD$ */ -#ifndef _SYS_BUF_HH_ -#define _SYS_BUF_HH_ +#ifndef _SYS_BUF_H_ +#define _SYS_BUF_H_ -#include -#include -#include -#include +#include +#include +#include +#include struct bio; struct buf; @@ -255,8 +255,8 @@ struct buf { */ extern const char *buf_wmesg; /* Default buffer lock message */ #define BUF_WMESG "bufwait" -#include /* XXX for curthread */ -#include +#include /* XXX for curthread */ +#include /* * Initialize a lock. @@ -333,7 +333,7 @@ extern const char *buf_wmesg; /* Default buffer lock message */ #define BUF_ASSERT_UNHELD(bp) #endif -#ifdef _SYS_PROC_HH_ /* Avoid #include pollution */ +#ifdef _SYS_PROC_H_ /* Avoid #include pollution */ /* * When initiating asynchronous I/O, change ownership of the lock to the * kernel. Once done, the lock may legally released by biodone. The @@ -523,4 +523,4 @@ void bunpin_wait(struct buf *); #endif /* _KERNEL */ -#endif /* !_SYS_BUF_HH_ */ +#endif /* !_SYS_BUF_H_ */ diff --git a/freebsd/sys/sys/buf_ring.h b/freebsd/sys/sys/buf_ring.h index dbdf6206..59853e42 100644 --- a/freebsd/sys/sys/buf_ring.h +++ b/freebsd/sys/sys/buf_ring.h @@ -27,18 +27,18 @@ * */ -#ifndef _SYS_BUF_RING_HH_ -#define _SYS_BUF_RING_HH_ +#ifndef _SYS_BUF_RING_H_ +#define _SYS_BUF_RING_H_ -#include +#include #if defined(INVARIANTS) && !defined(DEBUG_BUFRING) #define DEBUG_BUFRING 1 #endif #ifdef DEBUG_BUFRING -#include -#include +#include +#include #endif struct buf_ring { diff --git a/freebsd/sys/sys/bufobj.h b/freebsd/sys/sys/bufobj.h index 896e4ff8..916b2565 100644 --- a/freebsd/sys/sys/bufobj.h +++ b/freebsd/sys/sys/bufobj.h @@ -46,14 +46,14 @@ * once things starts to crystalize. */ -#ifndef _SYS_BUFOBJ_HH_ -#define _SYS_BUFOBJ_HH_ +#ifndef _SYS_BUFOBJ_H_ +#define _SYS_BUFOBJ_H_ #if defined(_KERNEL) || defined(_KVM_VNODE) -#include -#include -#include +#include +#include +#include struct bufobj; struct buf_ops; @@ -128,4 +128,4 @@ int bufsync(struct bufobj *bo, int waitfor); void bufbdflush(struct bufobj *bo, struct buf *bp); #endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ -#endif /* _SYS_BUFOBJ_HH_ */ +#endif /* _SYS_BUFOBJ_H_ */ diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h index 8dc54d08..6c1128e3 100644 --- a/freebsd/sys/sys/bus.h +++ b/freebsd/sys/sys/bus.h @@ -26,11 +26,11 @@ * $FreeBSD$ */ -#ifndef _SYS_BUS_HH_ -#define _SYS_BUS_HH_ +#ifndef _SYS_BUS_H_ +#define _SYS_BUS_H_ -#include -#include +#include +#include /** * @defgroup NEWBUS newbus - a generic framework for managing devices @@ -76,8 +76,8 @@ struct u_device { #ifdef _KERNEL -#include -#include +#include +#include /** * devctl hooks. Typically one should use the devctl_notify @@ -547,8 +547,8 @@ void bus_set_pass(int pass); /* * Some common device interfaces. */ -#include -#include +#include +#include struct module; @@ -745,4 +745,4 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \ bus_space_write_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) #endif /* _KERNEL */ -#endif /* !_SYS_BUS_HH_ */ +#endif /* !_SYS_BUS_H_ */ diff --git a/freebsd/sys/sys/bus_dma.h b/freebsd/sys/sys/bus_dma.h index 1bcde10a..0dad3267 100644 --- a/freebsd/sys/sys/bus_dma.h +++ b/freebsd/sys/sys/bus_dma.h @@ -69,10 +69,10 @@ */ /* $FreeBSD$ */ -#ifndef _BUS_DMA_HH_ -#define _BUS_DMA_HH_ +#ifndef _BUS_DMA_H_ +#define _BUS_DMA_H_ -#include +#include /* * Machine independent interface for mapping physical addresses to peripheral @@ -274,4 +274,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); #endif /* __sparc64__ */ -#endif /* _BUS_DMA_HH_ */ +#endif /* _BUS_DMA_H_ */ diff --git a/freebsd/sys/sys/callout.h b/freebsd/sys/sys/callout.h index 4686a4db..2d43d149 100644 --- a/freebsd/sys/sys/callout.h +++ b/freebsd/sys/sys/callout.h @@ -35,10 +35,10 @@ * $FreeBSD$ */ -#ifndef _SYS_CALLOUT_HH_ -#define _SYS_CALLOUT_HH_ +#ifndef _SYS_CALLOUT_H_ +#define _SYS_CALLOUT_H_ -#include +#include struct lock_object; @@ -100,4 +100,4 @@ void callout_tick(void); #endif -#endif /* _SYS_CALLOUT_HH_ */ +#endif /* _SYS_CALLOUT_H_ */ diff --git a/freebsd/sys/sys/condvar.h b/freebsd/sys/sys/condvar.h index 54cfe9eb..51da8170 100644 --- a/freebsd/sys/sys/condvar.h +++ b/freebsd/sys/sys/condvar.h @@ -26,11 +26,11 @@ * $FreeBSD$ */ -#ifndef _SYS_CONDVAR_HH_ -#define _SYS_CONDVAR_HH_ +#ifndef _SYS_CONDVAR_H_ +#define _SYS_CONDVAR_H_ #ifndef LOCORE -#include +#include struct lock_object; struct thread; @@ -43,6 +43,10 @@ TAILQ_HEAD(cv_waitq, thread); * and is held across calls to cv_signal() and cv_broadcast(). It is an * optimization to avoid looking up the sleep queue if there are no waiters. */ +#ifdef __rtems__ +#include +#include +#endif struct cv { #ifdef __rtems__ rtems_chain_node cv_node; @@ -84,4 +88,4 @@ void cv_broadcastpri(struct cv *cvp, int pri); #endif /* _KERNEL */ #endif /* !LOCORE */ -#endif /* _SYS_CONDVAR_HH_ */ +#endif /* _SYS_CONDVAR_H_ */ diff --git a/freebsd/sys/sys/conf.h b/freebsd/sys/sys/conf.h index 86e29c4d..694bbb36 100644 --- a/freebsd/sys/sys/conf.h +++ b/freebsd/sys/sys/conf.h @@ -37,13 +37,13 @@ * $FreeBSD$ */ -#ifndef _SYS_CONF_HH_ -#define _SYS_CONF_HH_ +#ifndef _SYS_CONF_H_ +#define _SYS_CONF_H_ #ifdef _KERNEL -#include +#include #else -#include +#include #endif struct snapdata; @@ -348,4 +348,4 @@ extern int dumping; /* system is dumping */ #endif /* _KERNEL */ -#endif /* !_SYS_CONF_HH_ */ +#endif /* !_SYS_CONF_H_ */ diff --git a/freebsd/sys/sys/cpu.h b/freebsd/sys/sys/cpu.h index 3e6729db..c16091e1 100644 --- a/freebsd/sys/sys/cpu.h +++ b/freebsd/sys/sys/cpu.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_CPU_HH_ -#define _SYS_CPU_HH_ +#ifndef _SYS_CPU_H_ +#define _SYS_CPU_H_ -#include +#include /* * CPU device support. @@ -170,4 +170,4 @@ EVENTHANDLER_DECLARE(cpufreq_levels_changed, cpufreq_levels_notify_fn); /* Estimate the current clock rate for the given CPU id. */ int cpu_est_clockrate(int cpu_id, uint64_t *rate); -#endif /* !_SYS_CPU_HH_ */ +#endif /* !_SYS_CPU_H_ */ diff --git a/freebsd/sys/sys/ctype.h b/freebsd/sys/sys/ctype.h index b7b4ad5a..5022d40c 100644 --- a/freebsd/sys/sys/ctype.h +++ b/freebsd/sys/sys/ctype.h @@ -34,8 +34,8 @@ * $FreeBSD$ */ -#ifndef _SYS_CTYPE_HH_ -#define _SYS_CTYPE_HH_ +#ifndef _SYS_CTYPE_H_ +#define _SYS_CTYPE_H_ #ifdef _KERNEL @@ -54,4 +54,4 @@ #define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z'))) #endif -#endif /* !_SYS_CTYPE_HH_ */ +#endif /* !_SYS_CTYPE_H_ */ diff --git a/freebsd/sys/sys/domain.h b/freebsd/sys/sys/domain.h index 0b44e9fd..2563cb6e 100644 --- a/freebsd/sys/sys/domain.h +++ b/freebsd/sys/sys/domain.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _SYS_DOMAIN_HH_ -#define _SYS_DOMAIN_HH_ +#ifndef _SYS_DOMAIN_H_ +#define _SYS_DOMAIN_H_ /* * Structure per communications domain. @@ -103,4 +103,4 @@ void vnet_domain_uninit(void *); #endif /* _KERNEL */ -#endif /* !_SYS_DOMAIN_HH_ */ +#endif /* !_SYS_DOMAIN_H_ */ diff --git a/freebsd/sys/sys/endian.h b/freebsd/sys/sys/endian.h index 5c95d748..921fac41 100644 --- a/freebsd/sys/sys/endian.h +++ b/freebsd/sys/sys/endian.h @@ -26,12 +26,12 @@ * $FreeBSD$ */ -#ifndef _SYS_ENDIAN_HH_ -#define _SYS_ENDIAN_HH_ +#ifndef _SYS_ENDIAN_H_ +#define _SYS_ENDIAN_H_ -#include -#include -#include +#include +#include +#include #ifndef _UINT16_T_DECLARED typedef __uint16_t uint16_t; @@ -197,4 +197,4 @@ le64enc(void *pp, uint64_t u) le32enc(p + 4, u >> 32); } -#endif /* _SYS_ENDIAN_HH_ */ +#endif /* _SYS_ENDIAN_H_ */ diff --git a/freebsd/sys/sys/event.h b/freebsd/sys/sys/event.h index 1af716d7..d92eb55d 100644 --- a/freebsd/sys/sys/event.h +++ b/freebsd/sys/sys/event.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_EVENT_HH_ -#define _SYS_EVENT_HH_ +#ifndef _SYS_EVENT_H_ +#define _SYS_EVENT_H_ -#include +#include #define EVFILT_READ (-1) #define EVFILT_WRITE (-2) @@ -264,7 +264,7 @@ extern int kqueue_del_filteropts(int filt); #else /* !_KERNEL */ -#include +#include struct timespec; __BEGIN_DECLS @@ -276,4 +276,4 @@ __END_DECLS #endif /* !_KERNEL */ -#endif /* !_SYS_EVENT_HH_ */ +#endif /* !_SYS_EVENT_H_ */ diff --git a/freebsd/sys/sys/eventhandler.h b/freebsd/sys/sys/eventhandler.h index 1472df18..0da999d0 100644 --- a/freebsd/sys/sys/eventhandler.h +++ b/freebsd/sys/sys/eventhandler.h @@ -29,10 +29,10 @@ #ifndef SYS_EVENTHANDLER_H #define SYS_EVENTHANDLER_H -#include -#include -#include -#include +#include +#include +#include +#include struct eventhandler_entry { TAILQ_ENTRY(eventhandler_entry) ee_link; diff --git a/freebsd/sys/sys/eventvar.h b/freebsd/sys/sys/eventvar.h index 8712cfdc..bdb3adf5 100644 --- a/freebsd/sys/sys/eventvar.h +++ b/freebsd/sys/sys/eventvar.h @@ -26,14 +26,14 @@ * $FreeBSD$ */ -#ifndef _SYS_EVENTVAR_HH_ -#define _SYS_EVENTVAR_HH_ +#ifndef _SYS_EVENTVAR_H_ +#define _SYS_EVENTVAR_H_ #ifndef _KERNEL #error "no user-servicable parts inside" #endif -#include +#include #define KQ_NEVENTS 8 /* minimize copy{in,out} calls */ #define KQEXTENT 256 /* linear growth by this amount */ @@ -62,4 +62,4 @@ struct kqueue { struct task kq_task; }; -#endif /* !_SYS_EVENTVAR_HH_ */ +#endif /* !_SYS_EVENTVAR_H_ */ diff --git a/freebsd/sys/sys/fcntl.h b/freebsd/sys/sys/fcntl.h index 82646c7f..00f79279 100644 --- a/freebsd/sys/sys/fcntl.h +++ b/freebsd/sys/sys/fcntl.h @@ -35,8 +35,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FCNTL_HH_ -#define _SYS_FCNTL_HH_ +#ifndef _SYS_FCNTL_H_ +#define _SYS_FCNTL_H_ /* * This file includes the definitions for open and fcntl @@ -44,8 +44,8 @@ * related kernel definitions. */ -#include -#include +#include +#include #ifndef _MODE_T_DECLARED typedef __mode_t mode_t; @@ -293,4 +293,4 @@ int flock(int, int); __END_DECLS #endif -#endif /* !_SYS_FCNTL_HH_ */ +#endif /* !_SYS_FCNTL_H_ */ diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h index 21b8e413..5ba6aee2 100644 --- a/freebsd/sys/sys/file.h +++ b/freebsd/sys/sys/file.h @@ -30,18 +30,18 @@ * $FreeBSD$ */ -#ifndef _SYS_FILE_HH_ -#define _SYS_FILE_HH_ +#ifndef _SYS_FILE_H_ +#define _SYS_FILE_H_ #ifndef _KERNEL -#include /* XXX */ -#include -#include +#include /* XXX */ +#include +#include #else -#include -#include -#include -#include +#include +#include +#include +#include struct stat; struct thread; diff --git a/freebsd/sys/sys/filedesc.h b/freebsd/sys/sys/filedesc.h index fab6d93b..718f2e8b 100644 --- a/freebsd/sys/sys/filedesc.h +++ b/freebsd/sys/sys/filedesc.h @@ -30,16 +30,16 @@ * $FreeBSD$ */ -#ifndef _SYS_FILEDESC_HH_ -#define _SYS_FILEDESC_HH_ +#ifndef _SYS_FILEDESC_H_ +#define _SYS_FILEDESC_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include /* * This structure is used for the management of descriptors. It may be @@ -142,4 +142,4 @@ fget_locked(struct filedesc *fdp, int fd) #endif /* _KERNEL */ -#endif /* !_SYS_FILEDESC_HH_ */ +#endif /* !_SYS_FILEDESC_H_ */ diff --git a/freebsd/sys/sys/filio.h b/freebsd/sys/sys/filio.h index 899d3458..1710ba45 100644 --- a/freebsd/sys/sys/filio.h +++ b/freebsd/sys/sys/filio.h @@ -35,10 +35,10 @@ * $FreeBSD$ */ -#ifndef _SYS_FILIO_HH_ -#define _SYS_FILIO_HH_ +#ifndef _SYS_FILIO_H_ +#define _SYS_FILIO_H_ -#include +#include /* Generic file-descriptor ioctl's. */ #define FIOCLEX _IO('f', 1) /* set close on exec on fd */ @@ -61,4 +61,4 @@ struct fiodgname_arg { #define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ #define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */ -#endif /* !_SYS_FILIO_HH_ */ +#endif /* !_SYS_FILIO_H_ */ diff --git a/freebsd/sys/sys/hash.h b/freebsd/sys/sys/hash.h index 91dd4fcc..fcbe6b69 100644 --- a/freebsd/sys/sys/hash.h +++ b/freebsd/sys/sys/hash.h @@ -26,9 +26,9 @@ * $FreeBSD$ */ -#ifndef _SYS_HASH_HH_ -#define _SYS_HASH_HH_ -#include +#ifndef _SYS_HASH_H_ +#define _SYS_HASH_H_ +#include /* Convenience */ #ifndef HASHINIT @@ -118,4 +118,4 @@ hash32_strne(const void *buf, size_t len, int end, const char **ep, return hash; } -#endif /* !_SYS_HASH_HH_ */ +#endif /* !_SYS_HASH_H_ */ diff --git a/freebsd/sys/sys/interrupt.h b/freebsd/sys/sys/interrupt.h index e43d0047..c1df1c76 100644 --- a/freebsd/sys/sys/interrupt.h +++ b/freebsd/sys/sys/interrupt.h @@ -26,11 +26,11 @@ * $FreeBSD$ */ -#ifndef _SYS_INTERRUPT_HH_ -#define _SYS_INTERRUPT_HH_ +#ifndef _SYS_INTERRUPT_H_ +#define _SYS_INTERRUPT_H_ -#include -#include +#include +#include struct intr_event; struct intr_thread; diff --git a/freebsd/sys/sys/jail.h b/freebsd/sys/sys/jail.h index f501c0b2..2e259f24 100644 --- a/freebsd/sys/sys/jail.h +++ b/freebsd/sys/sys/jail.h @@ -27,8 +27,8 @@ * $FreeBSD$ */ -#ifndef _SYS_JAIL_HH_ -#define _SYS_JAIL_HH_ +#ifndef _SYS_JAIL_H_ +#define _SYS_JAIL_H_ #ifdef _KERNEL struct jail_v0 { @@ -116,11 +116,11 @@ int jail_remove(int); #else /* _KERNEL */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define JAIL_MAX 999999 @@ -131,7 +131,7 @@ MALLOC_DECLARE(M_PRISON); #if defined(_KERNEL) || defined(_WANT_PRISON) -#include +#include #define HOSTUUIDLEN 64 @@ -382,4 +382,4 @@ int prison_priv_check(struct ucred *cred, int priv); int sysctl_jail_param(struct sysctl_oid *, void *, int , struct sysctl_req *); #endif /* _KERNEL */ -#endif /* !_SYS_JAIL_HH_ */ +#endif /* !_SYS_JAIL_H_ */ diff --git a/freebsd/sys/sys/kenv.h b/freebsd/sys/sys/kenv.h index 497eb2f2..0a30ddb3 100644 --- a/freebsd/sys/sys/kenv.h +++ b/freebsd/sys/sys/kenv.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _SYS_KENV_HH_ -#define _SYS_KENV_HH_ +#ifndef _SYS_KENV_H_ +#define _SYS_KENV_H_ /* * Constants for the kenv(2) syscall @@ -40,4 +40,4 @@ #define KENV_MNAMELEN 128 /* Maximum name length (for the syscall) */ #define KENV_MVALLEN 128 /* Maximum value length (for the syscall) */ -#endif /* !_SYS_KENV_HH_ */ +#endif /* !_SYS_KENV_H_ */ diff --git a/freebsd/sys/sys/kernel.h b/freebsd/sys/sys/kernel.h index 2bcc58ed..e2cc2678 100644 --- a/freebsd/sys/sys/kernel.h +++ b/freebsd/sys/sys/kernel.h @@ -42,15 +42,15 @@ * $FreeBSD$ */ -#ifndef _SYS_KERNEL_HH_ -#define _SYS_KERNEL_HH_ +#ifndef _SYS_KERNEL_H_ +#define _SYS_KERNEL_H_ -#include +#include #ifdef _KERNEL /* for intrhook below */ -#include +#include /* Global variables for the kernel. */ @@ -421,4 +421,4 @@ struct intr_config_hook { int config_intrhook_establish(struct intr_config_hook *hook); void config_intrhook_disestablish(struct intr_config_hook *hook); -#endif /* !_SYS_KERNEL_HH_*/ +#endif /* !_SYS_KERNEL_H_*/ diff --git a/freebsd/sys/sys/kobj.h b/freebsd/sys/sys/kobj.h index 385159aa..3143bea4 100644 --- a/freebsd/sys/sys/kobj.h +++ b/freebsd/sys/sys/kobj.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _SYS_KOBJ_HH_ -#define _SYS_KOBJ_HH_ +#ifndef _SYS_KOBJ_H_ +#define _SYS_KOBJ_H_ /* * Forward declarations @@ -254,4 +254,4 @@ kobj_method_t* kobj_lookup_method(kobj_class_t cls, */ int kobj_error_method(void); -#endif /* !_SYS_KOBJ_HH_ */ +#endif /* !_SYS_KOBJ_H_ */ diff --git a/freebsd/sys/sys/kthread.h b/freebsd/sys/sys/kthread.h index 6fe442e3..390463f3 100644 --- a/freebsd/sys/sys/kthread.h +++ b/freebsd/sys/sys/kthread.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_KTHREAD_HH_ -#define _SYS_KTHREAD_HH_ +#ifndef _SYS_KTHREAD_H_ +#define _SYS_KTHREAD_H_ -#include +#include /*- * A kernel process descriptor; used to start "internal" daemons. @@ -76,4 +76,4 @@ int kthread_suspend(struct thread *, int); void kthread_suspend_check(struct thread *); -#endif /* !_SYS_KTHREAD_HH_ */ +#endif /* !_SYS_KTHREAD_H_ */ diff --git a/freebsd/sys/sys/ktr.h b/freebsd/sys/sys/ktr.h index 3942b92e..5fbe2947 100644 --- a/freebsd/sys/sys/ktr.h +++ b/freebsd/sys/sys/ktr.h @@ -33,8 +33,8 @@ * Wraparound kernel trace buffer support. */ -#ifndef _SYS_KTR_HH_ -#define _SYS_KTR_HH_ +#ifndef _SYS_KTR_H_ +#define _SYS_KTR_H_ /* * Trace classes @@ -279,4 +279,4 @@ void ktr_tracepoint(u_int mask, const char *file, int line, #endif /* !LOCORE */ -#endif /* !_SYS_KTR_HH_ */ +#endif /* !_SYS_KTR_H_ */ diff --git a/freebsd/sys/sys/libkern.h b/freebsd/sys/sys/libkern.h index 943ac34b..4675caa3 100644 --- a/freebsd/sys/sys/libkern.h +++ b/freebsd/sys/sys/libkern.h @@ -30,13 +30,13 @@ * $FreeBSD$ */ -#ifndef _SYS_LIBKERN_HH_ -#define _SYS_LIBKERN_HH_ +#ifndef _SYS_LIBKERN_H_ +#define _SYS_LIBKERN_H_ -#include -#include +#include +#include #ifdef _KERNEL -#include +#include #endif #ifndef __rtems__ @@ -192,4 +192,4 @@ strrchr(const char *p, int ch) #define FNM_IGNORECASE FNM_CASEFOLD #define FNM_FILE_NAME FNM_PATHNAME -#endif /* !_SYS_LIBKERN_HH_ */ +#endif /* !_SYS_LIBKERN_H_ */ diff --git a/freebsd/sys/sys/limits.h b/freebsd/sys/sys/limits.h index b2850e20..633a7f70 100644 --- a/freebsd/sys/sys/limits.h +++ b/freebsd/sys/sys/limits.h @@ -1,9 +1,104 @@ -#include -#include +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * $FreeBSD$ + */ -#define __FD_SETSIZE 1024 -#define FD_SETSIZE __FD_SETSIZE +#ifndef _SYS_LIMITS_H_ +#define _SYS_LIMITS_H_ -#define __CHAR_BIT CHAR_BIT /* number of bits in a char */ +#include +#include +#ifndef __rtems__ +#define CHAR_BIT __CHAR_BIT /* number of bits in a char */ +#define SCHAR_MAX __SCHAR_MAX /* max value for a signed char */ +#define SCHAR_MIN __SCHAR_MIN /* min value for a signed char */ + +#define UCHAR_MAX __UCHAR_MAX /* max value for an unsigned char */ + +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MAX UCHAR_MAX /* max value for a char */ +#define CHAR_MIN 0 /* min value for a char */ +#else +#define CHAR_MAX SCHAR_MAX +#define CHAR_MIN SCHAR_MIN +#endif + +#define USHRT_MAX __USHRT_MAX /* max value for an unsigned short */ +#define SHRT_MAX __SHRT_MAX /* max value for a short */ +#define SHRT_MIN __SHRT_MIN /* min value for a short */ + +#define UINT_MAX __UINT_MAX /* max value for an unsigned int */ +#define INT_MAX __INT_MAX /* max value for an int */ +#define INT_MIN __INT_MIN /* min value for an int */ + +#define ULONG_MAX __ULONG_MAX /* max for an unsigned long */ +#define LONG_MAX __LONG_MAX /* max for a long */ +#define LONG_MIN __LONG_MIN /* min for a long */ + +#ifdef __LONG_LONG_SUPPORTED +#define ULLONG_MAX __ULLONG_MAX /* max for an unsigned long long */ +#define LLONG_MAX __LLONG_MAX /* max for a long long */ +#define LLONG_MIN __LLONG_MIN /* min for a long long */ +#endif + +#if __POSIX_VISIBLE || __XSI_VISIBLE +#define SSIZE_MAX __SSIZE_MAX /* max value for an ssize_t */ +#endif + +#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE +#define SIZE_T_MAX __SIZE_T_MAX /* max value for a size_t */ + +#define OFF_MAX __OFF_MAX /* max value for an off_t */ +#define OFF_MIN __OFF_MIN /* min value for an off_t */ +#endif +#endif /* __rtems__ */ + +#if __BSD_VISIBLE +#define GID_MAX UINT_MAX /* max value for a gid_t */ +#define UID_MAX UINT_MAX /* max value for a uid_t */ + +#define UQUAD_MAX (__UQUAD_MAX) /* max value for a uquad_t */ +#define QUAD_MAX (__QUAD_MAX) /* max value for a quad_t */ +#define QUAD_MIN (__QUAD_MIN) /* min value for a quad_t */ +#endif + +#ifndef __rtems__ +#if __XSI_VISIBLE +#define LONG_BIT __LONG_BIT +#define WORD_BIT __WORD_BIT +#endif + +#if __POSIX_VISIBLE +#define MQ_PRIO_MAX 64 +#endif +#endif /* __rtems__ */ + +#endif /* !_SYS_LIMITS_H_ */ diff --git a/freebsd/sys/sys/linker.h b/freebsd/sys/sys/linker.h index 449fa1ec..896b0c8c 100644 --- a/freebsd/sys/sys/linker.h +++ b/freebsd/sys/sys/linker.h @@ -26,13 +26,13 @@ * $FreeBSD$ */ -#ifndef _SYS_LINKER_HH_ -#define _SYS_LINKER_HH_ +#ifndef _SYS_LINKER_H_ +#define _SYS_LINKER_H_ #ifdef _KERNEL -#include -#include +#include +#include #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINKER); @@ -331,7 +331,7 @@ struct kld_sym_lookup { #ifndef _KERNEL -#include +#include __BEGIN_DECLS int kldload(const char* _file); @@ -346,4 +346,4 @@ __END_DECLS #endif -#endif /* !_SYS_LINKER_HH_ */ +#endif /* !_SYS_LINKER_H_ */ diff --git a/freebsd/sys/sys/linker_set.h b/freebsd/sys/sys/linker_set.h index 2dd056bc..fc04fe0d 100644 --- a/freebsd/sys/sys/linker_set.h +++ b/freebsd/sys/sys/linker_set.h @@ -27,8 +27,8 @@ * $FreeBSD$ */ -#ifndef _SYS_LINKER_SET_HH_ -#define _SYS_LINKER_SET_HH_ +#ifndef _SYS_LINKER_SET_H_ +#define _SYS_LINKER_SET_H_ #ifndef _SYS_CDEFS_H_ #error this file needs sys/cdefs.h as a prerequisite @@ -111,4 +111,4 @@ #define SET_COUNT(set) \ (SET_LIMIT(set) - SET_BEGIN(set)) -#endif /* _SYS_LINKER_SET_HH_ */ +#endif /* _SYS_LINKER_SET_H_ */ diff --git a/freebsd/sys/sys/lock_profile.h b/freebsd/sys/sys/lock_profile.h index 92eb512f..579113a7 100644 --- a/freebsd/sys/sys/lock_profile.h +++ b/freebsd/sys/sys/lock_profile.h @@ -28,16 +28,16 @@ */ -#ifndef _SYS_LOCK_PROFILE_HH_ -#define _SYS_LOCK_PROFILE_HH_ +#ifndef _SYS_LOCK_PROFILE_H_ +#define _SYS_LOCK_PROFILE_H_ struct lock_profile_object; LIST_HEAD(lpohead, lock_profile_object); #ifdef _KERNEL #ifdef LOCK_PROFILING -#include -#include +#include +#include #ifndef USE_CPU_NANOSECONDS u_int64_t nanoseconds(void); @@ -72,4 +72,4 @@ lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, #endif /* _KERNEL */ -#endif /* _SYS_LOCK_PROFILE_HH_ */ +#endif /* _SYS_LOCK_PROFILE_H_ */ diff --git a/freebsd/sys/sys/lockmgr.h b/freebsd/sys/sys/lockmgr.h index 2020eb83..3d0aad0b 100644 --- a/freebsd/sys/sys/lockmgr.h +++ b/freebsd/sys/sys/lockmgr.h @@ -28,13 +28,13 @@ * $FreeBSD$ */ -#ifndef _SYS_LOCKMGR_HH_ -#define _SYS_LOCKMGR_HH_ +#ifndef _SYS_LOCKMGR_H_ +#define _SYS_LOCKMGR_H_ -#include -#include -#include -#include +#include +#include +#include +#include #define LK_SHARE 0x01 #define LK_SHARED_WAITERS 0x02 @@ -56,7 +56,7 @@ #ifdef _KERNEL #if !defined(LOCK_FILE) || !defined(LOCK_LINE) -#error "LOCK_FILE and LOCK_LINE not defined, include before" +#error "LOCK_FILE and LOCK_LINE not defined, include before" #endif struct thread; @@ -192,4 +192,4 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk, #endif /* _KERNEL */ -#endif /* !_SYS_LOCKMGR_HH_ */ +#endif /* !_SYS_LOCKMGR_H_ */ diff --git a/freebsd/sys/sys/mac.h b/freebsd/sys/sys/mac.h index f261c7ff..0aa89608 100644 --- a/freebsd/sys/sys/mac.h +++ b/freebsd/sys/sys/mac.h @@ -44,8 +44,8 @@ * http://www.TrustedBSD.org/ */ -#ifndef _SYS_MAC_HH_ -#define _SYS_MAC_HH_ +#ifndef _SYS_MAC_H_ +#define _SYS_MAC_H_ #ifndef _POSIX_MAC #define _POSIX_MAC @@ -108,4 +108,4 @@ __END_DECLS #endif /* !_KERNEL */ -#endif /* !_SYS_MAC_HH_ */ +#endif /* !_SYS_MAC_H_ */ diff --git a/freebsd/sys/sys/malloc.h b/freebsd/sys/sys/malloc.h index faca480d..d70fd21c 100644 --- a/freebsd/sys/sys/malloc.h +++ b/freebsd/sys/sys/malloc.h @@ -32,13 +32,13 @@ * $FreeBSD$ */ -#ifndef _SYS_MALLOC_HH_ -#define _SYS_MALLOC_HH_ +#ifndef _SYS_MALLOC_H_ +#define _SYS_MALLOC_H_ -#include -#include -#include -#include +#include +#include +#include +#include #define MINALLOCSIZE UMA_SMALLEST_UNIT @@ -186,4 +186,4 @@ void *reallocf(void *addr, unsigned long size, struct malloc_type *type, struct malloc_type *malloc_desc2type(const char *desc); #endif /* _KERNEL */ -#endif /* !_SYS_MALLOC_HH_ */ +#endif /* !_SYS_MALLOC_H_ */ diff --git a/freebsd/sys/sys/mbuf.h b/freebsd/sys/sys/mbuf.h index 5988760e..148e9cd1 100644 --- a/freebsd/sys/sys/mbuf.h +++ b/freebsd/sys/sys/mbuf.h @@ -31,16 +31,16 @@ * $FreeBSD$ */ -#ifndef _SYS_MBUF_HH_ -#define _SYS_MBUF_HH_ +#ifndef _SYS_MBUF_H_ +#define _SYS_MBUF_H_ /* XXX: These includes suck. Sorry! */ -#include +#include #ifdef _KERNEL -#include -#include +#include +#include #ifdef WITNESS -#include +#include #endif #endif @@ -1029,4 +1029,4 @@ m_tag_find(struct mbuf *m, int type, struct m_tag *start) #endif -#endif /* !_SYS_MBUF_HH_ */ +#endif /* !_SYS_MBUF_H_ */ diff --git a/freebsd/sys/sys/md5.h b/freebsd/sys/sys/md5.h index 9bf97cd6..e98b7afb 100644 --- a/freebsd/sys/sys/md5.h +++ b/freebsd/sys/sys/md5.h @@ -25,8 +25,8 @@ These notices must be retained in any copies of any part of this documentation and/or software. */ -#ifndef _SYS_MD5_HH_ -#define _SYS_MD5_HH_ +#ifndef _SYS_MD5_H_ +#define _SYS_MD5_H_ #define MD5_BLOCK_LENGTH 64 #define MD5_DIGEST_LENGTH 16 @@ -39,7 +39,7 @@ typedef struct MD5Context { unsigned char buffer[64]; /* input buffer */ } MD5_CTX; -#include +#include __BEGIN_DECLS void MD5Init (MD5_CTX *); @@ -50,4 +50,4 @@ char * MD5File(const char *, char *); char * MD5FileChunk(const char *, char *, off_t, off_t); char * MD5Data(const void *, unsigned int, char *); __END_DECLS -#endif /* _SYS_MD5_HH_ */ +#endif /* _SYS_MD5_H_ */ diff --git a/freebsd/sys/sys/mman.h b/freebsd/sys/sys/mman.h index 2d90a14d..4872d631 100644 --- a/freebsd/sys/sys/mman.h +++ b/freebsd/sys/sys/mman.h @@ -1,3 +1,238 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)mman.h 8.2 (Berkeley) 1/9/95 + * $FreeBSD$ + */ +#ifndef _SYS_MMAN_H_ +#define _SYS_MMAN_H_ + +#include +#include + +#if __BSD_VISIBLE +/* + * Inheritance for minherit() + */ +#define INHERIT_SHARE 0 +#define INHERIT_COPY 1 +#define INHERIT_NONE 2 +#endif + +/* + * Protections are chosen from these bits, or-ed together + */ +#define PROT_NONE 0x00 /* no permissions */ +#define PROT_READ 0x01 /* pages can be read */ +#define PROT_WRITE 0x02 /* pages can be written */ +#define PROT_EXEC 0x04 /* pages can be executed */ + +/* + * Flags contain sharing type and options. + * Sharing types; choose one. + */ +#define MAP_SHARED 0x0001 /* share changes */ +#define MAP_PRIVATE 0x0002 /* changes are private */ +#if __BSD_VISIBLE +#define MAP_COPY MAP_PRIVATE /* Obsolete */ +#endif + +/* + * Other flags + */ +#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ + +#if __BSD_VISIBLE +#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ +#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ +#define MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */ +#define MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */ +#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ +#define MAP_STACK 0x0400 /* region grows down, like a stack */ +#define MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */ + +/* + * Mapping type + */ +#define MAP_FILE 0x0000 /* map from file (default) */ +#define MAP_ANON 0x1000 /* allocated from memory, swap space */ + +/* + * Extended flags + */ +#define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ +#endif /* __BSD_VISIBLE */ + +#if __POSIX_VISIBLE >= 199309 +/* + * Process memory locking + */ +#define MCL_CURRENT 0x0001 /* Lock only current memory */ +#define MCL_FUTURE 0x0002 /* Lock all future memory as well */ +#endif + +/* + * Error return from mmap() + */ +#define MAP_FAILED ((void *)-1) + +/* + * msync() flags + */ +#define MS_SYNC 0x0000 /* msync synchronously */ +#define MS_ASYNC 0x0001 /* return immediately */ +#define MS_INVALIDATE 0x0002 /* invalidate all cached data */ + +/* + * Advice to madvise + */ +#define _MADV_NORMAL 0 /* no further special treatment */ +#define _MADV_RANDOM 1 /* expect random page references */ +#define _MADV_SEQUENTIAL 2 /* expect sequential page references */ +#define _MADV_WILLNEED 3 /* will need these pages */ +#define _MADV_DONTNEED 4 /* dont need these pages */ + +#if __BSD_VISIBLE +#define MADV_NORMAL _MADV_NORMAL +#define MADV_RANDOM _MADV_RANDOM +#define MADV_SEQUENTIAL _MADV_SEQUENTIAL +#define MADV_WILLNEED _MADV_WILLNEED +#define MADV_DONTNEED _MADV_DONTNEED +#define MADV_FREE 5 /* dont need these pages, and junk contents */ +#define MADV_NOSYNC 6 /* try to avoid flushes to physical media */ +#define MADV_AUTOSYNC 7 /* revert to default flushing strategy */ +#define MADV_NOCORE 8 /* do not include these pages in a core file */ +#define MADV_CORE 9 /* revert to including pages in a core file */ +#define MADV_PROTECT 10 /* protect process from pageout kill */ + +/* + * Return bits from mincore + */ +#define MINCORE_INCORE 0x1 /* Page is incore */ +#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */ +#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ +#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ +#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ +#define MINCORE_SUPER 0x20 /* Page is a "super" page */ + +/* + * Anonymous object constant for shm_open(). + */ +#define SHM_ANON ((char *)1) +#endif /* __BSD_VISIBLE */ + +/* + * XXX missing POSIX_TYPED_MEM_* macros and + * posix_typed_mem_info structure. + */ +#if __POSIX_VISIBLE >= 200112 +#define POSIX_MADV_NORMAL _MADV_NORMAL +#define POSIX_MADV_RANDOM _MADV_RANDOM +#define POSIX_MADV_SEQUENTIAL _MADV_SEQUENTIAL +#define POSIX_MADV_WILLNEED _MADV_WILLNEED +#define POSIX_MADV_DONTNEED _MADV_DONTNEED +#endif + +#ifndef _MODE_T_DECLARED +typedef __mode_t mode_t; +#define _MODE_T_DECLARED +#endif + +#ifndef _OFF_T_DECLARED +typedef __off_t off_t; +#define _OFF_T_DECLARED +#endif + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#ifdef _KERNEL +#include + +struct shmfd { + size_t shm_size; + vm_object_t shm_object; + int shm_refs; + uid_t shm_uid; + gid_t shm_gid; + mode_t shm_mode; + + /* + * Values maintained solely to make this a better-behaved file + * descriptor for fstat() to run on. + */ + struct timespec shm_atime; + struct timespec shm_mtime; + struct timespec shm_ctime; + struct timespec shm_birthtime; + + struct label *shm_label; /* MAC label */ +}; + +int shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, + vm_object_t *obj); + +#else /* !_KERNEL */ + +__BEGIN_DECLS +/* + * XXX not yet implemented: posix_mem_offset(), posix_typed_mem_get_info(), + * posix_typed_mem_open(). + */ +#if __BSD_VISIBLE +int getpagesizes(size_t *, int); +int madvise(void *, size_t, int); +int mincore(const void *, size_t, char *); +int minherit(void *, size_t, int); +#endif +int mlock(const void *, size_t); +#ifndef _MMAP_DECLARED +#define _MMAP_DECLARED +void * mmap(void *, size_t, int, int, int, off_t); +#endif +int mprotect(const void *, size_t, int); +int msync(void *, size_t, int); +int munlock(const void *, size_t); +int munmap(void *, size_t); +#if __POSIX_VISIBLE >= 200112 +int posix_madvise(void *, size_t, int); +#endif +#if __POSIX_VISIBLE >= 199309 +int mlockall(int); +int munlockall(void); +int shm_open(const char *, int, mode_t); +int shm_unlink(const char *); +#endif +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_MMAN_H_ */ diff --git a/freebsd/sys/sys/module.h b/freebsd/sys/sys/module.h index 3b67ad5a..782770a7 100644 --- a/freebsd/sys/sys/module.h +++ b/freebsd/sys/sys/module.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _SYS_MODULE_HH_ -#define _SYS_MODULE_HH_ +#ifndef _SYS_MODULE_H_ +#define _SYS_MODULE_H_ /* * Module metadata types @@ -94,7 +94,7 @@ struct mod_metadata { #ifdef _KERNEL -#include +#include #define MODULE_METADATA(uniquifier, type, data, cval) \ static struct mod_metadata _mod_metadata##uniquifier = { \ @@ -204,7 +204,7 @@ struct module_stat { #ifndef _KERNEL -#include +#include __BEGIN_DECLS int modnext(int _modid); @@ -215,4 +215,4 @@ __END_DECLS #endif -#endif /* !_SYS_MODULE_HH_ */ +#endif /* !_SYS_MODULE_H_ */ diff --git a/freebsd/sys/sys/mount.h b/freebsd/sys/sys/mount.h index 9ec6915d..fcf80bd5 100644 --- a/freebsd/sys/sys/mount.h +++ b/freebsd/sys/sys/mount.h @@ -30,15 +30,15 @@ * $FreeBSD$ */ -#ifndef _SYS_MOUNT_HH_ -#define _SYS_MOUNT_HH_ +#ifndef _SYS_MOUNT_H_ +#define _SYS_MOUNT_H_ -#include -#include +#include +#include #ifdef _KERNEL -#include -#include -#include +#include +#include +#include #endif /* @@ -663,7 +663,7 @@ vfs_statfs_t __vfs_statfs; VN_KNOTE((vp), (hint), 0); \ } while (0) -#include +#include /* * Version numbers. @@ -771,7 +771,7 @@ vfs_sysctl_t vfs_stdsysctl; #else /* !_KERNEL */ -#include +#include struct stat; @@ -795,4 +795,4 @@ __END_DECLS #endif /* _KERNEL */ -#endif /* !_SYS_MOUNT_HH_ */ +#endif /* !_SYS_MOUNT_H_ */ diff --git a/freebsd/sys/sys/mqueue.h b/freebsd/sys/sys/mqueue.h index 80d40479..36e89fa2 100644 --- a/freebsd/sys/sys/mqueue.h +++ b/freebsd/sys/sys/mqueue.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _SYS_MQUEUE_HH_ -#define _SYS_MQUEUE_HH_ +#ifndef _SYS_MQUEUE_H_ +#define _SYS_MQUEUE_H_ struct mq_attr { long mq_flags; /* Message queue flags. */ diff --git a/freebsd/sys/sys/mutex.h b/freebsd/sys/sys/mutex.h index 0e8e1739..3e4a1701 100644 --- a/freebsd/sys/sys/mutex.h +++ b/freebsd/sys/sys/mutex.h @@ -29,24 +29,24 @@ * $FreeBSD$ */ -#ifndef _SYS_MUTEX_HH_ -#define _SYS_MUTEX_HH_ +#ifndef _SYS_MUTEX_H_ +#define _SYS_MUTEX_H_ #ifndef LOCORE -#include -#include -#include +#include +#include +#include #ifdef _KERNEL -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif /* _KERNEL_ */ #endif /* !LOCORE */ -#include +#include #ifdef _KERNEL @@ -337,7 +337,7 @@ extern struct mtx_pool *mtxpool_lockbuilder; extern struct mtx_pool *mtxpool_sleep; #ifndef LOCK_DEBUG -#error LOCK_DEBUG not defined, include before +#error LOCK_DEBUG not defined, include before #endif #if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE) #define mtx_lock_flags(m, opts) \ @@ -471,4 +471,4 @@ struct mtx_args { #endif /* _KERNEL */ #endif /* !LOCORE */ -#endif /* _SYS_MUTEX_HH_ */ +#endif /* _SYS_MUTEX_H_ */ diff --git a/freebsd/sys/sys/osd.h b/freebsd/sys/sys/osd.h index a1989de0..63d536fa 100644 --- a/freebsd/sys/sys/osd.h +++ b/freebsd/sys/sys/osd.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_OSD_HH_ -#define _SYS_OSD_HH_ +#ifndef _SYS_OSD_H_ +#define _SYS_OSD_H_ -#include +#include /* * Lock key: @@ -98,4 +98,4 @@ void osd_exit(u_int type, struct osd *osd); #endif /* _KERNEL */ -#endif /* !_SYS_OSD_HH_ */ +#endif /* !_SYS_OSD_H_ */ diff --git a/freebsd/sys/sys/pciio.h b/freebsd/sys/sys/pciio.h index c4a5abf8..a0c4560e 100644 --- a/freebsd/sys/sys/pciio.h +++ b/freebsd/sys/sys/pciio.h @@ -28,10 +28,10 @@ * */ -#ifndef _SYS_PCIIO_HH_ -#define _SYS_PCIIO_HH_ +#ifndef _SYS_PCIIO_H_ +#define _SYS_PCIIO_H_ -#include +#include #define PCI_MAXNAMELEN 16 @@ -122,4 +122,4 @@ struct pci_bar_io { #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) #define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io) -#endif /* !_SYS_PCIIO_HH_ */ +#endif /* !_SYS_PCIIO_H_ */ diff --git a/freebsd/sys/sys/pcpu.h b/freebsd/sys/sys/pcpu.h index ce84f15a..48a3bccb 100644 --- a/freebsd/sys/sys/pcpu.h +++ b/freebsd/sys/sys/pcpu.h @@ -30,19 +30,19 @@ * $FreeBSD$ */ -#ifndef _SYS_PCPU_HH_ -#define _SYS_PCPU_HH_ +#ifndef _SYS_PCPU_H_ +#define _SYS_PCPU_H_ #ifdef LOCORE #error "no assembler-serviceable parts inside" #endif -#include +#include #ifndef __rtems__ -#include +#include #endif -#include -#include +#include +#include /* * Define a set for pcpu data. @@ -230,4 +230,4 @@ void pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); #endif /* _KERNEL */ -#endif /* !_SYS_PCPU_HH_ */ +#endif /* !_SYS_PCPU_H_ */ diff --git a/freebsd/sys/sys/poll.h b/freebsd/sys/sys/poll.h index 1d09405a..c955f321 100644 --- a/freebsd/sys/sys/poll.h +++ b/freebsd/sys/sys/poll.h @@ -28,10 +28,10 @@ * $FreeBSD$ */ -#ifndef _SYS_POLL_HH_ -#define _SYS_POLL_HH_ +#ifndef _SYS_POLL_H_ +#define _SYS_POLL_H_ -#include +#include /* * This file is intended to be compatible with the traditional poll.h. @@ -101,4 +101,4 @@ __END_DECLS #endif /* !_KERNEL */ -#endif /* !_SYS_POLL_HH_ */ +#endif /* !_SYS_POLL_H_ */ diff --git a/freebsd/sys/sys/priority.h b/freebsd/sys/sys/priority.h index dbaa5eaa..9bbd2de8 100644 --- a/freebsd/sys/sys/priority.h +++ b/freebsd/sys/sys/priority.h @@ -31,8 +31,8 @@ * $FreeBSD$ */ -#ifndef _SYS_PRIORITY_HH_ -#define _SYS_PRIORITY_HH_ +#ifndef _SYS_PRIORITY_H_ +#define _SYS_PRIORITY_H_ /* * Process priority specifications. @@ -127,4 +127,4 @@ struct priority { u_char pri_user; /* User priority based on p_cpu and p_nice. */ }; -#endif /* !_SYS_PRIORITY_HH_ */ +#endif /* !_SYS_PRIORITY_H_ */ diff --git a/freebsd/sys/sys/priv.h b/freebsd/sys/sys/priv.h index 78342669..6939e144 100644 --- a/freebsd/sys/sys/priv.h +++ b/freebsd/sys/sys/priv.h @@ -32,8 +32,8 @@ /* * Privilege checking interface for BSD kernel. */ -#ifndef _SYS_PRIV_HH_ -#define _SYS_PRIV_HH_ +#ifndef _SYS_PRIV_H_ +#define _SYS_PRIV_H_ /* * Privilege list, sorted loosely by kernel subsystem. @@ -515,4 +515,4 @@ int priv_check_cred(struct ucred *cred, int priv, int flags); #endif /* __rtems__ */ #endif -#endif /* !_SYS_PRIV_HH_ */ +#endif /* !_SYS_PRIV_H_ */ diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h index 43c2044c..cd10421e 100644 --- a/freebsd/sys/sys/proc.h +++ b/freebsd/sys/sys/proc.h @@ -35,35 +35,35 @@ * $FreeBSD$ */ -#ifndef _SYS_PROC_HH_ -#define _SYS_PROC_HH_ +#ifndef _SYS_PROC_H_ +#define _SYS_PROC_H_ -#include /* For struct callout. */ -#include /* For struct klist. */ -#include +#include /* For struct callout. */ +#include /* For struct klist. */ +#include #ifndef _KERNEL -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include /* XXX. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* XXX. */ +#include +#include +#include +#include +#include #ifndef _KERNEL -#include /* For structs itimerval, timeval. */ +#include /* For structs itimerval, timeval. */ #else -#include +#include #endif -#include -#include -#include /* Machine-dependent proc substruct. */ +#include +#include +#include /* Machine-dependent proc substruct. */ /* * One structure allocated per session. @@ -926,4 +926,4 @@ void thr_exit1(void); #endif /* _KERNEL */ -#endif /* !_SYS_PROC_HH_ */ +#endif /* !_SYS_PROC_H_ */ diff --git a/freebsd/sys/sys/protosw.h b/freebsd/sys/sys/protosw.h index 5b8e9f03..b55af4b7 100644 --- a/freebsd/sys/sys/protosw.h +++ b/freebsd/sys/sys/protosw.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _SYS_PROTOSW_HH_ -#define _SYS_PROTOSW_HH_ +#ifndef _SYS_PROTOSW_H_ +#define _SYS_PROTOSW_H_ /* Forward declare these structures referenced from prototypes below. */ struct mbuf; diff --git a/freebsd/sys/sys/queue.h b/freebsd/sys/sys/queue.h index e303641a..f0bae8d9 100644 --- a/freebsd/sys/sys/queue.h +++ b/freebsd/sys/sys/queue.h @@ -30,10 +30,10 @@ * $FreeBSD$ */ -#ifndef _SYS_QUEUE_HH_ -#define _SYS_QUEUE_HH_ +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ -#include +#include /* * This file defines four types of data structures: singly-linked lists, @@ -633,4 +633,4 @@ struct { \ (head2)->tqh_last = &(head2)->tqh_first; \ } while (0) -#endif /* !_SYS_QUEUE_HH_ */ +#endif /* !_SYS_QUEUE_H_ */ diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h index e5dea939..5cf1611e 100644 --- a/freebsd/sys/sys/random.h +++ b/freebsd/sys/sys/random.h @@ -26,8 +26,8 @@ * $FreeBSD$ */ -#ifndef _SYS_RANDOM_HH_ -#define _SYS_RANDOM_HH_ +#ifndef _SYS_RANDOM_H_ +#define _SYS_RANDOM_H_ #ifdef _KERNEL @@ -63,4 +63,4 @@ extern struct harvest_select harvest; #endif /* _KERNEL */ -#endif /* _SYS_RANDOM_HH_ */ +#endif /* _SYS_RANDOM_H_ */ diff --git a/freebsd/sys/sys/reboot.h b/freebsd/sys/sys/reboot.h index c2ffd30e..6b8e25e6 100644 --- a/freebsd/sys/sys/reboot.h +++ b/freebsd/sys/sys/reboot.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _SYS_REBOOT_HH_ -#define _SYS_REBOOT_HH_ +#ifndef _SYS_REBOOT_H_ +#define _SYS_REBOOT_H_ /* * Arguments to reboot system call. These are passed to diff --git a/freebsd/sys/sys/refcount.h b/freebsd/sys/sys/refcount.h index 6ec2417e..848b69ca 100644 --- a/freebsd/sys/sys/refcount.h +++ b/freebsd/sys/sys/refcount.h @@ -32,10 +32,10 @@ #ifndef __SYS_REFCOUNT_HH__ #define __SYS_REFCOUNT_HH__ -#include +#include #ifdef _KERNEL -#include +#include #else #define KASSERT(exp, msg) /* */ #endif diff --git a/freebsd/sys/sys/resourcevar.h b/freebsd/sys/sys/resourcevar.h index 53901f39..688bc22d 100644 --- a/freebsd/sys/sys/resourcevar.h +++ b/freebsd/sys/sys/resourcevar.h @@ -30,14 +30,14 @@ * $FreeBSD$ */ -#ifndef _SYS_RESOURCEVAR_HH_ -#define _SYS_RESOURCEVAR_HH_ +#ifndef _SYS_RESOURCEVAR_H_ +#define _SYS_RESOURCEVAR_H_ -#include -#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #endif /* @@ -140,4 +140,4 @@ void uihashinit(void); void uihold(struct uidinfo *uip); #endif /* _KERNEL */ -#endif /* !_SYS_RESOURCEVAR_HH_ */ +#endif /* !_SYS_RESOURCEVAR_H_ */ diff --git a/freebsd/sys/sys/rman.h b/freebsd/sys/sys/rman.h index 3f909a22..ba06cc04 100644 --- a/freebsd/sys/sys/rman.h +++ b/freebsd/sys/sys/rman.h @@ -29,14 +29,14 @@ * $FreeBSD$ */ -#ifndef _SYS_RMAN_HH_ -#define _SYS_RMAN_HH_ 1 +#ifndef _SYS_RMAN_H_ +#define _SYS_RMAN_H_ 1 #ifndef _KERNEL -#include +#include #else -#include -#include +#include +#include #endif #define RF_ALLOCATED 0x0001 /* resource has been reserved */ @@ -152,4 +152,4 @@ extern struct rman_head rman_head; #endif /* _KERNEL */ -#endif /* !_SYS_RMAN_HH_ */ +#endif /* !_SYS_RMAN_H_ */ diff --git a/freebsd/sys/sys/rmlock.h b/freebsd/sys/sys/rmlock.h index ec676b74..04a1e79c 100644 --- a/freebsd/sys/sys/rmlock.h +++ b/freebsd/sys/sys/rmlock.h @@ -29,12 +29,12 @@ * $FreeBSD$ */ -#ifndef _SYS_RMLOCK_HH_ -#define _SYS_RMLOCK_HH_ +#ifndef _SYS_RMLOCK_H_ +#define _SYS_RMLOCK_H_ -#include -#include -#include +#include +#include +#include #ifdef _KERNEL @@ -68,7 +68,7 @@ void _rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker); * Public interface for lock operations. */ #ifndef LOCK_DEBUG -#error LOCK_DEBUG not defined, include before +#error LOCK_DEBUG not defined, include before #endif #if LOCK_DEBUG > 0 @@ -135,4 +135,4 @@ struct rm_args_flags { rm_destroy, (rm)) #endif /* _KERNEL */ -#endif /* !_SYS_RMLOCK_HH_ */ +#endif /* !_SYS_RMLOCK_H_ */ diff --git a/freebsd/sys/sys/rtprio.h b/freebsd/sys/sys/rtprio.h index 0694c119..7ffdb732 100644 --- a/freebsd/sys/sys/rtprio.h +++ b/freebsd/sys/sys/rtprio.h @@ -31,10 +31,10 @@ * $FreeBSD$ */ -#ifndef _SYS_RTPRIO_HH_ -#define _SYS_RTPRIO_HH_ +#ifndef _SYS_RTPRIO_H_ +#define _SYS_RTPRIO_H_ -#include +#include /* * Process realtime-priority specifications to rtprio. @@ -82,11 +82,11 @@ void pri_to_rtp(struct thread *, struct rtprio *); #endif #ifndef _KERNEL -#include +#include __BEGIN_DECLS int rtprio(int, pid_t, struct rtprio *); int rtprio_thread(int, lwpid_t, struct rtprio *); __END_DECLS #endif /* !_KERNEL */ -#endif /* !_SYS_RTPRIO_HH_ */ +#endif /* !_SYS_RTPRIO_H_ */ diff --git a/freebsd/sys/sys/runq.h b/freebsd/sys/sys/runq.h index ce2dada1..50c00eb6 100644 --- a/freebsd/sys/sys/runq.h +++ b/freebsd/sys/sys/runq.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _RUNQ_HH_ -#define _RUNQ_HH_ +#ifndef _RUNQ_H_ +#define _RUNQ_H_ -#include +#include struct thread; diff --git a/freebsd/sys/sys/rwlock.h b/freebsd/sys/sys/rwlock.h index c3d6ee7a..82e95c4b 100644 --- a/freebsd/sys/sys/rwlock.h +++ b/freebsd/sys/sys/rwlock.h @@ -29,17 +29,17 @@ * $FreeBSD$ */ -#ifndef _SYS_RWLOCK_HH_ -#define _SYS_RWLOCK_HH_ +#ifndef _SYS_RWLOCK_H_ +#define _SYS_RWLOCK_H_ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef _KERNEL -#include -#include +#include +#include #endif #ifdef __rtems__ @@ -155,7 +155,7 @@ void _rw_assert(struct rwlock *rw, int what, const char *file, int line); */ #ifndef LOCK_DEBUG -#error LOCK_DEBUG not defined, include before +#error LOCK_DEBUG not defined, include before #endif #if LOCK_DEBUG > 0 || defined(RWLOCK_NOINLINE) #define rw_wlock(rw) _rw_wlock((rw), LOCK_FILE, LOCK_LINE) @@ -248,4 +248,4 @@ struct rw_args_flags { #endif #endif /* _KERNEL */ -#endif /* !_SYS_RWLOCK_HH_ */ +#endif /* !_SYS_RWLOCK_H_ */ diff --git a/freebsd/sys/sys/sbuf.h b/freebsd/sys/sys/sbuf.h index 6b270d3d..ee74ce5b 100644 --- a/freebsd/sys/sys/sbuf.h +++ b/freebsd/sys/sys/sbuf.h @@ -28,10 +28,10 @@ * $FreeBSD$ */ -#ifndef _SYS_SBUF_HH_ -#define _SYS_SBUF_HH_ +#ifndef _SYS_SBUF_H_ +#define _SYS_SBUF_H_ -#include +#include /* * Structure definition diff --git a/freebsd/sys/sys/select.h b/freebsd/sys/sys/select.h index 03f7d851..f348f54e 100644 --- a/freebsd/sys/sys/select.h +++ b/freebsd/sys/sys/select.h @@ -1,3 +1,114 @@ -#include -#include +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * $FreeBSD$ + */ +#ifndef _SYS_SELECT_H_ +#define _SYS_SELECT_H_ + +#include +#include + +#include +#include +#include + +#ifndef __rtems__ +typedef unsigned long __fd_mask; +#if __BSD_VISIBLE +typedef __fd_mask fd_mask; +#endif + +#ifndef _SIGSET_T_DECLARED +#define _SIGSET_T_DECLARED +typedef __sigset_t sigset_t; +#endif + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 1024U +#endif + +#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ +#if __BSD_VISIBLE +#define NFDBITS _NFDBITS +#endif + +#ifndef _howmany +#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +typedef struct fd_set { + __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; +} fd_set; +#if __BSD_VISIBLE +#define fds_bits __fds_bits +#endif + +#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) +#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) +#if __BSD_VISIBLE +#define FD_COPY(f, t) (void)(*(t) = *(f)) +#endif +#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) +#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) +#define FD_ZERO(p) do { \ + fd_set *_p; \ + __size_t _n; \ + \ + _p = (p); \ + _n = _howmany(FD_SETSIZE, _NFDBITS); \ + while (_n > 0) \ + _p->__fds_bits[--_n] = 0; \ +} while (0) +#else /* __rtems__ */ +#include +#include +#include +#endif /* __rtems__ */ + +#ifndef _KERNEL + +__BEGIN_DECLS +int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, + const struct timespec *__restrict, const sigset_t *__restrict); +#ifndef _SELECT_DECLARED +#define _SELECT_DECLARED +/* XXX missing restrict type-qualifier */ +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* _SYS_SELECT_H_ */ diff --git a/freebsd/sys/sys/selinfo.h b/freebsd/sys/sys/selinfo.h index da20189b..39e540f7 100644 --- a/freebsd/sys/sys/selinfo.h +++ b/freebsd/sys/sys/selinfo.h @@ -30,10 +30,10 @@ * $FreeBSD$ */ -#ifndef _SYS_SELINFO_HH_ -#define _SYS_SELINFO_HH_ +#ifndef _SYS_SELINFO_H_ +#define _SYS_SELINFO_H_ -#include /* for struct klist */ +#include /* for struct klist */ struct selfd; TAILQ_HEAD(selfdlist, selfd); @@ -61,4 +61,4 @@ void selwakeuppri(struct selinfo *sip, int pri); void seltdfini(struct thread *td); #endif -#endif /* !_SYS_SELINFO_HH_ */ +#endif /* !_SYS_SELINFO_H_ */ diff --git a/freebsd/sys/sys/sf_buf.h b/freebsd/sys/sys/sf_buf.h index 5dbcd5ef..af420652 100644 --- a/freebsd/sys/sys/sf_buf.h +++ b/freebsd/sys/sys/sf_buf.h @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _SYS_SF_BUF_HH_ -#define _SYS_SF_BUF_HH_ +#ifndef _SYS_SF_BUF_H_ +#define _SYS_SF_BUF_H_ -#include +#include /* * Options to sf_buf_alloc() are specified through its flags argument. This @@ -53,4 +53,4 @@ struct sf_buf * void sf_buf_free(struct sf_buf *sf); void sf_buf_mext(void *addr, void *args); -#endif /* !_SYS_SF_BUF_HH_ */ +#endif /* !_SYS_SF_BUF_H_ */ diff --git a/freebsd/sys/sys/sigio.h b/freebsd/sys/sys/sigio.h index dc29d948..62ece6d4 100644 --- a/freebsd/sys/sys/sigio.h +++ b/freebsd/sys/sys/sigio.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _SYS_SIGIO_HH_ -#define _SYS_SIGIO_HH_ +#ifndef _SYS_SIGIO_H_ +#define _SYS_SIGIO_H_ /* * This structure holds the information needed to send a SIGIO or @@ -64,4 +64,4 @@ int fsetown(pid_t pgid, struct sigio **sigiop); void funsetown(struct sigio **sigiop); void funsetownlst(struct sigiolst *sigiolst); -#endif /* _SYS_SIGIO_HH_ */ +#endif /* _SYS_SIGIO_H_ */ diff --git a/freebsd/sys/sys/smp.h b/freebsd/sys/sys/smp.h index c73bec25..619eba81 100644 --- a/freebsd/sys/sys/smp.h +++ b/freebsd/sys/sys/smp.h @@ -9,8 +9,8 @@ * $FreeBSD$ */ -#ifndef _SYS_SMP_HH_ -#define _SYS_SMP_HH_ +#ifndef _SYS_SMP_H_ +#define _SYS_SMP_H_ #ifdef _KERNEL @@ -180,4 +180,4 @@ void smp_rendezvous_cpus(cpumask_t, void *arg); #endif /* !LOCORE */ #endif /* _KERNEL */ -#endif /* _SYS_SMP_HH_ */ +#endif /* _SYS_SMP_H_ */ diff --git a/freebsd/sys/sys/sockbuf.h b/freebsd/sys/sys/sockbuf.h index 5de6f6eb..b8e66999 100644 --- a/freebsd/sys/sys/sockbuf.h +++ b/freebsd/sys/sys/sockbuf.h @@ -30,12 +30,12 @@ * * $FreeBSD$ */ -#ifndef _SYS_SOCKBUF_HH_ -#define _SYS_SOCKBUF_HH_ -#include /* for struct selinfo */ -#include -#include -#include +#ifndef _SYS_SOCKBUF_H_ +#define _SYS_SOCKBUF_H_ +#include /* for struct selinfo */ +#include +#include +#include #define SB_MAX (256*1024) /* default for max chars in sockbuf */ @@ -220,4 +220,4 @@ void sblastmbufchk(struct sockbuf *, const char *, int); #endif /* _KERNEL */ -#endif /* _SYS_SOCKBUF_HH_ */ +#endif /* _SYS_SOCKBUF_H_ */ diff --git a/freebsd/sys/sys/socket.h b/freebsd/sys/sys/socket.h index 39138881..9481e5c4 100644 --- a/freebsd/sys/sys/socket.h +++ b/freebsd/sys/sys/socket.h @@ -1,2 +1,691 @@ -#include -#include +/*- + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)socket.h 8.4 (Berkeley) 2/21/94 + * $FreeBSD$ + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +#include +#include +#include +#define _NO_NAMESPACE_POLLUTION +#include +#undef _NO_NAMESPACE_POLLUTION + +/* + * Definitions related to sockets: types, address families, options. + */ + +/* + * Data types. + */ +#if __BSD_VISIBLE +#ifndef _GID_T_DECLARED +typedef __gid_t gid_t; +#define _GID_T_DECLARED +#endif + +#ifndef _OFF_T_DECLARED +typedef __off_t off_t; +#define _OFF_T_DECLARED +#endif + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif +#endif + +#ifndef _SA_FAMILY_T_DECLARED +typedef __sa_family_t sa_family_t; +#define _SA_FAMILY_T_DECLARED +#endif + +#ifndef _SOCKLEN_T_DECLARED +typedef __socklen_t socklen_t; +#define _SOCKLEN_T_DECLARED +#endif + +#ifndef _SSIZE_T_DECLARED +typedef __ssize_t ssize_t; +#define _SSIZE_T_DECLARED +#endif + +#if __BSD_VISIBLE +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; +#define _UID_T_DECLARED +#endif +#endif + +/* + * Types + */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#if __BSD_VISIBLE +#define SOCK_RDM 4 /* reliably-delivered message */ +#endif +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#if __BSD_VISIBLE +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#endif +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#if __BSD_VISIBLE +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ +#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ +#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */ +#endif +#define SO_NO_OFFLOAD 0x4000 /* socket cannot be offloaded */ +#define SO_NO_DDP 0x8000 /* disable direct data placement */ + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#if __BSD_VISIBLE +#define SO_LABEL 0x1009 /* socket's MAC label */ +#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */ +#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ +#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ +#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ +#define SO_SETFIB 0x1014 /* use this FIB to route */ +#endif + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +#if __BSD_VISIBLE +struct accept_filter_arg { + char af_name[16]; + char af_arg[256-16]; +}; +#endif + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ + +/* + * Address families. + */ +#define AF_UNSPEC 0 /* unspecified */ +#if __BSD_VISIBLE +#define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */ +#endif +#define AF_UNIX 1 /* standardized name for AF_LOCAL */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#if __BSD_VISIBLE +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NETBIOS 6 /* SMB protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO +#define AF_ECMA 8 /* European computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* DEC Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_ROUTE 17 /* Internal Routing Protocol */ +#define AF_LINK 18 /* Link layer interface */ +#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ +#define AF_COIP 20 /* connection-oriented IP, aka ST II */ +#define AF_CNT 21 /* Computer Network Technology */ +#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_SIP 24 /* Simple Internet Protocol */ +#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ +#define AF_ISDN 26 /* Integrated Services Digital Network*/ +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ +#define pseudo_AF_KEY 27 /* Internal key-management function */ +#endif +#define AF_INET6 28 /* IPv6 */ +#if __BSD_VISIBLE +#define AF_NATM 29 /* native ATM access */ +#define AF_ATM 30 /* ATM */ +#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers + * in interface output routine + */ +#define AF_NETGRAPH 32 /* Netgraph sockets */ +#define AF_SLOW 33 /* 802.3ad slow protocol */ +#define AF_SCLUSTER 34 /* Sitara cluster protocol */ +#define AF_ARP 35 +#define AF_BLUETOOTH 36 /* Bluetooth sockets */ +#define AF_IEEE80211 37 /* IEEE 802.11 protocol */ +#define AF_MAX 38 +/* + * When allocating a new AF_ constant, please only allocate + * even numbered constants for FreeBSD until 134 as odd numbered AF_ + * constants 39-133 are now reserved for vendors. + */ +#define AF_VENDOR00 39 +#define AF_VENDOR01 41 +#define AF_VENDOR02 43 +#define AF_VENDOR03 45 +#define AF_VENDOR04 47 +#define AF_VENDOR05 49 +#define AF_VENDOR06 51 +#define AF_VENDOR07 53 +#define AF_VENDOR08 55 +#define AF_VENDOR09 57 +#define AF_VENDOR10 59 +#define AF_VENDOR11 61 +#define AF_VENDOR12 63 +#define AF_VENDOR13 65 +#define AF_VENDOR14 67 +#define AF_VENDOR15 69 +#define AF_VENDOR16 71 +#define AF_VENDOR17 73 +#define AF_VENDOR18 75 +#define AF_VENDOR19 77 +#define AF_VENDOR20 79 +#define AF_VENDOR21 81 +#define AF_VENDOR22 83 +#define AF_VENDOR23 85 +#define AF_VENDOR24 87 +#define AF_VENDOR25 89 +#define AF_VENDOR26 91 +#define AF_VENDOR27 93 +#define AF_VENDOR28 95 +#define AF_VENDOR29 97 +#define AF_VENDOR30 99 +#define AF_VENDOR31 101 +#define AF_VENDOR32 103 +#define AF_VENDOR33 105 +#define AF_VENDOR34 107 +#define AF_VENDOR35 109 +#define AF_VENDOR36 111 +#define AF_VENDOR37 113 +#define AF_VENDOR38 115 +#define AF_VENDOR39 117 +#define AF_VENDOR40 119 +#define AF_VENDOR41 121 +#define AF_VENDOR42 123 +#define AF_VENDOR43 125 +#define AF_VENDOR44 127 +#define AF_VENDOR45 129 +#define AF_VENDOR46 131 +#define AF_VENDOR47 133 +#endif + +/* + * Structure used by kernel to store most + * addresses. + */ +struct sockaddr { + unsigned char sa_len; /* total length */ + sa_family_t sa_family; /* address family */ + char sa_data[14]; /* actually longer; address value */ +}; +#if __BSD_VISIBLE +#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ + +/* + * Structure used by kernel to pass protocol + * information in raw sockets. + */ +struct sockproto { + unsigned short sp_family; /* address family */ + unsigned short sp_protocol; /* protocol */ +}; +#endif + +#ifndef _STRUCT_SOCKADDR_STORAGE_DECLARED +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128U +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ + sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { + unsigned char ss_len; /* address length */ + sa_family_t ss_family; /* address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; /* force desired struct alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; +#define _STRUCT_SOCKADDR_STORAGE_DECLARED +#endif + +#if __BSD_VISIBLE +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_LOCAL AF_LOCAL +#define PF_UNIX PF_LOCAL /* backward compatibility */ +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NETBIOS AF_NETBIOS +#define PF_ISO AF_ISO +#define PF_OSI AF_ISO +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_ROUTE AF_ROUTE +#define PF_LINK AF_LINK +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ +#define PF_COIP AF_COIP +#define PF_CNT AF_CNT +#define PF_SIP AF_SIP +#define PF_IPX AF_IPX +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ +#define PF_PIP pseudo_AF_PIP +#define PF_ISDN AF_ISDN +#define PF_KEY pseudo_AF_KEY +#define PF_INET6 AF_INET6 +#define PF_NATM AF_NATM +#define PF_ATM AF_ATM +#define PF_NETGRAPH AF_NETGRAPH +#define PF_SLOW AF_SLOW +#define PF_SCLUSTER AF_SCLUSTER +#define PF_ARP AF_ARP +#define PF_BLUETOOTH AF_BLUETOOTH + +#define PF_MAX AF_MAX + +/* + * Definitions for network related sysctl, CTL_NET. + * + * Second level is protocol family. + * Third level is protocol number. + * + * Further levels are defined by the individual families below. + */ +#define NET_MAXID AF_MAX + +#define CTL_NET_NAMES { \ + { 0, 0 }, \ + { "unix", CTLTYPE_NODE }, \ + { "inet", CTLTYPE_NODE }, \ + { "implink", CTLTYPE_NODE }, \ + { "pup", CTLTYPE_NODE }, \ + { "chaos", CTLTYPE_NODE }, \ + { "xerox_ns", CTLTYPE_NODE }, \ + { "iso", CTLTYPE_NODE }, \ + { "emca", CTLTYPE_NODE }, \ + { "datakit", CTLTYPE_NODE }, \ + { "ccitt", CTLTYPE_NODE }, \ + { "ibm_sna", CTLTYPE_NODE }, \ + { "decnet", CTLTYPE_NODE }, \ + { "dec_dli", CTLTYPE_NODE }, \ + { "lat", CTLTYPE_NODE }, \ + { "hylink", CTLTYPE_NODE }, \ + { "appletalk", CTLTYPE_NODE }, \ + { "route", CTLTYPE_NODE }, \ + { "link_layer", CTLTYPE_NODE }, \ + { "xtp", CTLTYPE_NODE }, \ + { "coip", CTLTYPE_NODE }, \ + { "cnt", CTLTYPE_NODE }, \ + { "rtip", CTLTYPE_NODE }, \ + { "ipx", CTLTYPE_NODE }, \ + { "sip", CTLTYPE_NODE }, \ + { "pip", CTLTYPE_NODE }, \ + { "isdn", CTLTYPE_NODE }, \ + { "key", CTLTYPE_NODE }, \ + { "inet6", CTLTYPE_NODE }, \ + { "natm", CTLTYPE_NODE }, \ + { "atm", CTLTYPE_NODE }, \ + { "hdrcomplete", CTLTYPE_NODE }, \ + { "netgraph", CTLTYPE_NODE }, \ + { "snp", CTLTYPE_NODE }, \ + { "scp", CTLTYPE_NODE }, \ +} + +/* + * PF_ROUTE - Routing table + * + * Three additional levels are defined: + * Fourth: address family, 0 is wildcard + * Fifth: type of info, defined below + * Sixth: flag(s) to mask with for NET_RT_FLAGS + */ +#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ +#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ +#define NET_RT_IFLIST 3 /* survey interface list */ +#define NET_RT_IFMALIST 4 /* return multicast address list */ +#define NET_RT_MAXID 5 + +#define CTL_NET_RT_NAMES { \ + { 0, 0 }, \ + { "dump", CTLTYPE_STRUCT }, \ + { "flags", CTLTYPE_STRUCT }, \ + { "iflist", CTLTYPE_STRUCT }, \ + { "ifmalist", CTLTYPE_STRUCT }, \ +} +#endif /* __BSD_VISIBLE */ + +/* + * Maximum queue length specifiable by listen. + */ +#define SOMAXCONN 128 + +/* + * Message header for recvmsg and sendmsg calls. + * Used value-result for recvmsg, value only for sendmsg. + */ +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + socklen_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ +}; + +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_EOR 0x8 /* data completes record */ +#define MSG_TRUNC 0x10 /* data discarded before delivery */ +#define MSG_CTRUNC 0x20 /* control data lost before delivery */ +#define MSG_WAITALL 0x40 /* wait for full request or error */ +#define MSG_NOTIFICATION 0x2000 /* SCTP notification */ +#if __BSD_VISIBLE +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ +#define MSG_EOF 0x100 /* data completes connection */ +#define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */ +#define MSG_COMPAT 0x8000 /* used in sendit() */ +#endif +#ifdef _KERNEL +#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */ +#endif +#if __BSD_VISIBLE +#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */ +#endif + +/* + * Header for ancillary data objects in msg_control buffer. + * Used for additional information with/about a datagram + * not expressible by flags. The format is a sequence + * of message elements headed by cmsghdr structures. + */ +struct cmsghdr { + socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +/* followed by u_char cmsg_data[]; */ +}; + +#if __BSD_VISIBLE +/* + * While we may have more groups than this, the cmsgcred struct must + * be able to fit in an mbuf and we have historically supported a + * maximum of 16 groups. +*/ +#define CMGROUP_MAX 16 + +/* + * Credentials structure, used to verify the identity of a peer + * process that has sent us a message. This is allocated by the + * peer process but filled in by the kernel. This prevents the + * peer from lying about its identity. (Note that cmcred_groups[0] + * is the effective GID.) + */ +struct cmsgcred { + pid_t cmcred_pid; /* PID of sending process */ + uid_t cmcred_uid; /* real UID of sending process */ + uid_t cmcred_euid; /* effective UID of sending process */ + gid_t cmcred_gid; /* real GID of sending process */ + short cmcred_ngroups; /* number or groups */ + gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ +}; + +/* + * Socket credentials. + */ +struct sockcred { + uid_t sc_uid; /* real user id */ + uid_t sc_euid; /* effective user id */ + gid_t sc_gid; /* real group id */ + gid_t sc_egid; /* effective group id */ + int sc_ngroups; /* number of supplemental groups */ + gid_t sc_groups[1]; /* variable length */ +}; + +/* + * Compute size of a sockcred structure with groups. + */ +#define SOCKCREDSIZE(ngrps) \ + (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) + +#endif /* __BSD_VISIBLE */ + +/* given pointer to struct cmsghdr, return pointer to data */ +#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ + _ALIGN(sizeof(struct cmsghdr))) + +/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \ + ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \ + _ALIGN(sizeof(struct cmsghdr)) > \ + (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ + (struct cmsghdr *)0 : \ + (struct cmsghdr *)((char *)(cmsg) + \ + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))) + +/* + * RFC 2292 requires to check msg_controllen, in case that the kernel returns + * an empty list for some reasons. + */ +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ + (struct cmsghdr *)NULL) + +#if __BSD_VISIBLE +/* RFC 2292 additions */ +#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) +#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) +#endif + +#ifdef _KERNEL +#define CMSG_ALIGN(n) _ALIGN(n) +#endif + +/* "Socket"-level control message types: */ +#define SCM_RIGHTS 0x01 /* access rights (array of int) */ +#if __BSD_VISIBLE +#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ +#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ +#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */ +#endif + +#if __BSD_VISIBLE +/* + * 4.3 compat sockaddr, move to compat file later + */ +struct osockaddr { + unsigned short sa_family; /* address family */ + char sa_data[14]; /* up to 14 bytes of direct address */ +}; + +/* + * 4.3-compat message header (move to compat file later). + */ +struct omsghdr { + char *msg_name; /* optional address */ + int msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + char *msg_accrights; /* access rights sent/received */ + int msg_accrightslen; +}; +#endif + +/* + * howto arguments for shutdown(2), specified by Posix.1g. + */ +#define SHUT_RD 0 /* shut down the reading side */ +#define SHUT_WR 1 /* shut down the writing side */ +#define SHUT_RDWR 2 /* shut down both sides */ + +/* we cheat and use the SHUT_XX defines for these */ +#define PRU_FLUSH_RD SHUT_RD +#define PRU_FLUSH_WR SHUT_WR +#define PRU_FLUSH_RDWR SHUT_RDWR + + +#if __BSD_VISIBLE +/* + * sendfile(2) header/trailer struct + */ +struct sf_hdtr { + struct iovec *headers; /* pointer to an array of header struct iovec's */ + int hdr_cnt; /* number of header iovec's */ + struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ + int trl_cnt; /* number of trailer iovec's */ +}; + +/* + * Sendfile-specific flag(s) + */ +#define SF_NODISKIO 0x00000001 +#define SF_MNOWAIT 0x00000002 +#define SF_SYNC 0x00000004 +#endif + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); +int bind(int, const struct sockaddr *, socklen_t); +int connect(int, const struct sockaddr *, socklen_t); +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); +int listen(int, int); +ssize_t recv(int, void *, size_t, int); +ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); +ssize_t recvmsg(int, struct msghdr *, int); +ssize_t send(int, const void *, size_t, int); +ssize_t sendto(int, const void *, + size_t, int, const struct sockaddr *, socklen_t); +ssize_t sendmsg(int, const struct msghdr *, int); +#if __BSD_VISIBLE +int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); +int setfib(int); +#endif +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int sockatmark(int); +int socket(int, int, int); +int socketpair(int, int, int, int *); +__END_DECLS + +#endif /* !_KERNEL */ + +#ifdef _KERNEL +struct socket; + +struct tcpcb *so_sototcpcb(struct socket *so); +struct inpcb *so_sotoinpcb(struct socket *so); +struct sockbuf *so_sockbuf_snd(struct socket *); +struct sockbuf *so_sockbuf_rcv(struct socket *); + +int so_state_get(const struct socket *); +void so_state_set(struct socket *, int); + +int so_options_get(const struct socket *); +void so_options_set(struct socket *, int); + +int so_error_get(const struct socket *); +void so_error_set(struct socket *, int); + +int so_linger_get(const struct socket *); +void so_linger_set(struct socket *, int); + +struct protosw *so_protosw_get(const struct socket *); +void so_protosw_set(struct socket *, struct protosw *); + +void so_sorwakeup_locked(struct socket *so); +void so_sowwakeup_locked(struct socket *so); + +void so_sorwakeup(struct socket *so); +void so_sowwakeup(struct socket *so); + +void so_lock(struct socket *so); +void so_unlock(struct socket *so); + +void so_listeners_apply_all(struct socket *so, void (*func)(struct socket *, void *), void *arg); + +#endif + + +#endif /* !_SYS_SOCKET_H_ */ diff --git a/freebsd/sys/sys/socketvar.h b/freebsd/sys/sys/socketvar.h index 5c3a9b4d..88990831 100644 --- a/freebsd/sys/sys/socketvar.h +++ b/freebsd/sys/sys/socketvar.h @@ -1,2 +1,393 @@ -#include -#include +/*- + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 + * + * $FreeBSD$ + */ + +#ifndef _SYS_SOCKETVAR_H_ +#define _SYS_SOCKETVAR_H_ + +#include /* for TAILQ macros */ +#include /* for struct selinfo */ +#include +#include +#include +#include +#include +#ifdef _KERNEL +#include +#endif + +struct vnet; + +/* + * Kernel structure per socket. + * Contains send and receive buffer queues, + * handle on protocol and pointer to protocol + * private data and error information. + */ +typedef u_quad_t so_gen_t; + +struct socket; + +/*- + * Locking key to struct socket: + * (a) constant after allocation, no locking required. + * (b) locked by SOCK_LOCK(so). + * (c) locked by SOCKBUF_LOCK(&so->so_rcv). + * (d) locked by SOCKBUF_LOCK(&so->so_snd). + * (e) locked by ACCEPT_LOCK(). + * (f) not locked since integer reads/writes are atomic. + * (g) used only as a sleep/wakeup address, no value. + * (h) locked by global mutex so_global_mtx. + */ +struct socket { + int so_count; /* (b) reference count */ + short so_type; /* (a) generic type, see socket.h */ + short so_options; /* from socket call, see socket.h */ + short so_linger; /* time to linger while closing */ + short so_state; /* (b) internal state flags SS_* */ + int so_qstate; /* (e) internal state flags SQ_* */ + void *so_pcb; /* protocol control block */ + struct vnet *so_vnet; /* network stack instance */ + struct protosw *so_proto; /* (a) protocol handle */ +/* + * Variables for connection queuing. + * Socket where accepts occur is so_head in all subsidiary sockets. + * If so_head is 0, socket is not related to an accept. + * For head socket so_incomp queues partially completed connections, + * while so_comp is a queue of connections ready to be accepted. + * If a connection is aborted and it has so_head set, then + * it has to be pulled out of either so_incomp or so_comp. + * We allow connections to queue up based on current queue lengths + * and limit on number of queued connections for this socket. + */ + struct socket *so_head; /* (e) back pointer to listen socket */ + TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted connections */ + TAILQ_HEAD(, socket) so_comp; /* (e) queue of complete unaccepted connections */ + TAILQ_ENTRY(socket) so_list; /* (e) list of unaccepted connections */ + u_short so_qlen; /* (e) number of unaccepted connections */ + u_short so_incqlen; /* (e) number of unaccepted incomplete + connections */ + u_short so_qlimit; /* (e) max number queued connections */ + short so_timeo; /* (g) connection timeout */ + u_short so_error; /* (f) error affecting connection */ + struct sigio *so_sigio; /* [sg] information for async I/O or + out of band data (SIGURG) */ + u_long so_oobmark; /* (c) chars to oob mark */ + TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */ + + struct sockbuf so_rcv, so_snd; + + struct ucred *so_cred; /* (a) user credentials */ + struct label *so_label; /* (b) MAC label for socket */ + struct label *so_peerlabel; /* (b) cached MAC label for peer */ + /* NB: generation count must not be first. */ + so_gen_t so_gencnt; /* (h) generation count */ + void *so_emuldata; /* (b) private data for emulators */ + struct so_accf { + struct accept_filter *so_accept_filter; + void *so_accept_filter_arg; /* saved filter args */ + char *so_accept_filter_str; /* saved user args */ + } *so_accf; + int so_fibnum; /* routing domain for this socket */ +}; + +/* + * Global accept mutex to serialize access to accept queues and + * fields associated with multiple sockets. This allows us to + * avoid defining a lock order between listen and accept sockets + * until such time as it proves to be a good idea. + */ +extern struct mtx accept_mtx; +#define ACCEPT_LOCK_ASSERT() mtx_assert(&accept_mtx, MA_OWNED) +#define ACCEPT_UNLOCK_ASSERT() mtx_assert(&accept_mtx, MA_NOTOWNED) +#define ACCEPT_LOCK() mtx_lock(&accept_mtx) +#define ACCEPT_UNLOCK() mtx_unlock(&accept_mtx) + +/* + * Per-socket mutex: we reuse the receive socket buffer mutex for space + * efficiency. This decision should probably be revisited as we optimize + * locking for the socket code. + */ +#define SOCK_MTX(_so) SOCKBUF_MTX(&(_so)->so_rcv) +#define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv) +#define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv) +#define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv) +#define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv) + +/* + * Socket state bits stored in so_qstate. + */ +#define SQ_INCOMP 0x0800 /* unaccepted, incomplete connection */ +#define SQ_COMP 0x1000 /* unaccepted, complete connection */ + +/* + * Externalized form of struct socket used by the sysctl(3) interface. + */ +struct xsocket { + size_t xso_len; /* length of this structure */ + struct socket *xso_so; /* makes a convenient handle sometimes */ + short so_type; + short so_options; + short so_linger; + short so_state; + caddr_t so_pcb; /* another convenient handle */ + int xso_protocol; + int xso_family; + u_short so_qlen; + u_short so_incqlen; + u_short so_qlimit; + short so_timeo; + u_short so_error; + pid_t so_pgid; + u_long so_oobmark; + struct xsockbuf so_rcv, so_snd; + uid_t so_uid; /* XXX */ +}; + +#ifdef _KERNEL + +/* + * Macros for sockets and socket buffering. + */ + +/* + * Flags to sblock(). + */ +#define SBL_WAIT 0x00000001 /* Wait if not immediately available. */ +#define SBL_NOINTR 0x00000002 /* Force non-interruptible sleep. */ +#define SBL_VALID (SBL_WAIT | SBL_NOINTR) + +/* + * Do we need to notify the other side when I/O is possible? + */ +#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \ + SB_UPCALL | SB_AIO | SB_KNOTE)) != 0) + +/* do we have to send all at once on a socket? */ +#define sosendallatonce(so) \ + ((so)->so_proto->pr_flags & PR_ATOMIC) + +/* can we read something from so? */ +#define soreadabledata(so) \ + ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \ + !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error) +#define soreadable(so) \ + (soreadabledata(so) || ((so)->so_rcv.sb_state & SBS_CANTRCVMORE)) + +/* can we write something to so? */ +#define sowriteable(so) \ + ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \ + (((so)->so_state&SS_ISCONNECTED) || \ + ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \ + ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \ + (so)->so_error) + +/* + * soref()/sorele() ref-count the socket structure. Note that you must + * still explicitly close the socket, but the last ref count will free + * the structure. + */ +#define soref(so) do { \ + SOCK_LOCK_ASSERT(so); \ + ++(so)->so_count; \ +} while (0) + +#define sorele(so) do { \ + ACCEPT_LOCK_ASSERT(); \ + SOCK_LOCK_ASSERT(so); \ + if ((so)->so_count <= 0) \ + panic("sorele"); \ + if (--(so)->so_count == 0) \ + sofree(so); \ + else { \ + SOCK_UNLOCK(so); \ + ACCEPT_UNLOCK(); \ + } \ +} while (0) + +#define sotryfree(so) do { \ + ACCEPT_LOCK_ASSERT(); \ + SOCK_LOCK_ASSERT(so); \ + if ((so)->so_count == 0) \ + sofree(so); \ + else { \ + SOCK_UNLOCK(so); \ + ACCEPT_UNLOCK(); \ + } \ +} while(0) + +/* + * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to + * avoid a non-atomic test-and-wakeup. However, sowakeup is + * responsible for releasing the lock if it is called. We unlock only + * if we don't call into sowakeup. If any code is introduced that + * directly invokes the underlying sowakeup() primitives, it must + * maintain the same semantics. + */ +#define sorwakeup_locked(so) do { \ + SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \ + if (sb_notify(&(so)->so_rcv)) \ + sowakeup((so), &(so)->so_rcv); \ + else \ + SOCKBUF_UNLOCK(&(so)->so_rcv); \ +} while (0) + +#define sorwakeup(so) do { \ + SOCKBUF_LOCK(&(so)->so_rcv); \ + sorwakeup_locked(so); \ +} while (0) + +#define sowwakeup_locked(so) do { \ + SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \ + if (sb_notify(&(so)->so_snd)) \ + sowakeup((so), &(so)->so_snd); \ + else \ + SOCKBUF_UNLOCK(&(so)->so_snd); \ +} while (0) + +#define sowwakeup(so) do { \ + SOCKBUF_LOCK(&(so)->so_snd); \ + sowwakeup_locked(so); \ +} while (0) + +struct accept_filter { + char accf_name[16]; + int (*accf_callback) + (struct socket *so, void *arg, int waitflag); + void * (*accf_create) + (struct socket *so, char *arg); + void (*accf_destroy) + (struct socket *so); + SLIST_ENTRY(accept_filter) accf_next; +}; + +#ifdef MALLOC_DECLARE +MALLOC_DECLARE(M_ACCF); +MALLOC_DECLARE(M_PCB); +MALLOC_DECLARE(M_SONAME); +#endif + +extern int maxsockets; +extern u_long sb_max; +extern struct uma_zone *socket_zone; +extern so_gen_t so_gencnt; + +struct mbuf; +struct sockaddr; +struct ucred; +struct uio; + +/* 'which' values for socket upcalls. */ +#define SO_RCV 1 +#define SO_SND 2 + +/* Return values for socket upcalls. */ +#define SU_OK 0 +#define SU_ISCONNECTED 1 + +/* + * From uipc_socket and friends + */ +int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type); +int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len); +void soabort(struct socket *so); +int soaccept(struct socket *so, struct sockaddr **nam); +int socheckuid(struct socket *so, uid_t uid); +int sobind(struct socket *so, struct sockaddr *nam, struct thread *td); +int soclose(struct socket *so); +int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td); +int soconnect2(struct socket *so1, struct socket *so2); +int socow_setup(struct mbuf *m0, struct uio *uio); +int socreate(int dom, struct socket **aso, int type, int proto, + struct ucred *cred, struct thread *td); +int sodisconnect(struct socket *so); +struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags); +void sofree(struct socket *so); +void sohasoutofband(struct socket *so); +int solisten(struct socket *so, int backlog, struct thread *td); +void solisten_proto(struct socket *so, int backlog); +int solisten_proto_check(struct socket *so); +struct socket * + sonewconn(struct socket *head, int connstatus); + + +int sopoll(struct socket *so, int events, struct ucred *active_cred, + struct thread *td); +int sopoll_generic(struct socket *so, int events, + struct ucred *active_cred, struct thread *td); +int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio, + struct mbuf **mp0, struct mbuf **controlp, int *flagsp); +int soreceive_stream(struct socket *so, struct sockaddr **paddr, + struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, + int *flagsp); +int soreceive_dgram(struct socket *so, struct sockaddr **paddr, + struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, + int *flagsp); +int soreceive_generic(struct socket *so, struct sockaddr **paddr, + struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, + int *flagsp); +int soreserve(struct socket *so, u_long sndcc, u_long rcvcc); +void sorflush(struct socket *so); +int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, + struct mbuf *top, struct mbuf *control, int flags, + struct thread *td); +int sosend_dgram(struct socket *so, struct sockaddr *addr, + struct uio *uio, struct mbuf *top, struct mbuf *control, + int flags, struct thread *td); +int sosend_generic(struct socket *so, struct sockaddr *addr, + struct uio *uio, struct mbuf *top, struct mbuf *control, + int flags, struct thread *td); +int soshutdown(struct socket *so, int how); +void sotoxsocket(struct socket *so, struct xsocket *xso); +void soupcall_clear(struct socket *so, int which); +void soupcall_set(struct socket *so, int which, + int (*func)(struct socket *, void *, int), void *arg); +void sowakeup(struct socket *so, struct sockbuf *sb); +int selsocket(struct socket *so, int events, struct timeval *tv, + struct thread *td); + +/* + * Accept filter functions (duh). + */ +int accept_filt_add(struct accept_filter *filt); +int accept_filt_del(char *name); +struct accept_filter *accept_filt_get(char *name); +#ifdef ACCEPT_FILTER_MOD +#ifdef SYSCTL_DECL +SYSCTL_DECL(_net_inet_accf); +#endif +int accept_filt_generic_mod_event(module_t mod, int event, void *data); +#endif + +#endif /* _KERNEL */ + +#endif /* !_SYS_SOCKETVAR_H_ */ diff --git a/freebsd/sys/sys/sockio.h b/freebsd/sys/sys/sockio.h index 319dc783..4c1c4839 100644 --- a/freebsd/sys/sys/sockio.h +++ b/freebsd/sys/sys/sockio.h @@ -30,10 +30,10 @@ * $FreeBSD$ */ -#ifndef _SYS_SOCKIO_HH_ -#define _SYS_SOCKIO_HH_ +#ifndef _SYS_SOCKIO_H_ +#define _SYS_SOCKIO_H_ -#include +#include /* Socket ioctl's. */ #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ @@ -125,4 +125,4 @@ #define SIOCDIFGROUP _IOW('i', 137, struct ifgroupreq) /* delete ifgroup */ #define SIOCGIFGMEMB _IOWR('i', 138, struct ifgroupreq) /* get members */ -#endif /* !_SYS_SOCKIO_HH_ */ +#endif /* !_SYS_SOCKIO_H_ */ diff --git a/freebsd/sys/sys/sockopt.h b/freebsd/sys/sys/sockopt.h index 09dc5599..69d6c6dc 100644 --- a/freebsd/sys/sys/sockopt.h +++ b/freebsd/sys/sys/sockopt.h @@ -30,8 +30,8 @@ * * $FreeBSD$ */ -#ifndef _SYS_SOCKOPT_HH_ -#define _SYS_SOCKOPT_HH_ +#ifndef _SYS_SOCKOPT_H_ +#define _SYS_SOCKOPT_H_ #ifndef _KERNEL #error "no user-servicable parts inside" @@ -69,4 +69,4 @@ int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt); int so_setsockopt(struct socket *so, int level, int optname, void *optval, size_t optlen); -#endif /* _SYS_SOCKOPT_HH_ */ +#endif /* _SYS_SOCKOPT_H_ */ diff --git a/freebsd/sys/sys/sockstate.h b/freebsd/sys/sys/sockstate.h index a6c4149d..52c85b76 100644 --- a/freebsd/sys/sys/sockstate.h +++ b/freebsd/sys/sys/sockstate.h @@ -30,8 +30,8 @@ * * $FreeBSD$ */ -#ifndef _SYS_SOCKTATE_HH_ -#define _SYS_SOCKTATE_HH_ +#ifndef _SYS_SOCKTATE_H_ +#define _SYS_SOCKTATE_H_ /* * Socket state bits. @@ -80,4 +80,4 @@ void socantrcvmore(struct socket *so); void socantrcvmore_locked(struct socket *so); void socantsendmore(struct socket *so); void socantsendmore_locked(struct socket *so); -#endif /* _SYS_SOCKTATE_HH_ */ +#endif /* _SYS_SOCKTATE_H_ */ diff --git a/freebsd/sys/sys/stddef.h b/freebsd/sys/sys/stddef.h index 85de99d8..df51c369 100644 --- a/freebsd/sys/sys/stddef.h +++ b/freebsd/sys/sys/stddef.h @@ -26,17 +26,17 @@ * $FreeBSD$ */ -#ifndef _SYS_STDDEF_HH_ -#define _SYS_STDDEF_HH_ - -#include -#include -#include +#ifndef _SYS_STDDEF_H_ +#define _SYS_STDDEF_H_ +#include #ifndef __rtems__ +#include +#include + typedef __ptrdiff_t ptrdiff_t; #define offsetof(type, field) __offsetof(type, field) #endif /* __rtems__ */ -#endif /* !_SYS_STDDEF_HH_ */ +#endif /* !_SYS_STDDEF_H_ */ diff --git a/freebsd/sys/sys/stdint.h b/freebsd/sys/sys/stdint.h index 10bab732..74e4a0ce 100644 --- a/freebsd/sys/sys/stdint.h +++ b/freebsd/sys/sys/stdint.h @@ -26,13 +26,14 @@ * $FreeBSD$ */ -#ifndef _SYS_STDINT_HH_ -#define _SYS_STDINT_HH_ +#ifndef _SYS_STDINT_H_ +#define _SYS_STDINT_H_ -#include -#include +#include +#include -#include +#ifndef __rtems__ +#include #ifndef _INT8_T_DECLARED typedef __int8_t int8_t; @@ -102,5 +103,6 @@ typedef __intptr_t intptr_t; typedef __uintptr_t uintptr_t; #define _INTPTR_T_DECLARED #endif +#endif /* __rtems__ */ -#endif /* !_SYS_STDINT_HH_ */ +#endif /* !_SYS_STDINT_H_ */ diff --git a/freebsd/sys/sys/sx.h b/freebsd/sys/sys/sx.h index e6a22c13..dc19023c 100644 --- a/freebsd/sys/sys/sx.h +++ b/freebsd/sys/sys/sx.h @@ -29,17 +29,17 @@ * $FreeBSD$ */ -#ifndef _SYS_SX_HH_ -#define _SYS_SX_HH_ +#ifndef _SYS_SX_H_ +#define _SYS_SX_H_ -#include -#include +#include +#include #ifdef _KERNEL -#include -#include -#include -#include +#include +#include +#include +#include #endif #ifdef __rtems__ @@ -210,7 +210,7 @@ __sx_sunlock(struct sx *sx, const char *file, int line) * Public interface for lock operations. */ #ifndef LOCK_DEBUG -#error "LOCK_DEBUG not defined, include before " +#error "LOCK_DEBUG not defined, include before " #endif #if (LOCK_DEBUG > 0) || defined(SX_NOINLINE) #define sx_xlock(sx) (void)_sx_xlock((sx), 0, LOCK_FILE, LOCK_LINE) @@ -304,4 +304,4 @@ int sx_xlocked(struct sx *sx); #endif /* _KERNEL */ -#endif /* !_SYS_SX_HH_ */ +#endif /* !_SYS_SX_H_ */ diff --git a/freebsd/sys/sys/sysctl.h b/freebsd/sys/sys/sysctl.h index 11ed653d..35c0e984 100644 --- a/freebsd/sys/sys/sysctl.h +++ b/freebsd/sys/sys/sysctl.h @@ -1,2 +1,762 @@ -#include -#include +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Karels at Berkeley Software Design, Inc. + * + * 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. + * 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. + * + * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 + * $FreeBSD$ + */ + +#ifndef _SYS_SYSCTL_H_ +#define _SYS_SYSCTL_H_ + +#include + +struct thread; +/* + * Definitions for sysctl call. The sysctl call uses a hierarchical name + * for objects that can be examined or modified. The name is expressed as + * a sequence of integers. Like a file path name, the meaning of each + * component depends on its place in the hierarchy. The top-level and kern + * identifiers are defined here, and other identifiers are defined in the + * respective subsystem header files. + */ + +#define CTL_MAXNAME 24 /* largest number of components supported */ + +/* + * Each subsystem defined by sysctl defines a list of variables + * for that subsystem. Each name is either a node with further + * levels defined below it, or it is a leaf of some particular + * type given below. Each sysctl level defines a set of name/type + * pairs to be used by sysctl(8) in manipulating the subsystem. + */ +struct ctlname { + char *ctl_name; /* subsystem name */ + int ctl_type; /* type of name */ +}; + +#define CTLTYPE 0xf /* Mask for the type */ +#define CTLTYPE_NODE 1 /* name is a node */ +#define CTLTYPE_INT 2 /* name describes an integer */ +#define CTLTYPE_STRING 3 /* name describes a string */ +#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ +#define CTLTYPE_OPAQUE 5 /* name describes a structure */ +#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ +#define CTLTYPE_UINT 6 /* name describes an unsigned integer */ +#define CTLTYPE_LONG 7 /* name describes a long */ +#define CTLTYPE_ULONG 8 /* name describes an unsigned long */ + +#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ +#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ +#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) +#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_PRISON 0x04000000 /* Prisoned roots can fiddle */ +#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ +#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ +#define CTLMASK_SECURE 0x00F00000 /* Secure level */ +#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ +#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ +#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) + +/* + * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. + * + * Secure when the securelevel is raised to at least N. + */ +#define CTLSHIFT_SECURE 20 +#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) +#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) +#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) + +/* + * USE THIS instead of a hardwired number from the categories below + * to get dynamically assigned sysctl entries using the linker-set + * technology. This is the way nearly all new sysctl variables should + * be implemented. + * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); + */ +#define OID_AUTO (-1) + +/* + * The starting number for dynamically-assigned entries. WARNING! + * ALL static sysctl entries should have numbers LESS than this! + */ +#define CTL_AUTO_START 0x100 + +#ifdef _KERNEL +#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \ + struct sysctl_req *req + +/* definitions for sysctl_req 'lock' member */ +#define REQ_UNLOCKED 0 /* not locked and not wired */ +#define REQ_LOCKED 1 /* locked and not wired */ +#define REQ_WIRED 2 /* locked and wired */ + +/* definitions for sysctl_req 'flags' member */ +#if defined(__amd64__) || defined(__ia64__) +#define SCTL_MASK32 1 /* 32 bit emulation */ +#endif + +/* + * This describes the access space for a sysctl request. This is needed + * so that we can use the interface from the kernel or from user-space. + */ +struct sysctl_req { + struct thread *td; /* used for access checking */ + int lock; /* locking/wiring state */ + void *oldptr; + size_t oldlen; + size_t oldidx; + int (*oldfunc)(struct sysctl_req *, const void *, size_t); +#ifndef __rtems__ + void *newptr; +#else /* __rtems__ */ + const void *newptr; +#endif /* __rtems__ */ + size_t newlen; + size_t newidx; + int (*newfunc)(struct sysctl_req *, void *, size_t); + size_t validlen; + int flags; +}; + +SLIST_HEAD(sysctl_oid_list, sysctl_oid); + +/* + * This describes one "oid" in the MIB tree. Potentially more nodes can + * be hidden behind it, expanded by the handler. + */ +struct sysctl_oid { + struct sysctl_oid_list *oid_parent; + SLIST_ENTRY(sysctl_oid) oid_link; + int oid_number; + u_int oid_kind; + void *oid_arg1; + int oid_arg2; + const char *oid_name; + int (*oid_handler)(SYSCTL_HANDLER_ARGS); + const char *oid_fmt; + int oid_refcnt; + const char *oid_descr; +}; + +#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) +#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) + +int sysctl_handle_int(SYSCTL_HANDLER_ARGS); +int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); +int sysctl_handle_long(SYSCTL_HANDLER_ARGS); +int sysctl_handle_quad(SYSCTL_HANDLER_ARGS); +int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS); +int sysctl_handle_string(SYSCTL_HANDLER_ARGS); +int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); + +int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); +int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); +int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); + +/* + * These functions are used to add/remove an oid from the mib. + */ +void sysctl_register_oid(struct sysctl_oid *oidp); +void sysctl_unregister_oid(struct sysctl_oid *oidp); + +/* Declare a static oid to allow child oids to be added to it. */ +#ifndef __rtems__ +#define SYSCTL_DECL(name) \ + extern struct sysctl_oid_list sysctl_##name##_children +#else /* __rtems__ */ +#define SYSCTL_DECL(name) \ + extern struct sysctl_oid_list _bsd_sysctl_##name##_children +#endif /* __rtems__ */ + +/* Hide these in macros */ +#define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \ + (oid_ptr)->oid_arg1 +#define SYSCTL_CHILDREN_SET(oid_ptr, val) \ + (oid_ptr)->oid_arg1 = (val); +#ifndef __rtems__ +#define SYSCTL_STATIC_CHILDREN(oid_name) \ + (&sysctl_##oid_name##_children) +#else /* __rtems__ */ +#define SYSCTL_STATIC_CHILDREN(oid_name) \ + (&_bsd_sysctl_##oid_name##_children) +#endif /* __rtems__ */ + +/* === Structs and macros related to context handling === */ + +/* All dynamically created sysctls can be tracked in a context list. */ +struct sysctl_ctx_entry { + struct sysctl_oid *entry; + TAILQ_ENTRY(sysctl_ctx_entry) link; +}; + +TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); + +#ifndef __rtems__ +#define SYSCTL_NODE_CHILDREN(parent, name) \ + sysctl_##parent##_##name##_children +#else /* __rtems__ */ +#define SYSCTL_NODE_CHILDREN(parent, name) \ + _bsd_sysctl_##parent##_##name##_children +#endif /* __rtems__ */ + +#ifndef NO_SYSCTL_DESCR +#define __DESCR(d) d +#else +#define __DESCR(d) "" +#endif + +/* This constructs a "raw" MIB oid. */ +#ifndef __rtems__ +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + static struct sysctl_oid sysctl__##parent##_##name = { \ + &sysctl_##parent##_children, { NULL }, nbr, kind, \ + a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ + DATA_SET(sysctl_set, sysctl__##parent##_##name) +#else /* __rtems__ */ +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + static struct sysctl_oid sysctl__##parent##_##name = { \ + &_bsd_sysctl_##parent##_children, { NULL }, nbr, kind, \ + a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ + DATA_SET(sysctl_set, sysctl__##parent##_##name) +#endif /* __rtems__ */ + +#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) + +/* This constructs a node from which other oids can hang. */ +#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ + struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ + (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr) + +#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ + NULL, 0, handler, "N", __DESCR(descr)) + +/* Oid for a string. len can be 0 to indicate '\0' termination. */ +#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ + arg, len, sysctl_handle_string, "A", descr) + +#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ + arg, len, sysctl_handle_string, "A", __DESCR(descr)) + +/* Oid for an int. If ptr is NULL, val is returned. */ +#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "I", descr) + +#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "I", __DESCR(descr)) + +/* Oid for an unsigned int. If ptr is NULL, val is returned. */ +#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "IU", descr) + +#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "IU", __DESCR(descr)) + +#define SYSCTL_XINT(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "IX", descr) + +#define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_int, "IX", __DESCR(descr)) + +/* Oid for a long. The pointer must be non NULL. */ +#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_long, "L", descr) + +#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ + ptr, 0, sysctl_handle_long, "L", __DESCR(descr)) + +/* Oid for an unsigned long. The pointer must be non NULL. */ +#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_long, "LU", __DESCR(descr)) + +#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ + ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)) + +#define SYSCTL_XLONG(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_long, "LX", __DESCR(descr)) + +#define SYSCTL_ADD_XLONG(ctx, parent, nbr, name, access, ptr, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ + ptr, 0, sysctl_handle_long, "LX", __DESCR(descr)) + +/* Oid for a quad. The pointer must be non NULL. */ +#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|CTLFLAG_MPSAFE|(access), \ + ptr, val, sysctl_handle_quad, "Q", __DESCR(descr)) + +#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|CTLFLAG_MPSAFE|(access), \ + ptr, 0, sysctl_handle_quad, "Q", __DESCR(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), \ + ptr, len, sysctl_handle_opaque, fmt, descr) + +#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ + ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)) + +/* Oid for a struct. Specified by a pointer and a type. */ +#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ + ptr, sizeof(struct type), sysctl_handle_opaque, \ + "S," #type, descr) + +#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ + ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr)) + +/* Oid for a procedure. Specified by a pointer and an arg. */ +#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ + SYSCTL_OID(parent, nbr, name, (access), \ + ptr, arg, handler, fmt, descr) + +#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ + sysctl_add_oid(ctx, parent, nbr, name, (access), \ + ptr, arg, handler, fmt, __DESCR(descr)) + +/* + * A macro to generate a read-only sysctl to indicate the presense of optional + * kernel features. + */ +#define FEATURE(name, desc) \ + SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD, 0, 1, desc) + +#endif /* _KERNEL */ + +/* + * Top-level identifiers + */ +#define CTL_UNSPEC 0 /* unused */ +#define CTL_KERN 1 /* "high kernel": proc, limits */ +#define CTL_VM 2 /* virtual memory */ +#define CTL_VFS 3 /* filesystem, mount type is next */ +#define CTL_NET 4 /* network, see socket.h */ +#define CTL_DEBUG 5 /* debugging parameters */ +#define CTL_HW 6 /* generic cpu/io */ +#define CTL_MACHDEP 7 /* machine dependent */ +#define CTL_USER 8 /* user-level */ +#define CTL_P1003_1B 9 /* POSIX 1003.1B */ +#define CTL_MAXID 10 /* number of valid top-level ids */ + +#define CTL_NAMES { \ + { 0, 0 }, \ + { "kern", CTLTYPE_NODE }, \ + { "vm", CTLTYPE_NODE }, \ + { "vfs", CTLTYPE_NODE }, \ + { "net", CTLTYPE_NODE }, \ + { "debug", CTLTYPE_NODE }, \ + { "hw", CTLTYPE_NODE }, \ + { "machdep", CTLTYPE_NODE }, \ + { "user", CTLTYPE_NODE }, \ + { "p1003_1b", CTLTYPE_NODE }, \ +} + +/* + * CTL_KERN identifiers + */ +#define KERN_OSTYPE 1 /* string: system version */ +#define KERN_OSRELEASE 2 /* string: system release */ +#define KERN_OSREV 3 /* int: system revision */ +#define KERN_VERSION 4 /* string: compile time info */ +#define KERN_MAXVNODES 5 /* int: max vnodes */ +#define KERN_MAXPROC 6 /* int: max processes */ +#define KERN_MAXFILES 7 /* int: max open files */ +#define KERN_ARGMAX 8 /* int: max arguments to exec */ +#define KERN_SECURELVL 9 /* int: system security level */ +#define KERN_HOSTNAME 10 /* string: hostname */ +#define KERN_HOSTID 11 /* int: host identifier */ +#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ +#define KERN_VNODE 13 /* struct: vnode structures */ +#define KERN_PROC 14 /* struct: process entries */ +#define KERN_FILE 15 /* struct: file entries */ +#define KERN_PROF 16 /* node: kernel profiling info */ +#define KERN_POSIX1 17 /* int: POSIX.1 version */ +#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ +#define KERN_JOB_CONTROL 19 /* int: is job control available */ +#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ +#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ +#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ +#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ +#define KERN_OSRELDATE 24 /* int: kernel release date */ +#define KERN_NTP_PLL 25 /* node: NTP PLL control */ +#define KERN_BOOTFILE 26 /* string: name of booted kernel */ +#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ +#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ +#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ +#define KERN_IPC 30 /* node: anything related to IPC */ +#define KERN_DUMMY 31 /* unused */ +#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ +#define KERN_USRSTACK 33 /* int: address of USRSTACK */ +#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ +#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ +#define KERN_HOSTUUID 36 /* string: host UUID identifier */ +#define KERN_ARND 37 /* int: from arc4rand() */ +#define KERN_MAXID 38 /* number of valid kern ids */ + +#define CTL_KERN_NAMES { \ + { 0, 0 }, \ + { "ostype", CTLTYPE_STRING }, \ + { "osrelease", CTLTYPE_STRING }, \ + { "osrevision", CTLTYPE_INT }, \ + { "version", CTLTYPE_STRING }, \ + { "maxvnodes", CTLTYPE_INT }, \ + { "maxproc", CTLTYPE_INT }, \ + { "maxfiles", CTLTYPE_INT }, \ + { "argmax", CTLTYPE_INT }, \ + { "securelevel", CTLTYPE_INT }, \ + { "hostname", CTLTYPE_STRING }, \ + { "hostid", CTLTYPE_UINT }, \ + { "clockrate", CTLTYPE_STRUCT }, \ + { "vnode", CTLTYPE_STRUCT }, \ + { "proc", CTLTYPE_STRUCT }, \ + { "file", CTLTYPE_STRUCT }, \ + { "profiling", CTLTYPE_NODE }, \ + { "posix1version", CTLTYPE_INT }, \ + { "ngroups", CTLTYPE_INT }, \ + { "job_control", CTLTYPE_INT }, \ + { "saved_ids", CTLTYPE_INT }, \ + { "boottime", CTLTYPE_STRUCT }, \ + { "nisdomainname", CTLTYPE_STRING }, \ + { "update", CTLTYPE_INT }, \ + { "osreldate", CTLTYPE_INT }, \ + { "ntp_pll", CTLTYPE_NODE }, \ + { "bootfile", CTLTYPE_STRING }, \ + { "maxfilesperproc", CTLTYPE_INT }, \ + { "maxprocperuid", CTLTYPE_INT }, \ + { "ipc", CTLTYPE_NODE }, \ + { "dummy", CTLTYPE_INT }, \ + { "ps_strings", CTLTYPE_INT }, \ + { "usrstack", CTLTYPE_INT }, \ + { "logsigexit", CTLTYPE_INT }, \ + { "iov_max", CTLTYPE_INT }, \ + { "hostuuid", CTLTYPE_STRING }, \ + { "arc4rand", CTLTYPE_OPAQUE }, \ +} + +/* + * CTL_VFS identifiers + */ +#define CTL_VFS_NAMES { \ + { "vfsconf", CTLTYPE_STRUCT }, \ +} + +/* + * KERN_PROC subtypes + */ +#define KERN_PROC_ALL 0 /* everything */ +#define KERN_PROC_PID 1 /* by process id */ +#define KERN_PROC_PGRP 2 /* by process group id */ +#define KERN_PROC_SESSION 3 /* by session of pid */ +#define KERN_PROC_TTY 4 /* by controlling tty */ +#define KERN_PROC_UID 5 /* by effective uid */ +#define KERN_PROC_RUID 6 /* by real uid */ +#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ +#define KERN_PROC_PROC 8 /* only return procs */ +#define KERN_PROC_SV_NAME 9 /* get syscall vector name */ +#define KERN_PROC_RGID 10 /* by real group id */ +#define KERN_PROC_GID 11 /* by effective group id */ +#define KERN_PROC_PATHNAME 12 /* path to executable */ +#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ +#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ +#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ +#define KERN_PROC_INC_THREAD 0x10 /* + * modifier for pid, pgrp, tty, + * uid, ruid, gid, rgid and proc + * This effectively uses 16-31 + */ +#define KERN_PROC_VMMAP 32 /* VM map entries for process */ +#define KERN_PROC_FILEDESC 33 /* File descriptors for process */ +#define KERN_PROC_GROUPS 34 /* process groups */ + +/* + * KERN_IPC identifiers + */ +#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ +#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ +#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ +#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ +#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ +#define KIPC_MAX_HDR 6 /* int: max total length of headers */ +#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ + +/* + * CTL_HW identifiers + */ +#define HW_MACHINE 1 /* string: machine class */ +#define HW_MODEL 2 /* string: specific machine model */ +#define HW_NCPU 3 /* int: number of cpus */ +#define HW_BYTEORDER 4 /* int: machine byte order */ +#define HW_PHYSMEM 5 /* int: total memory */ +#define HW_USERMEM 6 /* int: non-kernel memory */ +#define HW_PAGESIZE 7 /* int: software page size */ +#define HW_DISKNAMES 8 /* strings: disk drive names */ +#define HW_DISKSTATS 9 /* struct: diskstats[] */ +#define HW_FLOATINGPT 10 /* int: has HW floating point? */ +#define HW_MACHINE_ARCH 11 /* string: machine architecture */ +#define HW_REALMEM 12 /* int: 'real' memory */ +#define HW_MAXID 13 /* number of valid hw ids */ + +#define CTL_HW_NAMES { \ + { 0, 0 }, \ + { "machine", CTLTYPE_STRING }, \ + { "model", CTLTYPE_STRING }, \ + { "ncpu", CTLTYPE_INT }, \ + { "byteorder", CTLTYPE_INT }, \ + { "physmem", CTLTYPE_ULONG }, \ + { "usermem", CTLTYPE_ULONG }, \ + { "pagesize", CTLTYPE_INT }, \ + { "disknames", CTLTYPE_STRUCT }, \ + { "diskstats", CTLTYPE_STRUCT }, \ + { "floatingpoint", CTLTYPE_INT }, \ + { "machine_arch", CTLTYPE_STRING }, \ + { "realmem", CTLTYPE_ULONG }, \ +} + +/* + * CTL_USER definitions + */ +#define USER_CS_PATH 1 /* string: _CS_PATH */ +#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ +#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ +#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ +#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ +#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ +#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ +#define USER_LINE_MAX 8 /* int: LINE_MAX */ +#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ +#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ +#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ +#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ +#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ +#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ +#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ +#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ +#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ +#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ +#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ +#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ +#define USER_MAXID 21 /* number of valid user ids */ + +#define CTL_USER_NAMES { \ + { 0, 0 }, \ + { "cs_path", CTLTYPE_STRING }, \ + { "bc_base_max", CTLTYPE_INT }, \ + { "bc_dim_max", CTLTYPE_INT }, \ + { "bc_scale_max", CTLTYPE_INT }, \ + { "bc_string_max", CTLTYPE_INT }, \ + { "coll_weights_max", CTLTYPE_INT }, \ + { "expr_nest_max", CTLTYPE_INT }, \ + { "line_max", CTLTYPE_INT }, \ + { "re_dup_max", CTLTYPE_INT }, \ + { "posix2_version", CTLTYPE_INT }, \ + { "posix2_c_bind", CTLTYPE_INT }, \ + { "posix2_c_dev", CTLTYPE_INT }, \ + { "posix2_char_term", CTLTYPE_INT }, \ + { "posix2_fort_dev", CTLTYPE_INT }, \ + { "posix2_fort_run", CTLTYPE_INT }, \ + { "posix2_localedef", CTLTYPE_INT }, \ + { "posix2_sw_dev", CTLTYPE_INT }, \ + { "posix2_upe", CTLTYPE_INT }, \ + { "stream_max", CTLTYPE_INT }, \ + { "tzname_max", CTLTYPE_INT }, \ +} + +#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ +#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ +#define CTL_P1003_1B_MEMLOCK 3 /* boolean */ +#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ +#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ +#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ +#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ +#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ +#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ +#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ +#define CTL_P1003_1B_FSYNC 11 /* boolean */ +#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ +#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ +#define CTL_P1003_1B_TIMERS 14 /* boolean */ +#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ +#define CTL_P1003_1B_AIO_MAX 16 /* int */ +#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ +#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ +#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ +#define CTL_P1003_1B_PAGESIZE 20 /* int */ +#define CTL_P1003_1B_RTSIG_MAX 21 /* int */ +#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ +#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ +#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ +#define CTL_P1003_1B_TIMER_MAX 25 /* int */ + +#define CTL_P1003_1B_MAXID 26 + +#define CTL_P1003_1B_NAMES { \ + { 0, 0 }, \ + { "asynchronous_io", CTLTYPE_INT }, \ + { "mapped_files", CTLTYPE_INT }, \ + { "memlock", CTLTYPE_INT }, \ + { "memlock_range", CTLTYPE_INT }, \ + { "memory_protection", CTLTYPE_INT }, \ + { "message_passing", CTLTYPE_INT }, \ + { "prioritized_io", CTLTYPE_INT }, \ + { "priority_scheduling", CTLTYPE_INT }, \ + { "realtime_signals", CTLTYPE_INT }, \ + { "semaphores", CTLTYPE_INT }, \ + { "fsync", CTLTYPE_INT }, \ + { "shared_memory_objects", CTLTYPE_INT }, \ + { "synchronized_io", CTLTYPE_INT }, \ + { "timers", CTLTYPE_INT }, \ + { "aio_listio_max", CTLTYPE_INT }, \ + { "aio_max", CTLTYPE_INT }, \ + { "aio_prio_delta_max", CTLTYPE_INT }, \ + { "delaytimer_max", CTLTYPE_INT }, \ + { "mq_open_max", CTLTYPE_INT }, \ + { "pagesize", CTLTYPE_INT }, \ + { "rtsig_max", CTLTYPE_INT }, \ + { "nsems_max", CTLTYPE_INT }, \ + { "sem_value_max", CTLTYPE_INT }, \ + { "sigqueue_max", CTLTYPE_INT }, \ + { "timer_max", CTLTYPE_INT }, \ +} + +#ifdef _KERNEL + +/* + * Declare some common oids. + */ +#ifdef __rtems__ +#define sysctl__children _bsd_sysctl__children +#endif /* __rtems__ */ +extern struct sysctl_oid_list sysctl__children; +SYSCTL_DECL(_kern); +SYSCTL_DECL(_kern_features); +SYSCTL_DECL(_kern_ipc); +SYSCTL_DECL(_kern_proc); +SYSCTL_DECL(_kern_sched); +SYSCTL_DECL(_kern_sched_stats); +SYSCTL_DECL(_sysctl); +SYSCTL_DECL(_vm); +SYSCTL_DECL(_vm_stats); +SYSCTL_DECL(_vm_stats_misc); +SYSCTL_DECL(_vfs); +SYSCTL_DECL(_net); +SYSCTL_DECL(_debug); +SYSCTL_DECL(_debug_sizeof); +SYSCTL_DECL(_dev); +SYSCTL_DECL(_hw); +SYSCTL_DECL(_hw_bus); +SYSCTL_DECL(_hw_bus_devices); +SYSCTL_DECL(_hw_bus_info); +SYSCTL_DECL(_machdep); +SYSCTL_DECL(_user); +SYSCTL_DECL(_compat); +SYSCTL_DECL(_regression); +SYSCTL_DECL(_security); +SYSCTL_DECL(_security_bsd); + +extern char machine[]; +extern char osrelease[]; +extern char ostype[]; +extern char kern_ident[]; + +/* Dynamic oid handling */ +struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, + struct sysctl_oid_list *parent, int nbr, const char *name, + int kind, void *arg1, int arg2, + int (*handler) (SYSCTL_HANDLER_ARGS), + const char *fmt, const char *descr); +void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); +int sysctl_move_oid(struct sysctl_oid *oidp, + struct sysctl_oid_list *parent); +int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); +int sysctl_ctx_init(struct sysctl_ctx_list *clist); +int sysctl_ctx_free(struct sysctl_ctx_list *clist); +struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, + struct sysctl_oid *oidp); +struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, + struct sysctl_oid *oidp); +int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, + struct sysctl_oid *oidp); + +int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, +#ifndef __rtems__ + size_t *oldlenp, void *new, size_t newlen, +#else /* __rtems__ */ + size_t *oldlenp, const void *newp, size_t newlen, +#endif /* __rtems__ */ + size_t *retval, int flags); +#ifndef __rtems__ +int kernel_sysctlbyname(struct thread *td, char *name, + void *old, size_t *oldlenp, void *new, size_t newlen, + size_t *retval, int flags); +int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, + size_t *oldlenp, int inkernel, void *new, size_t newlen, + size_t *retval, int flags); +#endif /* __rtems__ */ +int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, + int *nindx, struct sysctl_req *req); +void sysctl_lock(void); +void sysctl_unlock(void); +int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); + +#ifndef __rtems__ +#else /* !_KERNEL */ +#endif /* __rtems__ */ +#include + +__BEGIN_DECLS +int sysctl(int *, u_int, void *, size_t *, void *, size_t); +int sysctlbyname(const char *, void *, size_t *, void *, size_t); +int sysctlnametomib(const char *, int *, size_t *); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* !_SYS_SYSCTL_H_ */ diff --git a/freebsd/sys/sys/syslog.h b/freebsd/sys/sys/syslog.h index a4aba4a1..5407a67e 100644 --- a/freebsd/sys/sys/syslog.h +++ b/freebsd/sys/sys/syslog.h @@ -186,15 +186,15 @@ CODE facilitynames[] = { * __va_list from and use it. */ #include -#include +#include __BEGIN_DECLS void closelog(void); void openlog(const char *, int, int); int setlogmask(int); -void syslog(int, const char *, ...); /* JRS __printflike(2, 3); */ +void syslog(int, const char *, ...) __printflike(2, 3); #if __BSD_VISIBLE -void vsyslog(int, const char *, __va_list); /* JRS __printflike(2, 0); */ +void vsyslog(int, const char *, __va_list) __printflike(2, 0); #endif __END_DECLS diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h index 731626ee..1ab467d0 100644 --- a/freebsd/sys/sys/systm.h +++ b/freebsd/sys/sys/systm.h @@ -35,15 +35,15 @@ * $FreeBSD$ */ -#ifndef _SYS_SYSTM_HH_ -#define _SYS_SYSTM_HH_ +#ifndef _SYS_SYSTM_H_ +#define _SYS_SYSTM_H_ -#include -#include -#include -#include -#include -#include /* for people using printf mainly */ +#include +#include +#include +#include +#include +#include /* for people using printf mainly */ extern int cold; /* nonzero if we are doing a cold boot */ extern int rebooting; /* boot() has been called. */ @@ -279,7 +279,7 @@ struct timeval; void adjust_timeout_calltodo(struct timeval *time_change); #endif /* APM_FIXUP_CALLTODO */ -#include +#include /* Initialize the world */ void consinit(void); @@ -420,4 +420,4 @@ bitcount32(uint32_t x) return (x); } -#endif /* !_SYS_SYSTM_HH_ */ +#endif /* !_SYS_SYSTM_H_ */ diff --git a/freebsd/sys/sys/taskqueue.h b/freebsd/sys/sys/taskqueue.h index d5da47a9..bf2e4ee3 100644 --- a/freebsd/sys/sys/taskqueue.h +++ b/freebsd/sys/sys/taskqueue.h @@ -26,15 +26,15 @@ * $FreeBSD$ */ -#ifndef _SYS_TASKQUEUE_HH_ -#define _SYS_TASKQUEUE_HH_ +#ifndef _SYS_TASKQUEUE_H_ +#define _SYS_TASKQUEUE_H_ #ifndef _KERNEL #error "no user-servicable parts inside" #endif -#include -#include +#include +#include struct taskqueue; struct thread; @@ -158,4 +158,4 @@ struct taskqueue *taskqueue_create_fast(const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context); -#endif /* !_SYS_TASKQUEUE_HH_ */ +#endif /* !_SYS_TASKQUEUE_H_ */ diff --git a/freebsd/sys/sys/timepps.h b/freebsd/sys/sys/timepps.h index 1e5e84fc..4f3ce646 100644 --- a/freebsd/sys/sys/timepps.h +++ b/freebsd/sys/sys/timepps.h @@ -12,11 +12,11 @@ * timing interfaces. */ -#ifndef _SYS_TIMEPPS_HH_ -#define _SYS_TIMEPPS_HH_ +#ifndef _SYS_TIMEPPS_H_ +#define _SYS_TIMEPPS_H_ -#include -#include +#include +#include #define PPS_API_VERS_1 1 @@ -197,4 +197,4 @@ time_pps_kcbind(pps_handle_t handle, const int kernel_consumer, #endif /* KERNEL */ -#endif /* !_SYS_TIMEPPS_HH_ */ +#endif /* !_SYS_TIMEPPS_H_ */ diff --git a/freebsd/sys/sys/timetc.h b/freebsd/sys/sys/timetc.h index 6b1c9b91..d5a818b4 100644 --- a/freebsd/sys/sys/timetc.h +++ b/freebsd/sys/sys/timetc.h @@ -9,8 +9,8 @@ * $FreeBSD$ */ -#ifndef _SYS_TIMETC_HH_ -#define _SYS_TIMETC_HH_ +#ifndef _SYS_TIMETC_H_ +#define _SYS_TIMETC_H_ #ifndef _KERNEL #error "no user-serviceable parts inside" @@ -75,4 +75,4 @@ void tc_ticktock(void); SYSCTL_DECL(_kern_timecounter); #endif -#endif /* !_SYS_TIMETC_HH_ */ +#endif /* !_SYS_TIMETC_H_ */ diff --git a/freebsd/sys/sys/timex.h b/freebsd/sys/sys/timex.h index 838a0e05..c34b5892 100644 --- a/freebsd/sys/sys/timex.h +++ b/freebsd/sys/sys/timex.h @@ -65,7 +65,7 @@ * ntp_gettime - NTP user application interface * * SYNOPSIS - * #include + * #include * * int ntp_gettime(struct ntptimeval *ntv); * @@ -80,8 +80,8 @@ * ntp_adjtime - NTP daemon application interface * * SYNOPSIS - * #include - * #include + * #include + * #include * * int syscall(SYS_ntp_adjtime, tptr); * int SYS_ntp_adjtime; @@ -93,13 +93,13 @@ * STA_NANO bit in the status word. See the description below for * further information. */ -#ifndef _SYS_TIMEX_HH_ -#define _SYS_TIMEX_HH_ 1 +#ifndef _SYS_TIMEX_H_ +#define _SYS_TIMEX_H_ 1 #define NTP_API 4 /* NTP API version */ #ifndef __rtems__ #ifndef MSDOS /* Microsoft specific */ -#include +#include #endif /* MSDOS */ #endif @@ -225,7 +225,7 @@ struct timex { #ifdef _KERNEL void ntp_update_second(int64_t *adjustment, time_t *newsec); #else /* !_KERNEL */ -#include +#include __BEGIN_DECLS int ntp_adjtime(struct timex *); @@ -235,4 +235,4 @@ __END_DECLS #endif /* __FreeBSD__ */ -#endif /* !_SYS_TIMEX_HH_ */ +#endif /* !_SYS_TIMEX_H_ */ diff --git a/freebsd/sys/sys/tree.h b/freebsd/sys/sys/tree.h index ed0b9a27..1cce7278 100644 --- a/freebsd/sys/sys/tree.h +++ b/freebsd/sys/sys/tree.h @@ -27,10 +27,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYS_TREE_HH_ -#define _SYS_TREE_HH_ +#ifndef _SYS_TREE_H_ +#define _SYS_TREE_H_ -#include +#include /* * This file defines data structures for different types of trees: @@ -762,4 +762,4 @@ name##_RB_MINMAX(struct name *head, int val) \ ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ (x) = (y)) -#endif /* _SYS_TREE_HH_ */ +#endif /* _SYS_TREE_H_ */ diff --git a/freebsd/sys/sys/tty.h b/freebsd/sys/sys/tty.h index a56d38fb..2cf454ef 100644 --- a/freebsd/sys/sys/tty.h +++ b/freebsd/sys/sys/tty.h @@ -29,20 +29,20 @@ * $FreeBSD$ */ -#ifndef _SYS_TTY_HH_ -#define _SYS_TTY_HH_ - -#include -#include -#include -#include -#include -#include +#ifndef _SYS_TTY_H_ +#define _SYS_TTY_H_ + +#include +#include +#include +#include +#include +#include #ifndef __rtems__ -#include +#include #endif -#include -#include +#include +#include struct cdev; struct file; @@ -209,9 +209,9 @@ int pts_alloc_external(int fd, struct thread *td, struct file *fp, struct cdev *dev, const char *name); /* Drivers and line disciplines also need to call these. */ -#include -#include -#include +#include +#include +#include #endif /* _KERNEL */ -#endif /* !_SYS_TTY_HH_ */ +#endif /* !_SYS_TTY_H_ */ diff --git a/freebsd/sys/sys/ttycom.h b/freebsd/sys/sys/ttycom.h index cf7cba42..60b6145e 100644 --- a/freebsd/sys/sys/ttycom.h +++ b/freebsd/sys/sys/ttycom.h @@ -35,10 +35,10 @@ * $FreeBSD$ */ -#ifndef _SYS_TTYCOM_HH_ -#define _SYS_TTYCOM_HH_ +#ifndef _SYS_TTYCOM_H_ +#define _SYS_TTYCOM_H_ -#include +#include /* * Tty ioctl's except for those supported only for backwards compatibility @@ -143,4 +143,4 @@ struct winsize { #define NETGRAPHDISC 6 /* Netgraph tty node discipline */ #define H4DISC 7 /* Netgraph Bluetooth H4 discipline */ -#endif /* !_SYS_TTYCOM_HH_ */ +#endif /* !_SYS_TTYCOM_H_ */ diff --git a/freebsd/sys/sys/ttydevsw.h b/freebsd/sys/sys/ttydevsw.h index a4035585..e2278c3a 100644 --- a/freebsd/sys/sys/ttydevsw.h +++ b/freebsd/sys/sys/ttydevsw.h @@ -29,12 +29,12 @@ * $FreeBSD$ */ -#ifndef _SYS_TTYDEVSW_HH_ -#define _SYS_TTYDEVSW_HH_ +#ifndef _SYS_TTYDEVSW_H_ +#define _SYS_TTYDEVSW_H_ -#ifndef _SYS_TTY_HH_ +#ifndef _SYS_TTY_H_ #error "can only be included through " -#endif /* !_SYS_TTY_HH_ */ +#endif /* !_SYS_TTY_H_ */ /* * Driver routines that are called from the line discipline to adjust @@ -166,4 +166,4 @@ ttydevsw_free(struct tty *tp) tp->t_devsw->tsw_free(tty_softc(tp)); } -#endif /* !_SYS_TTYDEVSW_HH_ */ +#endif /* !_SYS_TTYDEVSW_H_ */ diff --git a/freebsd/sys/sys/ttydisc.h b/freebsd/sys/sys/ttydisc.h index 00194988..2ea54666 100644 --- a/freebsd/sys/sys/ttydisc.h +++ b/freebsd/sys/sys/ttydisc.h @@ -29,12 +29,12 @@ * $FreeBSD$ */ -#ifndef _SYS_TTYDISC_HH_ -#define _SYS_TTYDISC_HH_ +#ifndef _SYS_TTYDISC_H_ +#define _SYS_TTYDISC_H_ -#ifndef _SYS_TTY_HH_ +#ifndef _SYS_TTY_H_ #error "can only be included through " -#endif /* !_SYS_TTY_HH_ */ +#endif /* !_SYS_TTY_H_ */ struct cv; struct thread; @@ -83,4 +83,4 @@ ttydisc_write_poll(struct tty *tp) return ttyoutq_bytesleft(&tp->t_outq); } -#endif /* !_SYS_TTYDISC_HH_ */ +#endif /* !_SYS_TTYDISC_H_ */ diff --git a/freebsd/sys/sys/ttyhook.h b/freebsd/sys/sys/ttyhook.h index a15fbbb7..2a6d0887 100644 --- a/freebsd/sys/sys/ttyhook.h +++ b/freebsd/sys/sys/ttyhook.h @@ -26,12 +26,12 @@ * $FreeBSD$ */ -#ifndef _SYS_TTYHOOK_HH_ -#define _SYS_TTYHOOK_HH_ +#ifndef _SYS_TTYHOOK_H_ +#define _SYS_TTYHOOK_H_ -#ifndef _SYS_TTY_HH_ +#ifndef _SYS_TTY_H_ #error "can only be included through " -#endif /* !_SYS_TTY_HH_ */ +#endif /* !_SYS_TTY_H_ */ struct tty; @@ -144,4 +144,4 @@ ttyhook_close(struct tty *tp) tp->t_hook->th_close(tp); } -#endif /* !_SYS_TTYHOOK_HH_ */ +#endif /* !_SYS_TTYHOOK_H_ */ diff --git a/freebsd/sys/sys/ttyqueue.h b/freebsd/sys/sys/ttyqueue.h index b9228bdc..2d1a565a 100644 --- a/freebsd/sys/sys/ttyqueue.h +++ b/freebsd/sys/sys/ttyqueue.h @@ -29,12 +29,12 @@ * $FreeBSD$ */ -#ifndef _SYS_TTYQUEUE_HH_ -#define _SYS_TTYQUEUE_HH_ +#ifndef _SYS_TTYQUEUE_H_ +#define _SYS_TTYQUEUE_H_ -#ifndef _SYS_TTY_HH_ +#ifndef _SYS_TTY_H_ #error "can only be included through " -#endif /* !_SYS_TTY_HH_ */ +#endif /* !_SYS_TTY_H_ */ struct tty; struct ttyinq_block; @@ -175,4 +175,4 @@ ttyoutq_bytesused(struct ttyoutq *to) } #endif /* _KERNEL */ -#endif /* !_SYS_TTYQUEUE_HH_ */ +#endif /* !_SYS_TTYQUEUE_H_ */ diff --git a/freebsd/sys/sys/ucred.h b/freebsd/sys/sys/ucred.h index 917cc750..a8934cec 100644 --- a/freebsd/sys/sys/ucred.h +++ b/freebsd/sys/sys/ucred.h @@ -30,10 +30,10 @@ * $FreeBSD$ */ -#ifndef _SYS_UCRED_HH_ -#define _SYS_UCRED_HH_ +#ifndef _SYS_UCRED_H_ +#define _SYS_UCRED_H_ -#include +#include /* * Credentials. @@ -107,4 +107,4 @@ void crsetgroups(struct ucred *cr, int n, gid_t *groups); int groupmember(gid_t gid, struct ucred *cred); #endif /* _KERNEL */ -#endif /* !_SYS_UCRED_HH_ */ +#endif /* !_SYS_UCRED_H_ */ diff --git a/freebsd/sys/sys/un.h b/freebsd/sys/sys/un.h index 1f4731e6..a858abf4 100644 --- a/freebsd/sys/sys/un.h +++ b/freebsd/sys/sys/un.h @@ -34,7 +34,7 @@ #define _SYS_UN_H_ #include -#include +#include #ifndef _SA_FAMILY_T_DECLARED typedef __sa_family_t sa_family_t; diff --git a/freebsd/sys/sys/user.h b/freebsd/sys/sys/user.h index df788c06..7ca16ad0 100644 --- a/freebsd/sys/sys/user.h +++ b/freebsd/sys/sys/user.h @@ -32,34 +32,34 @@ * $FreeBSD$ */ -#ifndef _SYS_USER_HH_ -#define _SYS_USER_HH_ +#ifndef _SYS_USER_H_ +#define _SYS_USER_H_ -#include +#include #ifndef _KERNEL /* stuff that *used* to be included by user.h, or is now needed */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ -#include /* XXX */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ +#include /* XXX */ #endif /* !_KERNEL */ -#ifndef _SYS_RESOURCEVAR_HH_ -#include +#ifndef _SYS_RESOURCEVAR_H_ +#include #endif -#ifndef _SYS_SIGNALVAR_HH_ -#include +#ifndef _SYS_SIGNALVAR_H_ +#include #endif -#ifndef _SYS_SOCKET_VAR_HH_ -#include +#ifndef _SYS_SOCKET_VAR_H_ +#include #endif /* diff --git a/freebsd/sys/sys/vmmeter.h b/freebsd/sys/sys/vmmeter.h index 3a470074..6c866c7f 100644 --- a/freebsd/sys/sys/vmmeter.h +++ b/freebsd/sys/sys/vmmeter.h @@ -30,8 +30,8 @@ * $FreeBSD$ */ -#ifndef _SYS_VMMETER_HH_ -#define _SYS_VMMETER_HH_ +#ifndef _SYS_VMMETER_H_ +#define _SYS_VMMETER_H_ /* * System wide statistics counters. diff --git a/freebsd/sys/sysctl.h b/freebsd/sys/sysctl.h deleted file mode 100644 index b2a421f5..00000000 --- a/freebsd/sys/sysctl.h +++ /dev/null @@ -1,762 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Karels at Berkeley Software Design, Inc. - * - * 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. - * 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. - * - * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ - */ - -#ifndef _SYS_SYSCTL_HH_ -#define _SYS_SYSCTL_HH_ - -#include - -struct thread; -/* - * Definitions for sysctl call. The sysctl call uses a hierarchical name - * for objects that can be examined or modified. The name is expressed as - * a sequence of integers. Like a file path name, the meaning of each - * component depends on its place in the hierarchy. The top-level and kern - * identifiers are defined here, and other identifiers are defined in the - * respective subsystem header files. - */ - -#define CTL_MAXNAME 24 /* largest number of components supported */ - -/* - * Each subsystem defined by sysctl defines a list of variables - * for that subsystem. Each name is either a node with further - * levels defined below it, or it is a leaf of some particular - * type given below. Each sysctl level defines a set of name/type - * pairs to be used by sysctl(8) in manipulating the subsystem. - */ -struct ctlname { - char *ctl_name; /* subsystem name */ - int ctl_type; /* type of name */ -}; - -#define CTLTYPE 0xf /* Mask for the type */ -#define CTLTYPE_NODE 1 /* name is a node */ -#define CTLTYPE_INT 2 /* name describes an integer */ -#define CTLTYPE_STRING 3 /* name describes a string */ -#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ -#define CTLTYPE_OPAQUE 5 /* name describes a structure */ -#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ -#define CTLTYPE_UINT 6 /* name describes an unsigned integer */ -#define CTLTYPE_LONG 7 /* name describes a long */ -#define CTLTYPE_ULONG 8 /* name describes an unsigned long */ - -#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ -#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ -#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) -#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_PRISON 0x04000000 /* Prisoned roots can fiddle */ -#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ -#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ -#define CTLMASK_SECURE 0x00F00000 /* Secure level */ -#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ -#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ -#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ -#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) - -/* - * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. - * - * Secure when the securelevel is raised to at least N. - */ -#define CTLSHIFT_SECURE 20 -#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) -#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) -#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) - -/* - * USE THIS instead of a hardwired number from the categories below - * to get dynamically assigned sysctl entries using the linker-set - * technology. This is the way nearly all new sysctl variables should - * be implemented. - * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); - */ -#define OID_AUTO (-1) - -/* - * The starting number for dynamically-assigned entries. WARNING! - * ALL static sysctl entries should have numbers LESS than this! - */ -#define CTL_AUTO_START 0x100 - -#ifdef _KERNEL -#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \ - struct sysctl_req *req - -/* definitions for sysctl_req 'lock' member */ -#define REQ_UNLOCKED 0 /* not locked and not wired */ -#define REQ_LOCKED 1 /* locked and not wired */ -#define REQ_WIRED 2 /* locked and wired */ - -/* definitions for sysctl_req 'flags' member */ -#if defined(__amd64__) || defined(__ia64__) -#define SCTL_MASK32 1 /* 32 bit emulation */ -#endif - -/* - * This describes the access space for a sysctl request. This is needed - * so that we can use the interface from the kernel or from user-space. - */ -struct sysctl_req { - struct thread *td; /* used for access checking */ - int lock; /* locking/wiring state */ - void *oldptr; - size_t oldlen; - size_t oldidx; - int (*oldfunc)(struct sysctl_req *, const void *, size_t); -#ifndef __rtems__ - void *newptr; -#else /* __rtems__ */ - const void *newptr; -#endif /* __rtems__ */ - size_t newlen; - size_t newidx; - int (*newfunc)(struct sysctl_req *, void *, size_t); - size_t validlen; - int flags; -}; - -SLIST_HEAD(sysctl_oid_list, sysctl_oid); - -/* - * This describes one "oid" in the MIB tree. Potentially more nodes can - * be hidden behind it, expanded by the handler. - */ -struct sysctl_oid { - struct sysctl_oid_list *oid_parent; - SLIST_ENTRY(sysctl_oid) oid_link; - int oid_number; - u_int oid_kind; - void *oid_arg1; - int oid_arg2; - const char *oid_name; - int (*oid_handler)(SYSCTL_HANDLER_ARGS); - const char *oid_fmt; - int oid_refcnt; - const char *oid_descr; -}; - -#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) -#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) - -int sysctl_handle_int(SYSCTL_HANDLER_ARGS); -int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); -int sysctl_handle_long(SYSCTL_HANDLER_ARGS); -int sysctl_handle_quad(SYSCTL_HANDLER_ARGS); -int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS); -int sysctl_handle_string(SYSCTL_HANDLER_ARGS); -int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); - -int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); -int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); -int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); - -/* - * These functions are used to add/remove an oid from the mib. - */ -void sysctl_register_oid(struct sysctl_oid *oidp); -void sysctl_unregister_oid(struct sysctl_oid *oidp); - -/* Declare a static oid to allow child oids to be added to it. */ -#ifndef __rtems__ -#define SYSCTL_DECL(name) \ - extern struct sysctl_oid_list sysctl_##name##_children -#else /* __rtems__ */ -#define SYSCTL_DECL(name) \ - extern struct sysctl_oid_list _bsd_sysctl_##name##_children -#endif /* __rtems__ */ - -/* Hide these in macros */ -#define SYSCTL_CHILDREN(oid_ptr) (struct sysctl_oid_list *) \ - (oid_ptr)->oid_arg1 -#define SYSCTL_CHILDREN_SET(oid_ptr, val) \ - (oid_ptr)->oid_arg1 = (val); -#ifndef __rtems__ -#define SYSCTL_STATIC_CHILDREN(oid_name) \ - (&sysctl_##oid_name##_children) -#else /* __rtems__ */ -#define SYSCTL_STATIC_CHILDREN(oid_name) \ - (&_bsd_sysctl_##oid_name##_children) -#endif /* __rtems__ */ - -/* === Structs and macros related to context handling === */ - -/* All dynamically created sysctls can be tracked in a context list. */ -struct sysctl_ctx_entry { - struct sysctl_oid *entry; - TAILQ_ENTRY(sysctl_ctx_entry) link; -}; - -TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); - -#ifndef __rtems__ -#define SYSCTL_NODE_CHILDREN(parent, name) \ - sysctl_##parent##_##name##_children -#else /* __rtems__ */ -#define SYSCTL_NODE_CHILDREN(parent, name) \ - _bsd_sysctl_##parent##_##name##_children -#endif /* __rtems__ */ - -#ifndef NO_SYSCTL_DESCR -#define __DESCR(d) d -#else -#define __DESCR(d) "" -#endif - -/* This constructs a "raw" MIB oid. */ -#ifndef __rtems__ -#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - static struct sysctl_oid sysctl__##parent##_##name = { \ - &sysctl_##parent##_children, { NULL }, nbr, kind, \ - a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ - DATA_SET(sysctl_set, sysctl__##parent##_##name) -#else /* __rtems__ */ -#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - static struct sysctl_oid sysctl__##parent##_##name = { \ - &_bsd_sysctl_##parent##_children, { NULL }, nbr, kind, \ - a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ - DATA_SET(sysctl_set, sysctl__##parent##_##name) -#endif /* __rtems__ */ - -#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) - -/* This constructs a node from which other oids can hang. */ -#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ - struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ - (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr) - -#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ - NULL, 0, handler, "N", __DESCR(descr)) - -/* Oid for a string. len can be 0 to indicate '\0' termination. */ -#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ - arg, len, sysctl_handle_string, "A", descr) - -#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ - arg, len, sysctl_handle_string, "A", __DESCR(descr)) - -/* Oid for an int. If ptr is NULL, val is returned. */ -#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "I", descr) - -#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "I", __DESCR(descr)) - -/* Oid for an unsigned int. If ptr is NULL, val is returned. */ -#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "IU", descr) - -#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "IU", __DESCR(descr)) - -#define SYSCTL_XINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "IX", descr) - -#define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_int, "IX", __DESCR(descr)) - -/* Oid for a long. The pointer must be non NULL. */ -#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_long, "L", descr) - -#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ - ptr, 0, sysctl_handle_long, "L", __DESCR(descr)) - -/* Oid for an unsigned long. The pointer must be non NULL. */ -#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_long, "LU", __DESCR(descr)) - -#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ - ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)) - -#define SYSCTL_XLONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_long, "LX", __DESCR(descr)) - -#define SYSCTL_ADD_XLONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ - ptr, 0, sysctl_handle_long, "LX", __DESCR(descr)) - -/* Oid for a quad. The pointer must be non NULL. */ -#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|CTLFLAG_MPSAFE|(access), \ - ptr, val, sysctl_handle_quad, "Q", __DESCR(descr)) - -#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|CTLFLAG_MPSAFE|(access), \ - ptr, 0, sysctl_handle_quad, "Q", __DESCR(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), \ - ptr, len, sysctl_handle_opaque, fmt, descr) - -#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr)\ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ - ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)) - -/* Oid for a struct. Specified by a pointer and a type. */ -#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ - ptr, sizeof(struct type), sysctl_handle_opaque, \ - "S," #type, descr) - -#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ - ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr)) - -/* Oid for a procedure. Specified by a pointer and an arg. */ -#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ - SYSCTL_OID(parent, nbr, name, (access), \ - ptr, arg, handler, fmt, descr) - -#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, (access), \ - ptr, arg, handler, fmt, __DESCR(descr)) - -/* - * A macro to generate a read-only sysctl to indicate the presense of optional - * kernel features. - */ -#define FEATURE(name, desc) \ - SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD, 0, 1, desc) - -#endif /* _KERNEL */ - -/* - * Top-level identifiers - */ -#define CTL_UNSPEC 0 /* unused */ -#define CTL_KERN 1 /* "high kernel": proc, limits */ -#define CTL_VM 2 /* virtual memory */ -#define CTL_VFS 3 /* filesystem, mount type is next */ -#define CTL_NET 4 /* network, see socket.h */ -#define CTL_DEBUG 5 /* debugging parameters */ -#define CTL_HW 6 /* generic cpu/io */ -#define CTL_MACHDEP 7 /* machine dependent */ -#define CTL_USER 8 /* user-level */ -#define CTL_P1003_1B 9 /* POSIX 1003.1B */ -#define CTL_MAXID 10 /* number of valid top-level ids */ - -#define CTL_NAMES { \ - { 0, 0 }, \ - { "kern", CTLTYPE_NODE }, \ - { "vm", CTLTYPE_NODE }, \ - { "vfs", CTLTYPE_NODE }, \ - { "net", CTLTYPE_NODE }, \ - { "debug", CTLTYPE_NODE }, \ - { "hw", CTLTYPE_NODE }, \ - { "machdep", CTLTYPE_NODE }, \ - { "user", CTLTYPE_NODE }, \ - { "p1003_1b", CTLTYPE_NODE }, \ -} - -/* - * CTL_KERN identifiers - */ -#define KERN_OSTYPE 1 /* string: system version */ -#define KERN_OSRELEASE 2 /* string: system release */ -#define KERN_OSREV 3 /* int: system revision */ -#define KERN_VERSION 4 /* string: compile time info */ -#define KERN_MAXVNODES 5 /* int: max vnodes */ -#define KERN_MAXPROC 6 /* int: max processes */ -#define KERN_MAXFILES 7 /* int: max open files */ -#define KERN_ARGMAX 8 /* int: max arguments to exec */ -#define KERN_SECURELVL 9 /* int: system security level */ -#define KERN_HOSTNAME 10 /* string: hostname */ -#define KERN_HOSTID 11 /* int: host identifier */ -#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ -#define KERN_VNODE 13 /* struct: vnode structures */ -#define KERN_PROC 14 /* struct: process entries */ -#define KERN_FILE 15 /* struct: file entries */ -#define KERN_PROF 16 /* node: kernel profiling info */ -#define KERN_POSIX1 17 /* int: POSIX.1 version */ -#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ -#define KERN_JOB_CONTROL 19 /* int: is job control available */ -#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ -#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ -#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ -#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ -#define KERN_OSRELDATE 24 /* int: kernel release date */ -#define KERN_NTP_PLL 25 /* node: NTP PLL control */ -#define KERN_BOOTFILE 26 /* string: name of booted kernel */ -#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ -#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ -#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ -#define KERN_IPC 30 /* node: anything related to IPC */ -#define KERN_DUMMY 31 /* unused */ -#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ -#define KERN_USRSTACK 33 /* int: address of USRSTACK */ -#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ -#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ -#define KERN_HOSTUUID 36 /* string: host UUID identifier */ -#define KERN_ARND 37 /* int: from arc4rand() */ -#define KERN_MAXID 38 /* number of valid kern ids */ - -#define CTL_KERN_NAMES { \ - { 0, 0 }, \ - { "ostype", CTLTYPE_STRING }, \ - { "osrelease", CTLTYPE_STRING }, \ - { "osrevision", CTLTYPE_INT }, \ - { "version", CTLTYPE_STRING }, \ - { "maxvnodes", CTLTYPE_INT }, \ - { "maxproc", CTLTYPE_INT }, \ - { "maxfiles", CTLTYPE_INT }, \ - { "argmax", CTLTYPE_INT }, \ - { "securelevel", CTLTYPE_INT }, \ - { "hostname", CTLTYPE_STRING }, \ - { "hostid", CTLTYPE_UINT }, \ - { "clockrate", CTLTYPE_STRUCT }, \ - { "vnode", CTLTYPE_STRUCT }, \ - { "proc", CTLTYPE_STRUCT }, \ - { "file", CTLTYPE_STRUCT }, \ - { "profiling", CTLTYPE_NODE }, \ - { "posix1version", CTLTYPE_INT }, \ - { "ngroups", CTLTYPE_INT }, \ - { "job_control", CTLTYPE_INT }, \ - { "saved_ids", CTLTYPE_INT }, \ - { "boottime", CTLTYPE_STRUCT }, \ - { "nisdomainname", CTLTYPE_STRING }, \ - { "update", CTLTYPE_INT }, \ - { "osreldate", CTLTYPE_INT }, \ - { "ntp_pll", CTLTYPE_NODE }, \ - { "bootfile", CTLTYPE_STRING }, \ - { "maxfilesperproc", CTLTYPE_INT }, \ - { "maxprocperuid", CTLTYPE_INT }, \ - { "ipc", CTLTYPE_NODE }, \ - { "dummy", CTLTYPE_INT }, \ - { "ps_strings", CTLTYPE_INT }, \ - { "usrstack", CTLTYPE_INT }, \ - { "logsigexit", CTLTYPE_INT }, \ - { "iov_max", CTLTYPE_INT }, \ - { "hostuuid", CTLTYPE_STRING }, \ - { "arc4rand", CTLTYPE_OPAQUE }, \ -} - -/* - * CTL_VFS identifiers - */ -#define CTL_VFS_NAMES { \ - { "vfsconf", CTLTYPE_STRUCT }, \ -} - -/* - * KERN_PROC subtypes - */ -#define KERN_PROC_ALL 0 /* everything */ -#define KERN_PROC_PID 1 /* by process id */ -#define KERN_PROC_PGRP 2 /* by process group id */ -#define KERN_PROC_SESSION 3 /* by session of pid */ -#define KERN_PROC_TTY 4 /* by controlling tty */ -#define KERN_PROC_UID 5 /* by effective uid */ -#define KERN_PROC_RUID 6 /* by real uid */ -#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ -#define KERN_PROC_PROC 8 /* only return procs */ -#define KERN_PROC_SV_NAME 9 /* get syscall vector name */ -#define KERN_PROC_RGID 10 /* by real group id */ -#define KERN_PROC_GID 11 /* by effective group id */ -#define KERN_PROC_PATHNAME 12 /* path to executable */ -#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ -#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ -#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ -#define KERN_PROC_INC_THREAD 0x10 /* - * modifier for pid, pgrp, tty, - * uid, ruid, gid, rgid and proc - * This effectively uses 16-31 - */ -#define KERN_PROC_VMMAP 32 /* VM map entries for process */ -#define KERN_PROC_FILEDESC 33 /* File descriptors for process */ -#define KERN_PROC_GROUPS 34 /* process groups */ - -/* - * KERN_IPC identifiers - */ -#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ -#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ -#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ -#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ -#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ -#define KIPC_MAX_HDR 6 /* int: max total length of headers */ -#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ - -/* - * CTL_HW identifiers - */ -#define HW_MACHINE 1 /* string: machine class */ -#define HW_MODEL 2 /* string: specific machine model */ -#define HW_NCPU 3 /* int: number of cpus */ -#define HW_BYTEORDER 4 /* int: machine byte order */ -#define HW_PHYSMEM 5 /* int: total memory */ -#define HW_USERMEM 6 /* int: non-kernel memory */ -#define HW_PAGESIZE 7 /* int: software page size */ -#define HW_DISKNAMES 8 /* strings: disk drive names */ -#define HW_DISKSTATS 9 /* struct: diskstats[] */ -#define HW_FLOATINGPT 10 /* int: has HW floating point? */ -#define HW_MACHINE_ARCH 11 /* string: machine architecture */ -#define HW_REALMEM 12 /* int: 'real' memory */ -#define HW_MAXID 13 /* number of valid hw ids */ - -#define CTL_HW_NAMES { \ - { 0, 0 }, \ - { "machine", CTLTYPE_STRING }, \ - { "model", CTLTYPE_STRING }, \ - { "ncpu", CTLTYPE_INT }, \ - { "byteorder", CTLTYPE_INT }, \ - { "physmem", CTLTYPE_ULONG }, \ - { "usermem", CTLTYPE_ULONG }, \ - { "pagesize", CTLTYPE_INT }, \ - { "disknames", CTLTYPE_STRUCT }, \ - { "diskstats", CTLTYPE_STRUCT }, \ - { "floatingpoint", CTLTYPE_INT }, \ - { "machine_arch", CTLTYPE_STRING }, \ - { "realmem", CTLTYPE_ULONG }, \ -} - -/* - * CTL_USER definitions - */ -#define USER_CS_PATH 1 /* string: _CS_PATH */ -#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ -#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ -#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ -#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ -#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ -#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ -#define USER_LINE_MAX 8 /* int: LINE_MAX */ -#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ -#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ -#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ -#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ -#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ -#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ -#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ -#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ -#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ -#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ -#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ -#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ -#define USER_MAXID 21 /* number of valid user ids */ - -#define CTL_USER_NAMES { \ - { 0, 0 }, \ - { "cs_path", CTLTYPE_STRING }, \ - { "bc_base_max", CTLTYPE_INT }, \ - { "bc_dim_max", CTLTYPE_INT }, \ - { "bc_scale_max", CTLTYPE_INT }, \ - { "bc_string_max", CTLTYPE_INT }, \ - { "coll_weights_max", CTLTYPE_INT }, \ - { "expr_nest_max", CTLTYPE_INT }, \ - { "line_max", CTLTYPE_INT }, \ - { "re_dup_max", CTLTYPE_INT }, \ - { "posix2_version", CTLTYPE_INT }, \ - { "posix2_c_bind", CTLTYPE_INT }, \ - { "posix2_c_dev", CTLTYPE_INT }, \ - { "posix2_char_term", CTLTYPE_INT }, \ - { "posix2_fort_dev", CTLTYPE_INT }, \ - { "posix2_fort_run", CTLTYPE_INT }, \ - { "posix2_localedef", CTLTYPE_INT }, \ - { "posix2_sw_dev", CTLTYPE_INT }, \ - { "posix2_upe", CTLTYPE_INT }, \ - { "stream_max", CTLTYPE_INT }, \ - { "tzname_max", CTLTYPE_INT }, \ -} - -#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ -#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ -#define CTL_P1003_1B_MEMLOCK 3 /* boolean */ -#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ -#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ -#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ -#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ -#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ -#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ -#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ -#define CTL_P1003_1B_FSYNC 11 /* boolean */ -#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ -#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ -#define CTL_P1003_1B_TIMERS 14 /* boolean */ -#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ -#define CTL_P1003_1B_AIO_MAX 16 /* int */ -#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ -#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ -#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ -#define CTL_P1003_1B_PAGESIZE 20 /* int */ -#define CTL_P1003_1B_RTSIG_MAX 21 /* int */ -#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ -#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ -#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ -#define CTL_P1003_1B_TIMER_MAX 25 /* int */ - -#define CTL_P1003_1B_MAXID 26 - -#define CTL_P1003_1B_NAMES { \ - { 0, 0 }, \ - { "asynchronous_io", CTLTYPE_INT }, \ - { "mapped_files", CTLTYPE_INT }, \ - { "memlock", CTLTYPE_INT }, \ - { "memlock_range", CTLTYPE_INT }, \ - { "memory_protection", CTLTYPE_INT }, \ - { "message_passing", CTLTYPE_INT }, \ - { "prioritized_io", CTLTYPE_INT }, \ - { "priority_scheduling", CTLTYPE_INT }, \ - { "realtime_signals", CTLTYPE_INT }, \ - { "semaphores", CTLTYPE_INT }, \ - { "fsync", CTLTYPE_INT }, \ - { "shared_memory_objects", CTLTYPE_INT }, \ - { "synchronized_io", CTLTYPE_INT }, \ - { "timers", CTLTYPE_INT }, \ - { "aio_listio_max", CTLTYPE_INT }, \ - { "aio_max", CTLTYPE_INT }, \ - { "aio_prio_delta_max", CTLTYPE_INT }, \ - { "delaytimer_max", CTLTYPE_INT }, \ - { "mq_open_max", CTLTYPE_INT }, \ - { "pagesize", CTLTYPE_INT }, \ - { "rtsig_max", CTLTYPE_INT }, \ - { "nsems_max", CTLTYPE_INT }, \ - { "sem_value_max", CTLTYPE_INT }, \ - { "sigqueue_max", CTLTYPE_INT }, \ - { "timer_max", CTLTYPE_INT }, \ -} - -#ifdef _KERNEL - -/* - * Declare some common oids. - */ -#ifdef __rtems__ -#define sysctl__children _bsd_sysctl__children -#endif /* __rtems__ */ -extern struct sysctl_oid_list sysctl__children; -SYSCTL_DECL(_kern); -SYSCTL_DECL(_kern_features); -SYSCTL_DECL(_kern_ipc); -SYSCTL_DECL(_kern_proc); -SYSCTL_DECL(_kern_sched); -SYSCTL_DECL(_kern_sched_stats); -SYSCTL_DECL(_sysctl); -SYSCTL_DECL(_vm); -SYSCTL_DECL(_vm_stats); -SYSCTL_DECL(_vm_stats_misc); -SYSCTL_DECL(_vfs); -SYSCTL_DECL(_net); -SYSCTL_DECL(_debug); -SYSCTL_DECL(_debug_sizeof); -SYSCTL_DECL(_dev); -SYSCTL_DECL(_hw); -SYSCTL_DECL(_hw_bus); -SYSCTL_DECL(_hw_bus_devices); -SYSCTL_DECL(_hw_bus_info); -SYSCTL_DECL(_machdep); -SYSCTL_DECL(_user); -SYSCTL_DECL(_compat); -SYSCTL_DECL(_regression); -SYSCTL_DECL(_security); -SYSCTL_DECL(_security_bsd); - -extern char machine[]; -extern char osrelease[]; -extern char ostype[]; -extern char kern_ident[]; - -/* Dynamic oid handling */ -struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, - struct sysctl_oid_list *parent, int nbr, const char *name, - int kind, void *arg1, int arg2, - int (*handler) (SYSCTL_HANDLER_ARGS), - const char *fmt, const char *descr); -void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); -int sysctl_move_oid(struct sysctl_oid *oidp, - struct sysctl_oid_list *parent); -int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); -int sysctl_ctx_init(struct sysctl_ctx_list *clist); -int sysctl_ctx_free(struct sysctl_ctx_list *clist); -struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, - struct sysctl_oid *oidp); -struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, - struct sysctl_oid *oidp); -int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, - struct sysctl_oid *oidp); - -int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, -#ifndef __rtems__ - size_t *oldlenp, void *new, size_t newlen, -#else /* __rtems__ */ - size_t *oldlenp, const void *newp, size_t newlen, -#endif /* __rtems__ */ - size_t *retval, int flags); -#ifndef __rtems__ -int kernel_sysctlbyname(struct thread *td, char *name, - void *old, size_t *oldlenp, void *new, size_t newlen, - size_t *retval, int flags); -int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, - size_t *oldlenp, int inkernel, void *new, size_t newlen, - size_t *retval, int flags); -#endif /* __rtems__ */ -int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, - int *nindx, struct sysctl_req *req); -void sysctl_lock(void); -void sysctl_unlock(void); -int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); - -#ifndef __rtems__ -#else /* !_KERNEL */ -#endif /* __rtems__ */ -#include - -__BEGIN_DECLS -int sysctl(int *, u_int, void *, size_t *, void *, size_t); -int sysctlbyname(const char *, void *, size_t *, void *, size_t); -int sysctlnametomib(const char *, int *, size_t *); -__END_DECLS -#endif /* _KERNEL */ - -#endif /* !_SYS_SYSCTL_HH_ */ diff --git a/freebsd/sys/syslimits.h b/freebsd/sys/syslimits.h deleted file mode 100644 index 936ffd88..00000000 --- a/freebsd/sys/syslimits.h +++ /dev/null @@ -1 +0,0 @@ -/* EMPTY */ diff --git a/freebsd/sys/syslog.h b/freebsd/sys/syslog.h deleted file mode 100644 index 11f7c8e6..00000000 --- a/freebsd/sys/syslog.h +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)syslog.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ - */ - -#ifndef _SYS_SYSLOG_HH_ -#define _SYS_SYSLOG_HH_ - -#define _PATH_LOG "/var/run/log" -#define _PATH_LOG_PRIV "/var/run/logpriv" -#define _PATH_OLDLOG "/dev/log" /* backward compatibility */ - -/* - * priorities/facilities are encoded into a single 32-bit quantity, where the - * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility - * (0-big number). Both the priorities and the facilities map roughly - * one-to-one to strings in the syslogd(8) source code. This mapping is - * included in this file. - * - * priorities (these are ordered) - */ -#define LOG_EMERG 0 /* system is unusable */ -#define LOG_ALERT 1 /* action must be taken immediately */ -#define LOG_CRIT 2 /* critical conditions */ -#define LOG_ERR 3 /* error conditions */ -#define LOG_WARNING 4 /* warning conditions */ -#define LOG_NOTICE 5 /* normal but significant condition */ -#define LOG_INFO 6 /* informational */ -#define LOG_DEBUG 7 /* debug-level messages */ - -#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ - /* extract priority */ -#define LOG_PRI(p) ((p) & LOG_PRIMASK) -#define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) - -#ifdef SYSLOG_NAMES -#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ - /* mark "facility" */ -#define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0) -typedef struct _code { - const char *c_name; - int c_val; -} CODE; - -CODE prioritynames[] = { - { "alert", LOG_ALERT, }, - { "crit", LOG_CRIT, }, - { "debug", LOG_DEBUG, }, - { "emerg", LOG_EMERG, }, - { "err", LOG_ERR, }, - { "error", LOG_ERR, }, /* DEPRECATED */ - { "info", LOG_INFO, }, - { "none", INTERNAL_NOPRI, }, /* INTERNAL */ - { "notice", LOG_NOTICE, }, - { "panic", LOG_EMERG, }, /* DEPRECATED */ - { "warn", LOG_WARNING, }, /* DEPRECATED */ - { "warning", LOG_WARNING, }, - { NULL, -1, } -}; -#endif - -/* facility codes */ -#define LOG_KERN (0<<3) /* kernel messages */ -#define LOG_USER (1<<3) /* random user-level messages */ -#define LOG_MAIL (2<<3) /* mail system */ -#define LOG_DAEMON (3<<3) /* system daemons */ -#define LOG_AUTH (4<<3) /* authorization messages */ -#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ -#define LOG_LPR (6<<3) /* line printer subsystem */ -#define LOG_NEWS (7<<3) /* network news subsystem */ -#define LOG_UUCP (8<<3) /* UUCP subsystem */ -#define LOG_CRON (9<<3) /* clock daemon */ -#define LOG_AUTHPRIV (10<<3) /* authorization messages (private) */ - /* Facility #10 clashes in DEC UNIX, where */ - /* it's defined as LOG_MEGASAFE for AdvFS */ - /* event logging. */ -#define LOG_FTP (11<<3) /* ftp daemon */ -#define LOG_NTP (12<<3) /* NTP subsystem */ -#define LOG_SECURITY (13<<3) /* security subsystems (firewalling, etc.) */ -#define LOG_CONSOLE (14<<3) /* /dev/console output */ - - /* other codes through 15 reserved for system use */ -#define LOG_LOCAL0 (16<<3) /* reserved for local use */ -#define LOG_LOCAL1 (17<<3) /* reserved for local use */ -#define LOG_LOCAL2 (18<<3) /* reserved for local use */ -#define LOG_LOCAL3 (19<<3) /* reserved for local use */ -#define LOG_LOCAL4 (20<<3) /* reserved for local use */ -#define LOG_LOCAL5 (21<<3) /* reserved for local use */ -#define LOG_LOCAL6 (22<<3) /* reserved for local use */ -#define LOG_LOCAL7 (23<<3) /* reserved for local use */ - -#define LOG_NFACILITIES 24 /* current number of facilities */ -#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ - /* facility of pri */ -#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) - -#ifdef SYSLOG_NAMES -CODE facilitynames[] = { - { "auth", LOG_AUTH, }, - { "authpriv", LOG_AUTHPRIV, }, - { "console", LOG_CONSOLE, }, - { "cron", LOG_CRON, }, - { "daemon", LOG_DAEMON, }, - { "ftp", LOG_FTP, }, - { "kern", LOG_KERN, }, - { "lpr", LOG_LPR, }, - { "mail", LOG_MAIL, }, - { "mark", INTERNAL_MARK, }, /* INTERNAL */ - { "news", LOG_NEWS, }, - { "ntp", LOG_NTP, }, - { "security", LOG_SECURITY, }, - { "syslog", LOG_SYSLOG, }, - { "user", LOG_USER, }, - { "uucp", LOG_UUCP, }, - { "local0", LOG_LOCAL0, }, - { "local1", LOG_LOCAL1, }, - { "local2", LOG_LOCAL2, }, - { "local3", LOG_LOCAL3, }, - { "local4", LOG_LOCAL4, }, - { "local5", LOG_LOCAL5, }, - { "local6", LOG_LOCAL6, }, - { "local7", LOG_LOCAL7, }, - { NULL, -1, } -}; -#endif - -#ifdef _KERNEL -#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ -#endif - -/* - * arguments to setlogmask. - */ -#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ -#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ - -/* - * Option flags for openlog. - * - * LOG_ODELAY no longer does anything. - * LOG_NDELAY is the inverse of what it used to be. - */ -#define LOG_PID 0x01 /* log the pid with each message */ -#define LOG_CONS 0x02 /* log on the console if errors in sending */ -#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ -#define LOG_NDELAY 0x08 /* don't delay open */ -#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ -#define LOG_PERROR 0x20 /* log to stderr as well */ - -#ifdef _KERNEL - -#else /* not _KERNEL */ - -/* - * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two - * places ( and ), so if we include one - * of them here we may collide with the utility's includes. It's unreasonable - * for utilities to have to include one of them to include syslog.h, so we get - * __va_list from and use it. - */ -#include -#include - -__BEGIN_DECLS -void closelog(void); -void openlog(const char *, int, int); -int setlogmask(int); -void syslog(int, const char *, ...) __printflike(2, 3); -#if __BSD_VISIBLE -void vsyslog(int, const char *, __va_list) __printflike(2, 0); -#endif -__END_DECLS - -#endif /* !_KERNEL */ - -#endif diff --git a/freebsd/sys/uio.h b/freebsd/sys/uio.h deleted file mode 100644 index 57b4153b..00000000 --- a/freebsd/sys/uio.h +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)uio.h 8.5 (Berkeley) 2/22/94 - * $FreeBSD$ - */ - -#ifndef _SYS_UIO_HH_ -#define _SYS_UIO_HH_ - -#include -#include -#include - -#ifndef _SSIZE_T_DECLARED -typedef __ssize_t ssize_t; -#define _SSIZE_T_DECLARED -#endif - -#ifndef _OFF_T_DECLARED -typedef __off_t off_t; -#define _OFF_T_DECLARED -#endif - -#if __BSD_VISIBLE -enum uio_rw { UIO_READ, UIO_WRITE }; - -/* Segment flag values. */ -enum uio_seg { - UIO_USERSPACE, /* from user data space */ - UIO_SYSSPACE, /* from system space */ - UIO_NOCOPY /* don't copy, already in object */ -}; -#endif - -#ifdef _KERNEL - -struct uio { - struct iovec *uio_iov; /* scatter/gather list */ - int uio_iovcnt; /* length of scatter/gather list */ - off_t uio_offset; /* offset in target object */ - ssize_t uio_resid; /* remaining bytes to process */ - enum uio_seg uio_segflg; /* address space */ - enum uio_rw uio_rw; /* operation */ - struct thread *uio_td; /* owner */ -}; - -/* - * Limits - * - * N.B.: UIO_MAXIOV must be no less than IOV_MAX from - * which in turn must be no less than _XOPEN_IOV_MAX from . If - * we ever make this tunable (probably pointless), then IOV_MAX should be - * removed from and applications would be expected to use - * sysconf(3) to find out the correct value, or else assume the worst - * (_XOPEN_IOV_MAX). Perhaps UIO_MAXIOV should be simply defined as - * IOV_MAX. - */ -#define UIO_MAXIOV 1024 /* max 1K of iov's */ - -struct vm_object; -struct vm_page; - -struct uio *cloneuio(struct uio *uiop); -int copyinfrom(const void * __restrict src, void * __restrict dst, - size_t len, int seg); -int copyiniov(struct iovec *iovp, u_int iovcnt, struct iovec **iov, - int error); -int copyinstrfrom(const void * __restrict src, void * __restrict dst, - size_t len, size_t * __restrict copied, int seg); -int copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop); -void uio_yield(void); -int uiomove(void *cp, int n, struct uio *uio); -int uiomove_frombuf(void *buf, int buflen, struct uio *uio); -int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, - struct uio *uio); -int uiomoveco(void *cp, int n, struct uio *uio, int disposable); - -#else /* !_KERNEL */ - -__BEGIN_DECLS -ssize_t readv(int, const struct iovec *, int); -ssize_t writev(int, const struct iovec *, int); -#if __BSD_VISIBLE -ssize_t preadv(int, const struct iovec *, int, off_t); -ssize_t pwritev(int, const struct iovec *, int, off_t); -#endif -__END_DECLS - -#endif /* _KERNEL */ - -#endif /* !_SYS_UIO_HH_ */ diff --git a/freebsd/sys/v850/include/machine/in_cksum.h b/freebsd/sys/v850/include/machine/in_cksum.h new file mode 100644 index 00000000..37d88e2e --- /dev/null +++ b/freebsd/sys/v850/include/machine/in_cksum.h @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg + * $FreeBSD$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +#define in_cksum(m, len) in_cksum_skip(m, len, 0) + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#ifdef __CC_SUPPORTS___INLINE + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#else + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#ifdef _KERNEL +u_int in_cksum_hdr(const struct ip *ip); +u_short in_addword(u_short sum, u_short b); +u_short in_pseudo(u_int sum, u_int b, u_int c); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/freebsd/sys/v850/include/machine/legacyvar.h b/freebsd/sys/v850/include/machine/legacyvar.h new file mode 100644 index 00000000..0b0fa433 --- /dev/null +++ b/freebsd/sys/v850/include/machine/legacyvar.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2000 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_LEGACYVAR_H_ +#define _MACHINE_LEGACYVAR_H_ + +enum legacy_device_ivars { + LEGACY_IVAR_PCIDOMAIN, + LEGACY_IVAR_PCIBUS +}; + +#define LEGACY_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(legacy, var, LEGACY, ivar, type) + +LEGACY_ACCESSOR(pcidomain, PCIDOMAIN, uint32_t) +LEGACY_ACCESSOR(pcibus, PCIBUS, uint32_t) + +#undef LEGACY_ACCESSOR + +int legacy_pcib_maxslots(device_t dev); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes); +int legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes); +int legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value); +struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, u_int flags); + +#endif /* !_MACHINE_LEGACYVAR_H_ */ diff --git a/freebsd/sys/v850/include/machine/pci_cfgreg.h b/freebsd/sys/v850/include/machine/pci_cfgreg.h new file mode 100644 index 00000000..bc72418d --- /dev/null +++ b/freebsd/sys/v850/include/machine/pci_cfgreg.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#define CONF1_ADDR_PORT 0x0cf8 +#define CONF1_DATA_PORT 0x0cfc + +#define CONF1_ENABLE 0x80000000ul +#define CONF1_ENABLE_CHK 0x80000000ul +#define CONF1_ENABLE_MSK 0x7f000000ul +#define CONF1_ENABLE_CHK1 0xff000001ul +#define CONF1_ENABLE_MSK1 0x80000001ul +#define CONF1_ENABLE_RES1 0x80000000ul + +#define CONF2_ENABLE_PORT 0x0cf8 +#define CONF2_FORWARD_PORT 0x0cfa + +#define CONF2_ENABLE_CHK 0x0e +#define CONF2_ENABLE_RES 0x0e + +int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus); +int pci_cfgregopen(void); +u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes); +void pci_pir_open(void); +int pci_pir_probe(int bus, int require_parse); +int pci_pir_route_interrupt(int bus, int device, int func, int pin); diff --git a/freebsd/sys/v850/pci/pci_bus.c b/freebsd/sys/v850/pci/pci_bus.c new file mode 100644 index 00000000..6627db98 --- /dev/null +++ b/freebsd/sys/v850/pci/pci_bus.c @@ -0,0 +1,729 @@ +#include + +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef CPU_ELAN +#include +#endif +#include +#include +#include + +#include + +#ifndef __rtems__ +static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, + int pin); +#else /* __rtems__ */ +int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin); +#endif /* __rtems__ */ + + +int +legacy_pcib_maxslots(device_t dev) +{ + return 31; +} + +/* read configuration space register */ + +#ifdef __rtems__ +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#else +u_int32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) +#endif +{ + return(pci_cfgregread(bus, slot, func, reg, bytes)); +} + +/* write configuration space register */ + +void +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, u_int32_t data, int bytes) +{ + pci_cfgregwrite(bus, slot, func, reg, data, bytes); +} + +/* Pass MSI requests up to the nexus. */ + +static int +legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, + int *irqs) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, + irqs)); +} + +static int +legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); +} + +static int +legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + device_t bus; + + bus = device_get_parent(pcib); + return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data)); +} + +static const char * +legacy_pcib_is_host_bridge(int bus, int slot, int func, + uint32_t id, uint8_t class, uint8_t subclass, + uint8_t *busnum) +{ + const char *s = NULL; + static uint8_t pxb[4]; /* hack for 450nx */ + + *busnum = 0; + + switch (id) { + case 0x12258086: + s = "Intel 824?? host to PCI bridge"; + /* XXX This is a guess */ + /* *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x41, 1); */ + *busnum = bus; + break; + case 0x71208086: + s = "Intel 82810 (i810 GMCH) Host To Hub bridge"; + break; + case 0x71228086: + s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge"; + break; + case 0x71248086: + s = "Intel 82810E (i810E GMCH) Host To Hub bridge"; + break; + case 0x11308086: + s = "Intel 82815 (i815 GMCH) Host To Hub bridge"; + break; + case 0x71808086: + s = "Intel 82443LX (440 LX) host to PCI bridge"; + break; + case 0x71908086: + s = "Intel 82443BX (440 BX) host to PCI bridge"; + break; + case 0x71928086: + s = "Intel 82443BX host to PCI bridge (AGP disabled)"; + break; + case 0x71948086: + s = "Intel 82443MX host to PCI bridge"; + break; + case 0x71a08086: + s = "Intel 82443GX host to PCI bridge"; + break; + case 0x71a18086: + s = "Intel 82443GX host to AGP bridge"; + break; + case 0x71a28086: + s = "Intel 82443GX host to PCI bridge (AGP disabled)"; + break; + case 0x84c48086: + s = "Intel 82454KX/GX (Orion) host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x4a, 1); + break; + case 0x84ca8086: + /* + * For the 450nx chipset, there is a whole bundle of + * things pretending to be host bridges. The MIOC will + * be seen first and isn't really a pci bridge (the + * actual busses are attached to the PXB's). We need to + * read the registers of the MIOC to figure out the + * bus numbers for the PXB channels. + * + * Since the MIOC doesn't have a pci bus attached, we + * pretend it wasn't there. + */ + pxb[0] = legacy_pcib_read_config(0, bus, slot, func, + 0xd0, 1); /* BUSNO[0] */ + pxb[1] = legacy_pcib_read_config(0, bus, slot, func, + 0xd1, 1) + 1; /* SUBA[0]+1 */ + pxb[2] = legacy_pcib_read_config(0, bus, slot, func, + 0xd3, 1); /* BUSNO[1] */ + pxb[3] = legacy_pcib_read_config(0, bus, slot, func, + 0xd4, 1) + 1; /* SUBA[1]+1 */ + return NULL; + case 0x84cb8086: + switch (slot) { + case 0x12: + s = "Intel 82454NX PXB#0, Bus#A"; + *busnum = pxb[0]; + break; + case 0x13: + s = "Intel 82454NX PXB#0, Bus#B"; + *busnum = pxb[1]; + break; + case 0x14: + s = "Intel 82454NX PXB#1, Bus#A"; + *busnum = pxb[2]; + break; + case 0x15: + s = "Intel 82454NX PXB#1, Bus#B"; + *busnum = pxb[3]; + break; + } + break; + case 0x1A308086: + s = "Intel 82845 Host to PCI bridge"; + break; + + /* AMD -- vendor 0x1022 */ + case 0x30001022: + s = "AMD Elan SC520 host to PCI bridge"; +#ifdef CPU_ELAN + init_AMD_Elan_sc520(); +#else + printf( +"*** WARNING: missing CPU_ELAN -- timekeeping may be wrong\n"); +#endif + break; + case 0x70061022: + s = "AMD-751 host to PCI bridge"; + break; + case 0x700e1022: + s = "AMD-761 host to PCI bridge"; + break; + + /* SiS -- vendor 0x1039 */ + case 0x04961039: + s = "SiS 85c496"; + break; + case 0x04061039: + s = "SiS 85c501"; + break; + case 0x06011039: + s = "SiS 85c601"; + break; + case 0x55911039: + s = "SiS 5591 host to PCI bridge"; + break; + case 0x00011039: + s = "SiS 5591 host to AGP bridge"; + break; + + /* VLSI -- vendor 0x1004 */ + case 0x00051004: + s = "VLSI 82C592 Host to PCI bridge"; + break; + + /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */ + /* totally. Please let me know if anything wrong. -F */ + /* XXX need info on the MVP3 -- any takers? */ + case 0x05981106: + s = "VIA 82C598MVP (Apollo MVP3) host bridge"; + break; + + /* AcerLabs -- vendor 0x10b9 */ + /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */ + /* id is '10b9" but the register always shows "10b9". -Foxfair */ + case 0x154110b9: + s = "AcerLabs M1541 (Aladdin-V) PCI host bridge"; + break; + + /* OPTi -- vendor 0x1045 */ + case 0xc7011045: + s = "OPTi 82C700 host to PCI bridge"; + break; + case 0xc8221045: + s = "OPTi 82C822 host to PCI Bridge"; + break; + + /* ServerWorks -- vendor 0x1166 */ + case 0x00051166: + s = "ServerWorks NB6536 2.0HE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00061166: + /* FALLTHROUGH */ + case 0x00081166: + /* FALLTHROUGH */ + case 0x02011166: + /* FALLTHROUGH */ + case 0x010f1014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00091166: + s = "ServerWorks NB6635 3.0LE host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00101166: + s = "ServerWorks CIOB30 host to PCI bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + case 0x00111166: + /* FALLTHROUGH */ + case 0x03021014: /* IBM re-badged ServerWorks chipset */ + s = "ServerWorks CMIC-HE host to PCI-X bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* XXX unknown chipset, but working */ + case 0x00171166: + /* FALLTHROUGH */ + case 0x01011166: + case 0x01101166: + case 0x02251166: + s = "ServerWorks host to PCI bridge(unknown chipset)"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0x44, 1); + break; + + /* Compaq/HP -- vendor 0x0e11 */ + case 0x60100e11: + s = "Compaq/HP Model 6010 HotPlug PCI Bridge"; + *busnum = legacy_pcib_read_config(0, bus, slot, func, 0xc8, 1); + break; + + /* Integrated Micro Solutions -- vendor 0x10e0 */ + case 0x884910e0: + s = "Integrated Micro Solutions VL Bridge"; + break; + + default: + if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST) + s = "Host to PCI bridge"; + break; + } + + return s; +} + +/* + * Scan the first pci bus for host-pci bridges and add pcib instances + * to the nexus for each bridge. + */ +static void +legacy_pcib_identify(driver_t *driver, device_t parent) +{ + int bus, slot, func; + u_int8_t hdrtype; + int found = 0; + int pcifunchigh; + int found824xx = 0; + int found_orion = 0; + device_t child; + devclass_t pci_devclass; + + if (pci_cfgregopen() == 0) + return; + /* + * Check to see if we haven't already had a PCI bus added + * via some other means. If we have, bail since otherwise + * we're going to end up duplicating it. + */ + if ((pci_devclass = devclass_find("pci")) && + devclass_get_device(pci_devclass, 0)) + return; + + + bus = 0; + retry: + for (slot = 0; slot <= PCI_SLOTMAX; slot++) { + func = 0; + hdrtype = legacy_pcib_read_config(0, bus, slot, func, + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; + if ((hdrtype & PCIM_MFDEV) && + (!found_orion || hdrtype != 0xff)) + pcifunchigh = PCI_FUNCMAX; + else + pcifunchigh = 0; + for (func = 0; func <= pcifunchigh; func++) { + /* + * Read the IDs and class from the device. + */ + u_int32_t id; + u_int8_t class, subclass, busnum; + const char *s; + device_t *devs; + int ndevs, i; + + id = legacy_pcib_read_config(0, bus, slot, func, + PCIR_DEVVENDOR, 4); + if (id == -1) + continue; + class = legacy_pcib_read_config(0, bus, slot, func, + PCIR_CLASS, 1); + subclass = legacy_pcib_read_config(0, bus, slot, func, + PCIR_SUBCLASS, 1); + + s = legacy_pcib_is_host_bridge(bus, slot, func, + id, class, subclass, + &busnum); + if (s == NULL) + continue; + + /* + * Check to see if the physical bus has already + * been seen. Eg: hybrid 32 and 64 bit host + * bridges to the same logical bus. + */ + if (device_get_children(parent, &devs, &ndevs) == 0) { + for (i = 0; s != NULL && i < ndevs; i++) { + if (strcmp(device_get_name(devs[i]), + "pcib") != 0) + continue; + if (legacy_get_pcibus(devs[i]) == busnum) + s = NULL; + } + free(devs, M_TEMP); + } + + if (s == NULL) + continue; + /* + * Add at priority 100 to make sure we + * go after any motherboard resources + */ + child = BUS_ADD_CHILD(parent, 100, + "pcib", busnum); + device_set_desc(child, s); + legacy_set_pcibus(child, busnum); + + found = 1; + if (id == 0x12258086) + found824xx = 1; + if (id == 0x84c48086) + found_orion = 1; + } + } + if (found824xx && bus == 0) { + bus++; + goto retry; + } + + /* + * Make sure we add at least one bridge since some old + * hardware doesn't actually have a host-pci bridge device. + * Note that pci_cfgregopen() thinks we have PCI devices.. + */ + if (!found) { + if (bootverbose) + printf( + "legacy_pcib_identify: no bridge found, adding pcib0 anyway\n"); + child = BUS_ADD_CHILD(parent, 100, "pcib", 0); + legacy_set_pcibus(child, 0); + } +} + +static int +legacy_pcib_probe(device_t dev) +{ + + if (pci_cfgregopen() == 0) + return ENXIO; + return -100; +} + +static int +legacy_pcib_attach(device_t dev) +{ + device_t pir; + int bus; + + /* + * Look for a PCI BIOS interrupt routing table as that will be + * our method of routing interrupts if we have one. + */ + bus = pcib_get_bus(dev); +#ifndef __rtems__ + if (pci_pir_probe(bus, 0)) { + pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0); + if (pir != NULL) + device_probe_and_attach(pir); + } +#else /* __rtems__ */ +#endif /* __rtems__ */ + device_add_child(dev, "pci", bus); + return bus_generic_attach(dev); +} + +int +legacy_pcib_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return 0; + case PCIB_IVAR_BUS: + *result = legacy_get_pcibus(dev); + return 0; + } + return ENOENT; +} + +int +legacy_pcib_write_ivar(device_t dev, device_t child, int which, + uintptr_t value) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + return EINVAL; + case PCIB_IVAR_BUS: + legacy_set_pcibus(dev, value); + return 0; + } + return ENOENT; +} + +SYSCTL_DECL(_hw_pci); + +static unsigned long legacy_host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, + &legacy_host_mem_start, 0x80000000, + "Limit the host bridge memory to being above this address. Must be\n\ +set at boot via a tunable."); + +struct resource * +legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + /* + * If no memory preference is given, use upper 32MB slot most + * bioses use for their memory window. Typically other bridges + * before us get in the way to assert their preferences on memory. + * Hardcoding like this sucks, so a more MD/MI way needs to be + * found to do it. This is typically only used on older laptops + * that don't have pci busses behind pci bridge, so assuming > 32MB + * is liekly OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ + if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + start = legacy_host_mem_start; + if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + start = 0x1000; + return (bus_generic_alloc_resource(dev, child, type, rid, start, end, + count, flags)); +} + +static device_method_t legacy_pcib_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, legacy_pcib_identify), + DEVMETHOD(device_probe, legacy_pcib_probe), + DEVMETHOD(device_attach, legacy_pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots), + DEVMETHOD(pcib_read_config, legacy_pcib_read_config), + DEVMETHOD(pcib_write_config, legacy_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi), + + { 0, 0 } +}; + +static devclass_t hostb_devclass; + +DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1); +DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0); + + +#ifndef __rtems__ +/* + * Install placeholder to claim the resources owned by the + * PCI bus interface. This could be used to extract the + * config space registers in the extreme case where the PnP + * ID is available and the PCI BIOS isn't, but for now we just + * eat the PnP ID and do nothing else. + * + * XXX we should silence this probe, as it will generally confuse + * people. + */ +static struct isa_pnp_id pcibus_pnp_ids[] = { + { 0x030ad041 /* PNP0A03 */, "PCI Bus" }, + { 0x080ad041 /* PNP0A08 */, "PCIe Bus" }, + { 0 } +}; + +static int +pcibus_pnp_probe(device_t dev) +{ + int result; + + if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0) + device_quiet(dev); + return(result); +} + +static int +pcibus_pnp_attach(device_t dev) +{ + return(0); +} + +static device_method_t pcibus_pnp_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibus_pnp_probe), + DEVMETHOD(device_attach, pcibus_pnp_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + { 0, 0 } +}; + +static devclass_t pcibus_pnp_devclass; + +DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1); +DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0); + + +/* + * Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges + * that appear in the PCIBIOS Interrupt Routing Table to use the routing + * table for interrupt routing when possible. + */ +static int pcibios_pcib_probe(device_t bus); + +static device_method_t pcibios_pcib_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcibios_pcib_probe), + DEVMETHOD(device_attach, pcib_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, pcib_read_ivar), + DEVMETHOD(bus_write_ivar, pcib_write_ivar), + DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, pcib_maxslots), + DEVMETHOD(pcib_read_config, pcib_read_config), + DEVMETHOD(pcib_write_config, pcib_write_config), + DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt), + DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), + DEVMETHOD(pcib_release_msi, pcib_release_msi), + DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), + DEVMETHOD(pcib_release_msix, pcib_release_msix), + DEVMETHOD(pcib_map_msi, pcib_map_msi), + + {0, 0} +}; + +static devclass_t pcib_devclass; + +DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods, + sizeof(struct pcib_softc)); +DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0); + +static int +pcibios_pcib_probe(device_t dev) +{ + int bus; + + if ((pci_get_class(dev) != PCIC_BRIDGE) || + (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) + return (ENXIO); + bus = pci_read_config(dev, PCIR_SECBUS_1, 1); + if (bus == 0) + return (ENXIO); + if (!pci_pir_probe(bus, 1)) + return (ENXIO); + device_set_desc(dev, "PCIBIOS PCI-PCI bridge"); + return (-2000); +} + +static int +pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin) +{ + return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev), + pci_get_function(dev), pin)); +} +#endif /* __rtems__ */ diff --git a/freebsd/sys/v850/v850/in_cksum.c b/freebsd/sys/v850/v850/in_cksum.c new file mode 100644 index 00000000..c6f7b568 --- /dev/null +++ b/freebsd/sys/v850/v850/in_cksum.c @@ -0,0 +1,255 @@ +#include + +/*- + * Copyright (c) 1988, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1996 + * Matt Thomas + * + * 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +/* + * Checksum routine for Internet Protocol family headers + * (Portable Alpha version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) +#define REDUCE32 \ + { \ + q_util.q = sum; \ + sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + } +#define REDUCE16 \ + { \ + q_util.q = sum; \ + l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \ + sum = l_util.s[0] + l_util.s[1]; \ + ADDCARRY(sum); \ + } + +static const u_int32_t in_masks[] = { +#if _BYTE_ORDER == _LITTLE_ENDIAN + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ + 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ + 0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */ + 0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */ +#else + /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ + 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */ + 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */ + 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */ + 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */ +#endif +}; + +union l_util { + u_int16_t s[2]; + u_int32_t l; +}; +union q_util { + u_int16_t s[4]; + u_int32_t l[2]; + u_int64_t q; +}; + +static u_int64_t +in_cksumdata(const void *buf, int len) +{ + const u_int32_t *lw = (const u_int32_t *) buf; + u_int64_t sum = 0; + u_int64_t prefilled; + int offset; + union q_util q_util; + + if ((3 & (long) lw) == 0 && len == 20) { + sum = (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3] + lw[4]; + REDUCE32; + return sum; + } + + if ((offset = 3 & (long) lw) != 0) { + const u_int32_t *masks = in_masks + (offset << 2); + lw = (u_int32_t *) (((long) lw) - offset); + sum = *lw++ & masks[len >= 3 ? 3 : len]; + len -= 4 - offset; + if (len <= 0) { + REDUCE32; + return sum; + } + } +#if 0 + /* + * Force to cache line boundary. + */ + offset = 32 - (0x1f & (long) lw); + if (offset < 32 && len > offset) { + len -= offset; + if (4 & offset) { + sum += (u_int64_t) lw[0]; + lw += 1; + } + if (8 & offset) { + sum += (u_int64_t) lw[0] + lw[1]; + lw += 2; + } + if (16 & offset) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + } +#endif + /* + * access prefilling to start load of next cache line. + * then add current cache line + * save result of prefilling for loop iteration. + */ + prefilled = lw[0]; + while ((len -= 32) >= 4) { + u_int64_t prefilling = lw[8]; + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + prefilled = prefilling; + } + if (len >= 0) { + sum += prefilled + lw[1] + lw[2] + lw[3] + + lw[4] + lw[5] + lw[6] + lw[7]; + lw += 8; + } else { + len += 32; + } + while ((len -= 16) >= 0) { + sum += (u_int64_t) lw[0] + lw[1] + lw[2] + lw[3]; + lw += 4; + } + len += 16; + while ((len -= 4) >= 0) { + sum += (u_int64_t) *lw++; + } + len += 4; + if (len > 0) + sum += (u_int64_t) (in_masks[len] & *lw); + REDUCE32; + return sum; +} + +u_short +in_addword(u_short a, u_short b) +{ + u_int64_t sum = a + b; + + ADDCARRY(sum); + return (sum); +} + +u_short +#ifdef __rtems__ +/* Prototype does not match in FreeBSD code */ +in_pseudo(u_int a, u_int b, u_int c) +#else +in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c) +#endif +{ + u_int64_t sum; + union q_util q_util; + union l_util l_util; + + sum = (u_int64_t) a + b + c; + REDUCE16; + return (sum); +} + +u_short +in_cksum_skip(struct mbuf *m, int len, int skip) +{ + u_int64_t sum = 0; + int mlen = 0; + int clen = 0; + caddr_t addr; + union q_util q_util; + union l_util l_util; + + len -= skip; + for (; skip && m; m = m->m_next) { + if (m->m_len > skip) { + mlen = m->m_len - skip; + addr = mtod(m, caddr_t) + skip; + goto skip_start; + } else { + skip -= m->m_len; + } + } + + for (; m && len; m = m->m_next) { + if (m->m_len == 0) + continue; + mlen = m->m_len; + addr = mtod(m, caddr_t); +skip_start: + if (len < mlen) + mlen = len; + + if ((clen ^ (uintptr_t) addr) & 1) + sum += in_cksumdata(addr, mlen) << 8; + else + sum += in_cksumdata(addr, mlen); + + clen += mlen; + len -= mlen; + } + REDUCE16; + return (~sum & 0xffff); +} + +u_int in_cksum_hdr(const struct ip *ip) +{ + u_int64_t sum = in_cksumdata(ip, sizeof(struct ip)); + union q_util q_util; + union l_util l_util; + REDUCE16; + return (~sum & 0xffff); +} diff --git a/freebsd/sys/v850/v850/legacy.c b/freebsd/sys/v850/v850/legacy.c new file mode 100644 index 00000000..2547990c --- /dev/null +++ b/freebsd/sys/v850/v850/legacy.c @@ -0,0 +1,347 @@ +#include + +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * This code implements a system driver for legacy systems that do not + * support ACPI or when ACPI support is not present in the kernel. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __rtems__ +#include +#endif /* __rtems__ */ +#ifdef DEV_MCA +#include +#endif + +#include +#include + +static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device"); +struct legacy_device { + int lg_pcibus; +}; + +#define DEVTOAT(dev) ((struct legacy_device *)device_get_ivars(dev)) + +static int legacy_probe(device_t); +static int legacy_attach(device_t); +static int legacy_print_child(device_t, device_t); +static device_t legacy_add_child(device_t bus, u_int order, const char *name, + int unit); +static int legacy_read_ivar(device_t, device_t, int, uintptr_t *); +static int legacy_write_ivar(device_t, device_t, int, uintptr_t); + +static device_method_t legacy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, legacy_probe), + DEVMETHOD(device_attach, legacy_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, legacy_print_child), + DEVMETHOD(bus_add_child, legacy_add_child), + DEVMETHOD(bus_read_ivar, legacy_read_ivar), + DEVMETHOD(bus_write_ivar, legacy_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t legacy_driver = { + "legacy", + legacy_methods, + 1, /* no softc */ +}; +static devclass_t legacy_devclass; + +DRIVER_MODULE(legacy, nexus, legacy_driver, legacy_devclass, 0, 0); + +static int +legacy_probe(device_t dev) +{ + + device_set_desc(dev, "legacy system"); + device_quiet(dev); + return (0); +} + +static int +legacy_attach(device_t dev) +{ + device_t child; + + /* + * Let our child drivers identify any child devices that they + * can find. Once that is done attach any devices that we + * found. + */ + bus_generic_probe(dev); + bus_generic_attach(dev); + +#ifndef PC98 + /* + * If we didn't see EISA or ISA on a pci bridge, create some + * connection points now so they show up "on motherboard". + */ + if (!devclass_get_device(devclass_find("eisa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "eisa", 0); + if (child == NULL) + panic("legacy_attach eisa"); + device_probe_and_attach(child); + } +#endif +#ifdef DEV_MCA + if (MCA_system && !devclass_get_device(devclass_find("mca"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "mca", 0); + if (child == 0) + panic("legacy_probe mca"); + device_probe_and_attach(child); + } +#endif + if (!devclass_get_device(devclass_find("isa"), 0)) { + child = BUS_ADD_CHILD(dev, 0, "isa", 0); + if (child == NULL) + panic("legacy_attach isa"); + device_probe_and_attach(child); + } + + return 0; +} + +static int +legacy_print_child(device_t bus, device_t child) +{ + struct legacy_device *atdev = DEVTOAT(child); + int retval = 0; + + retval += bus_print_child_header(bus, child); + if (atdev->lg_pcibus != -1) + retval += printf(" pcibus %d", atdev->lg_pcibus); + retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ + + return (retval); +} + +static device_t +legacy_add_child(device_t bus, u_int order, const char *name, int unit) +{ + device_t child; + struct legacy_device *atdev; + + atdev = malloc(sizeof(struct legacy_device), M_LEGACYDEV, + M_NOWAIT | M_ZERO); + if (atdev == NULL) + return(NULL); + atdev->lg_pcibus = -1; + + child = device_add_child_ordered(bus, order, name, unit); + if (child == NULL) + free(atdev, M_LEGACYDEV); + else + /* should we free this in legacy_child_detached? */ + device_set_ivars(child, atdev); + + return (child); +} + +static int +legacy_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + *result = 0; + break; + case LEGACY_IVAR_PCIBUS: + *result = atdev->lg_pcibus; + break; + default: + return ENOENT; + } + return 0; +} + + +static int +legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct legacy_device *atdev = DEVTOAT(child); + + switch (which) { + case LEGACY_IVAR_PCIDOMAIN: + return EINVAL; + case LEGACY_IVAR_PCIBUS: + atdev->lg_pcibus = value; + break; + default: + return ENOENT; + } + return 0; +} + +/* + * Legacy CPU attachment when ACPI is not available. Drivers like + * cpufreq(4) hang off this. + */ +static void cpu_identify(driver_t *driver, device_t parent); +static int cpu_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static device_t cpu_add_child(device_t bus, u_int order, const char *name, + int unit); +static struct resource_list *cpu_get_rlist(device_t dev, device_t child); + +struct cpu_device { + struct resource_list cd_rl; + struct pcpu *cd_pcpu; +}; + +static device_method_t cpu_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, cpu_identify), + DEVMETHOD(device_probe, bus_generic_probe), + DEVMETHOD(device_attach, bus_generic_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, cpu_add_child), + DEVMETHOD(bus_read_ivar, cpu_read_ivar), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_get_resource_list, cpu_get_rlist), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t cpu_driver = { + "cpu", + cpu_methods, + 1, /* no softc */ +}; +static devclass_t cpu_devclass; +DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0); + +static void +cpu_identify(driver_t *driver, device_t parent) +{ + device_t child; + int i; + + /* + * Attach a cpuX device for each CPU. We use an order of 150 + * so that these devices are attached after the Host-PCI + * bridges (which are added at order 100). + */ + for (i = 0; i <= mp_maxid; i++) + if (!CPU_ABSENT(i)) { + child = BUS_ADD_CHILD(parent, 150, "cpu", i); + if (child == NULL) + panic("legacy_attach cpu"); + } +} + +static device_t +cpu_add_child(device_t bus, u_int order, const char *name, int unit) +{ + struct cpu_device *cd; + device_t child; + struct pcpu *pc; + + if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) + return (NULL); + + resource_list_init(&cd->cd_rl); + pc = pcpu_find(device_get_unit(bus)); + cd->cd_pcpu = pc; + + child = device_add_child_ordered(bus, order, name, unit); + if (child != NULL) { + pc->pc_device = child; + device_set_ivars(child, cd); + } else + free(cd, M_DEVBUF); + return (child); +} + +static struct resource_list * +cpu_get_rlist(device_t dev, device_t child) +{ + struct cpu_device *cpdev; + + cpdev = device_get_ivars(child); + return (&cpdev->cd_rl); +} + +static int +cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) +{ + struct cpu_device *cpdev; + + if (index != CPU_IVAR_PCPU) + return (ENOENT); + cpdev = device_get_ivars(child); + *result = (uintptr_t)cpdev->cd_pcpu; + return (0); +} diff --git a/freebsd/sys/vm/uma.h b/freebsd/sys/vm/uma.h index b23ad453..62a0ca79 100644 --- a/freebsd/sys/vm/uma.h +++ b/freebsd/sys/vm/uma.h @@ -36,8 +36,8 @@ #ifndef VM_UMA_H #define VM_UMA_H -#include /* For NULL */ -#include /* For M_* */ +#include /* For NULL */ +#include /* For M_* */ /* User visible parameters */ #define UMA_SMALLEST_UNIT (PAGE_SIZE / 256) /* Smallest item allocated */ diff --git a/freebsd/sys/vm/uma_core.c b/freebsd/sys/vm/uma_core.c index a53fceb9..8d62d559 100644 --- a/freebsd/sys/vm/uma_core.c +++ b/freebsd/sys/vm/uma_core.c @@ -1,4 +1,4 @@ -#include +#include /*- * Copyright (c) 2002-2005, 2009 Jeffrey Roberson @@ -49,7 +49,7 @@ * - Investigate cache size adjustments */ -#include +#include __FBSDID("$FreeBSD$"); /* I should really use ktr.. */ @@ -59,45 +59,44 @@ __FBSDID("$FreeBSD$"); #define UMA_DEBUG_ALLOC_1 1 */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#ifndef __rtems__ -#include -#include -#include -#include -#include -#include -#else +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef __rtems__ void *rtems_page_alloc(int bytes); void *rtems_page_find( void *address ); void rtems_page_free( void *address ); #endif /* __rtems__ */ -#include -#include -#include +#include +#include +#include #ifndef __rtems__ -#include +#include -#include +#include #endif /* __rtems__ */ /* diff --git a/freebsd/sys/vm/vm.h b/freebsd/sys/vm/vm.h index 037ac838..941300a0 100644 --- a/freebsd/sys/vm/vm.h +++ b/freebsd/sys/vm/vm.h @@ -61,7 +61,7 @@ #ifndef VM_H #define VM_H -#include +#include typedef char vm_inherit_t; /* inheritance codes */ -- cgit v1.2.3