Commit Graph

3420 Commits

Author SHA1 Message Date
Tom Rhodes
a122cca953 These are changes to allow to use the Intel C/C++ compiler (lang/icc)
to build the kernel. It doesn't affect the operation if gcc.

Most of the changes are just adding __INTEL_COMPILER to #ifdef's, as
icc v8 may define __GNUC__ some parts may look strange but are
necessary.

Additional changes:
 - in_cksum.[ch]:
   * use a generic C version instead of the assembly version in the !gcc
     case (ASM code breaks with the optimizations icc does)
     -> no bad checksums with an icc compiled kernel
     Help from:		andre, grehan, das
     Stolen from: 	alpha version via ppc version
     The entire checksum code should IMHO be replaced with the DragonFly
     version (because it isn't guaranteed future revisions of gcc will
     include similar optimizations) as in:
        ---snip---
          Revision  Changes    Path
          1.12      +1 -0      src/sys/conf/files.i386
          1.4       +142 -558  src/sys/i386/i386/in_cksum.c
          1.5       +33 -69    src/sys/i386/include/in_cksum.h
          1.5       +2 -0      src/sys/netinet/igmp.c
          1.6       +0 -1      src/sys/netinet/in.h
          1.6       +2 -0      src/sys/netinet/ip_icmp.c

          1.4       +3 -4      src/contrib/ipfilter/ip_compat.h
          1.3       +1 -2      src/sbin/natd/icmp.c
          1.4       +0 -1      src/sbin/natd/natd.c
          1.48      +1 -0      src/sys/conf/files
          1.2       +0 -1      src/sys/conf/files.amd64
          1.13      +0 -1      src/sys/conf/files.i386
          1.5       +0 -1      src/sys/conf/files.pc98
          1.7       +1 -1      src/sys/contrib/ipfilter/netinet/fil.c
          1.10      +2 -3      src/sys/contrib/ipfilter/netinet/ip_compat.h
          1.10      +1 -1      src/sys/contrib/ipfilter/netinet/ip_fil.c
          1.7       +1 -1      src/sys/dev/netif/txp/if_txp.c
          1.7       +1 -1      src/sys/net/ip_mroute/ip_mroute.c
          1.7       +1 -2      src/sys/net/ipfw/ip_fw2.c
          1.6       +1 -2      src/sys/netinet/igmp.c
          1.4       +158 -116  src/sys/netinet/in_cksum.c
          1.6       +1 -1      src/sys/netinet/ip_gre.c
          1.7       +1 -2      src/sys/netinet/ip_icmp.c
          1.10      +1 -1      src/sys/netinet/ip_input.c
          1.10      +1 -2      src/sys/netinet/ip_output.c
          1.13      +1 -2      src/sys/netinet/tcp_input.c
          1.9       +1 -2      src/sys/netinet/tcp_output.c
          1.10      +1 -1      src/sys/netinet/tcp_subr.c
          1.10      +1 -1      src/sys/netinet/tcp_syncache.c
          1.9       +1 -2      src/sys/netinet/udp_usrreq.c

          1.5       +1 -2      src/sys/netinet6/ipsec.c
          1.5       +1 -2      src/sys/netproto/ipsec/ipsec.c
          1.5       +1 -1      src/sys/netproto/ipsec/ipsec_input.c
          1.4       +1 -2      src/sys/netproto/ipsec/ipsec_output.c

          and finally remove
            sys/i386/i386        in_cksum.c
            sys/i386/include     in_cksum.h
        ---snip---
 - endian.h:
   * DTRT in C++ mode
 - quad.h:
   * we don't use gcc v1 anymore, remove support for it
   Suggested by:	bde (long ago)
 - assym.h:
   * avoid zero-length arrays (remove dependency on a gcc specific
     feature)
     This change changes the contents of the object file, but as it's
     only used to generate some values for a header, and the generator
     knows how to handle this, there's no impact in the gcc case.
   Explained by:	bde
   Submitted by:	Marius Strobl <marius@alchemy.franken.de>
 - aicasm.c:
   * minor change to teach it about the way icc spells "-nostdinc"
   Not approved by:	gibbs (no reply to my mail)
 - bump __FreeBSD_version (lang/icc needs to know about the changes)

Incarnations of this patch survive gcc compiles since a loooong time,
I use it on my desktop. An icc compiled kernel works since Nov. 2003
(exceptions: snd_* if used as modules), it survives a build of the
entire ports collection with icc.

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by:	-arch
Submitted by:	netchild
2004-03-12 21:45:33 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
8e1f1df080 Device megapatch 3/6:
Add missing D_TTY flags to various drivers.

Complete asserts that dev_t's passed to ttyread(), ttywrite(),
ttypoll() and ttykqwrite() have (d_flags & D_TTY) and a struct tty
pointer.

Make ttyread(), ttywrite(), ttypoll() and ttykqwrite() the default
cdevsw methods for D_TTY drivers and remove the explicit initializations
in various drivers cdevsw structures.
2004-02-21 20:41:11 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Bruce Evans
1203f5be25 Fixed a misplaced ifdef that prevented npx.c building without "device isa"
ISA.  npx has few isa dependencies, but it does unconditional outb()'s to
the isa bus in the !SMP case, and it attaches to isa if "device isa" is
configured in order to support PNP-ISA.  The ifdef for the latter was
misplaced.

PR:		62595
2004-02-13 18:04:51 +00:00
Peter Pentchev
f7644f46f0 Fix a typo in kan's last commit: cnavaiable() -> cnavailable() 2004-02-05 10:02:20 +00:00
Alexander Kabaev
e99c09e2dc Eliminate global cons_unavailable flag and replace it by the status
bit maintained on a per-device basis. Single variable is inadequate
on machines running with multiple consoles enabled.
2004-02-05 01:56:43 +00:00
John Baldwin
7a9d7023a2 Revert the skipping of segment register reloads as it appears to actually
be a pessimization on non Pentium4 CPUs.  More importantly, it is buggy as
it can cause GPF's when using APM or vm86.
2004-02-03 22:00:42 +00:00
John Baldwin
5352136a25 Optimize the i386 interrupt entry code to not reload the segment registers
if they already contain the correct kernel selectors.

Reviewed by:	peter
Suggested by:	peter
2004-01-28 20:44:08 +00:00
Joerg Wunsch
d93dea685d Fix a long-standing bug that had been introduced in rev 1.24 with the
replacement of struct proc by struct thread.  This bug could cause a
NULL pointer dereferencation under certain circumstances (e. g. while
running /etc/rc.d/pcvt).
2004-01-07 10:12:59 +00:00
John Baldwin
c8d7ed0d05 - Use i8259A register defines from shared sys/dev/ic/i8259.h rather than
from the i386-specific icu.h.
- Replace PC98 magic numbers with equivalent register define values along
  with comments about PC-98 "quirks".
2004-01-06 19:07:08 +00:00
Warner Losh
6631471980 First part of the removal of drivers for hardware that isn't relevant
or whose drivers haven't even compiled for years.

The loran hardware was very unique, and only a few copies of it ever
existed.  It used the old COMPAT_ISA_DRIVER and when the author was
contacted, he indicated that he had no intention of ever updating this
driver and it was no longer relevant to the FreeBSD world and can be
removed without impact to anybody.

Approved by: phk
2003-12-07 03:51:19 +00:00
Warner Losh
b8b831f0ad Remove cx in its old location.
Approved by: re@ <scottl>
2003-12-03 23:07:37 +00:00
Bruce Evans
933a354fe5 Fixed breakage of the pci case of the cy driver by the new interrupt
code.  Both the driver and the new code were wrong.  Driver interrupt
handlers are supposed to take "void *vsc" arg, but some including all
COMPAT_ISA drivers and the pci part of the cy driver want an "int unit"
arg.  They got this using bogus casts of function pointers which should
have kept working despite their bogusness.  However, the new interrupt
code doesn't honor requests to pass an arg of ((void *)0), so things
are very broken if the arg is actually a representation of unit 0.

The fix is to use a normal "void *vsc" arg for the pci case and a
wrapper for the COMPAT_ISA case (of the cy driver).  This cleans up
new-busification of the pci case but takes the COMPAT_ISA case a little
further from new-bus.  The corresponding bug for the COMPAT_ISA case
has already been fixed similarly using a wrapper in compat_isa.c and
we need another wrapper just to undo that.

Fixed some directly related style bugs (mainly by removing compatibility
cruft).

cy.c:
Fixed an indirectly related old bug in cyattach_common().  A wrong status
was returned in the unlikely event that malloc() failed.

Approved by:	re (scottl)
2003-12-02 12:36:00 +00:00
John Baldwin
6006b8f4c6 Add a special check for a stray IRQ 7 or IRQ 15 to see if it is actually
a spurious interrupt from one of the 8259As.  If so, don't log it as a
stray IRQ, but just silently ignore it.

Approved by:	re (rwatson)
2003-11-19 15:40:23 +00:00
John Baldwin
8c770ed571 - Add counts to the ATPIC interrupt sources and point the ATPIC interrupt
source count pointers at them so that intr_execute_handlers() won't
  choke when it tries to handle an unregisterd ATPIC interrupt source.
- Install the low-level ATPIC interrupt handlers when we first program the
  ATPIC in atpic_startup() rather than at SI_SUB_INTR.  This is only
  necessary to work around buggy code that enables interrupts too early
  in the boot process (namely, the vm86 code).

Approved by:	re (rwatson)
2003-11-19 15:38:56 +00:00
Bruce Evans
095ab45bde Restored the call to schedsofttty() (now spelled swi_sched(...)) again.
Its restoration in rev.1.102 was mistranslated to the equivalent of
setsofttty() in rev.1.105.  This increased overheads by causing a
context switch to the SWI handler after almost every interrupt.  The
increase was approx. 50% on a Celeron 366 (from 23 usec to 34 usec
per interrupt).
2003-11-16 13:31:45 +00:00
Bruce Evans
416ab90e6b Localized the cy driver's locking. 2003-11-16 00:55:54 +00:00
John Baldwin
64bb257f0b Always install IDT entries for ATPIC interrupt sources. The APIC no
longer uses these interrupt vectors for its ISA interrupt pins, so these
entries will not be overwritten.  If we get a spurious interrupt from the
ATPIC when using the APIC, it will be treated as a stray interrupt instead
of causing a panic.
2003-11-14 21:02:49 +00:00
Peter Wemm
2edfe38b10 "opt_auto_eoi.h" is not used here anymore. See atpic.c. 2003-11-14 20:06:24 +00:00
John Baldwin
f082493f10 Replace magic numbers with macros for i8259A register constants. Still
need the ICW4 bits for PC98 though.
2003-11-14 19:13:06 +00:00
John Baldwin
be06bd496f - Bring in constants for 8259A registers from amd64 with some updated
comments from NetBSD's dev/ic/i8259A.h.  These bits really belong in
  a file of the same name as well, but this will do for now.
- Axe unused HWI_MASK.
2003-11-14 19:12:25 +00:00
Poul-Henning Kamp
daf9092bcd Don't disable the TSC with statclock_disable. 2003-11-13 10:02:12 +00:00
John Baldwin
bd9cd7e3f7 - Move manipulation of td_intr_nesting_level out of assembly interrupt
vector stubs and into the C functions they call.
- Move disabling and EOIing of interrupt sources out of PIC driver entry
  points and into intr_execute_handlers().  Intr_execute_handlers() only
  disables a source for an interrupt if it is a stray interrupt or has
  threaded handlers.  Sources with fast handlers no longer disable (mask)
  the source while executing the handlers.
- Move the setting of clkintr_pending into intr_execute_handlers() and set
  the variable for any interrupt source with a vector of 0.  (Should only
  be true for IRQ 0.)  This fixes clkintr_pending in the NO_MIXED_MODE
  case.
- Implement lapic_eoi() and use it to implement ioapic_eoi_source().
- Rename atpic_sched_ithd() to atpic_handle_intr() since it is used to
  handle all atpic interrupts and not just threaded ones.

Inspired by:	peter's changes to amd64 in p4 (1)
Requested by:	bde (2)
2003-11-12 18:13:57 +00:00
Seigo Tanimura
512824f8f7 - Implement selwakeuppri() which allows raising the priority of a
thread being waken up.  The thread waken up can run at a priority as
  high as after tsleep().

- Replace selwakeup()s with selwakeuppri()s and pass appropriate
  priorities.

- Add cv_broadcastpri() which raises the priority of the broadcast
  threads.  Used by selwakeuppri() if collision occurs.

Not objected in:	-arch, -current
2003-11-09 09:17:26 +00:00
John Baldwin
3de744b5d8 Use a wrapper around the driver interrupt handler. The wrapper accepts the
isa_device pointer as its argument and uses that to call the driver's
interrupt handler passing the unit number as its argument.  This should
fix COMPAT_OLDISA devices with a unit number of 0.

Reviewed by:	peter
Reported by:	bde
2003-11-04 19:04:54 +00:00
Yoshihiro Takahashi
dc5f261df8 Fix LINT 2003-11-04 14:02:13 +00:00
Yoshihiro Takahashi
0ca1bf3907 Fix to support pc98. 2003-11-04 13:13:04 +00:00
Yoshihiro Takahashi
95755cc99b Split pc98 support into pc98/pc98/nmi.c. 2003-11-04 13:01:41 +00:00
John Baldwin
892f579780 Remove remaining bits of old interrupt and APIC code. 2003-11-03 22:51:25 +00:00
John Baldwin
73adfd0ca0 Catch up to interrupt code changes. 2003-11-03 22:37:28 +00:00
John Baldwin
b9c72be725 - Export doreti as a global symbol.
- Don't include isa/vector.s.  Each PIC driver's entry points now live in
  their own standalone files.
2003-11-03 22:08:52 +00:00
John Baldwin
6f92bdd0c1 New APIC support code:
- The apic interrupt entry points have been rewritten so that each entry
  point can serve 32 different vectors.  When the entry is executed, it
  uses one of the 32-bit ISR registers to determine which vector in its
  assigned range was triggered.  Thus, the apic code can support 159
  different interrupt vectors with only 5 entry points.
- We now always to disable the local APIC to work around an errata in
  certain PPros and then re-enable it again if we decide to use the APICs
  to route interrupts.
- We no longer map IO APICs or local APICs using special page table
  entries.  Instead, we just use pmap_mapdev().  We also no longer
  export the virtual address of the local APIC as a global symbol to
  the rest of the system, but only in local_apic.c.  To aid this, the
  APIC ID of each CPU is exported as a per-CPU variable.
- Interrupt sources are provided for each intpin on each IO APIC.
  Currently, each source is given a unique interrupt vector meaning that
  PCI interrupts are not shared on most machines with an I/O APIC.
  That mapping for interrupt sources to interrupt vectors is up to the
  APIC enumerator driver however.
- We no longer probe to see if we need to use mixed mode to route IRQ 0,
  instead we always use mixed mode to route IRQ 0 for now.  This can be
  disabled via the 'NO_MIXED_MODE' kernel option.
- The npx(4) driver now always probes to see if a built-in FPU is present
  since this test can now be performed with the new APIC code.  However,
  an SMP kernel will panic if there is more than one CPU and a built-in
  FPU is not found.
- PCI interrupts are now properly routed when using APICs to route
  interrupts, so remove the hack to psuedo-route interrupts when the
  intpin register was read.
- The apic.h header was moved to apicreg.h and a new apicvar.h header
  that declares the APIs used by the new APIC code was added.
2003-11-03 21:53:38 +00:00
John Baldwin
223e573bbd Add the new atpic(4) driver for the 8259A master and slave PICs. By
default we provide 16 interrupt sources for IRQs 0 through 15.  However,
if the I/O APIC driver has already registered sources for any of those IRQs
then we will silently fail to register our own source for that IRQ.

Note that i386/isa/icu.h is now specific to the 8259A and no longer
contains any info relevant to APICs.  Also note that fast interrupts no
longer use a separate entry point.  Instead, both fast and threaded
interrupts share the same entry point which merely looks up the appropriate
source and passes control to intr_execute_handlers().
2003-11-03 21:34:45 +00:00
John Baldwin
e14243fac7 Move the NMI handling code out to its own file. 2003-11-03 21:10:17 +00:00
John Baldwin
8d8dbef5ac Remove soon to be obsolete file to break kernel build while the new
interrupt code comes in.
2003-11-03 21:00:34 +00:00
Brooks Davis
9bf40ede4a Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.

This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.

Approved By:	re (in principle)
Reviewed By:	njl, imp
Tested On:	i386, amd64, sparc64
Obtained From:	NetBSD (if_xname)
2003-10-31 18:32:15 +00:00
Brooks Davis
c020a92f9f There is no way to enter the attach routine twice with the same softc
without a detach call in between so don't try to deal with that
possiability.

This is a diff-reduction commit for the upcoming if_xname conversion.
2003-10-30 19:45:58 +00:00
Bruce Evans
ed86674a3d Don't forget to load %es with the kernel data segment selector in
Xcpustop().  %es is used in at least the call to savectx() when savectx()
calls bcopy(), so not loading it was fatal if a stop IPI interrupts
user mode.

This reduces bugs starting and stopping CPUs for debuggers.  CPUs are
stopped mainly in kdb_trap() and cpu_reset().  At reset time there is
a good chance that all the CPUs are in the kernel, so the bug was
probably harmless then.
2003-10-16 10:44:24 +00:00
Doug Rabson
5f16902f7e Add a workaround for the fact that the priv field was removed from
struct driver. We were the last user of that field (and we are scheduled
for demolition) so there wasn't much point in keeping it.
2003-10-16 09:18:35 +00:00
Bruce Evans
fa2e26c437 MFsio (sio.c 1.413: cleaned up and fixed setting of speeds in comparam()).
This is just a cleanup here (modulo rev.1.108 of kern/tty.c), since the
input speed can be different from to output speed and extra code to
handle both speeds naturally handled all cases.
2003-09-27 12:40:23 +00:00
Bruce Evans
7872ac5542 Quick fix for bitrot in locking in the SMP case. cd_getreg() and
cd_setreg() were still using !(read_eflags() & PSL_I) as the condition
for the lock hidden by COM_LOCK() (if any) being held.  This worked
when spin mutexes and/or critical_enter() used hard interrupt disablement,
but it has caused recursion on the non-recursive mutex com_mtx since
all relevant interrupt disablement became soft.  The recursion is
harmless unless there are other bugs, but it breaks an invariant so
it is fatal if spinlocks are witnessed.
2003-09-27 10:30:03 +00:00
Poul-Henning Kamp
3623186cbc Initialize cn_name, ignore cn_dev. 2003-09-26 08:51:54 +00:00
Warner Losh
00dc18b5a8 Per TRB vote: restore the aquire_timer0 and associated goo. This will
be gone in FreeBSD 6, so put BURN_BRIDGES around it.  The TRB also
felt that if something better comes along sooner, it can be used to
replace this code.

Delayed by: BSDcon and subsequent disk crash.
2003-09-24 15:33:33 +00:00
John Baldwin
0e85b19ba9 Add constants for entries in the IDT and use those instead of magic
numbers.
2003-09-10 01:07:04 +00:00
Bruce Evans
4df0520624 clock.c:
Quick fix for calling DELAY() for ddb input in some (atkbd-based)
console drivers.  ddb must not use any normal locks, but DELAY()
normally calls getit() which needs clock_lock.  One problem with using
normal locks in ddb is that deadlock is possible, but deadlock on
clock_lock is unlikely becaluse clock_lock is bogusly recursive,
apparently just to hide the problem of ddb using it.  The i8254 clock
hardware has mostly write-only registers so it is important for it to
use a lock that gives exclusive access.  (atkbd hardware is also
unfriendly to reentrant software but that problem is more local and
already solved.)  I mostly saw the symptoms of the bug caused by
unlocking in getit() running cpu_unpend().  cpu_unpend() should not
be called while in ddb and Debugger() calls for failing assertions
about this caused a breakpoint within ddb.

ddb must also not call getit() because ddb may be being used to step
through clock initialization code that has stopped or otherwise mangled
the clock.  If the clock is stopped, then getit() always returns the
same value and DELAY() takes forever if it trusts getit().

The quick fix is implement DELAY(n) as (n * timer_freq / 1000000)
inb(0x84)'s if ddb is active.

machdep.c:
Don't permit recursion on clock_lock.
2003-09-07 14:23:08 +00:00
Peter Wemm
116b8c8695 Mark the isa compat shims for BURN_BRIDGES for 6.0 2003-09-05 14:55:11 +00:00
Peter Wemm
b324e86370 Clean up some antique stuff. We do not support Weitek FPUs etc, and never
did.
2003-09-05 14:54:26 +00:00
Yoshihiro Takahashi
f2a610fa25 Fix compile error. 2003-08-25 08:13:07 +00:00
Warner Losh
afe1c7ba84 Even though this driver says it is broken, fix the location of the pci
include files.
2003-08-23 16:59:16 +00:00