Commit Graph

964 Commits

Author SHA1 Message Date
Poul-Henning Kamp
d8b47cbb70 Stop isadma from abusing the B_READ, B_RAW and B_WRITE flags.
Define ISADMA_{READ,WRITE,RAW} macros with the same numeric
values as the B_{READ,WRITE,RAW} and use them instead throughout.
2000-03-13 10:19:32 +00:00
Warner Losh
633f93bee5 Fix crashes on card eject for pccard modems. We check for NULL when
we get the com address.  If so, we go ahead and return.  Bruce thinks
there's a bug in the pccard layer that it terminates devices with
extreme prejustice rather than letting them deside for themselves when
to terminate (and he's likely right).  This fix doesn't change that,
but instead works around it by checking for NULL pointers at more
places than before.

The detach routine still calls functions at interrupt level that
aren't reentrant.  In theory this could cause a problem, but none
showed up in practice.  Future versions should correct this problem,
likely by making the detach process a thread/process at the pccard
level.  NEWCARD will do this, and the current pccard layer should
likely be modified to that as well, should it live long enough.

A few style nits of the same form that were in my original patch sent
off to bde were also fixed as part of this process.  Mostly use of
!ptr and return ENOPARENS.

This should prevent a crash on suspend with an active ppp link as
well, but that wasn't tested.

Reviewed by:	bde
Approved by:	jkh
2000-03-11 20:22:09 +00:00
Peter Wemm
d365f16644 Recognize another modem, "PMC2430 - Pace 56 Voice Internal Modem"
Submitted by:	Mark Ovens <mark@ukug.uk.freebsd.org>
2000-03-05 14:44:05 +00:00
Peter Wemm
fee576b2e5 Fix two more problems with freeing the softc data manually. subr_bus.c
is responsible for this and this will lead to malloc 'freeing already
free' type panics.  One was in the probe code, the other was in the
pccard eject? code.

Not explicitly approved by: jkh (but the first is fallout from subr_bus.c
rev 1.54 which was an approved commit, the second is the same problem)
2000-03-02 03:45:41 +00:00
Peter Wemm
a6b8513096 Don't free(sc) before returning an error from probe, it does not "belong"
to us, subr_bus.c will free it.  This bug (panic: freeing already free)
was exposed by kern/subr_bus.c rev 1.54

Not explicitly approved by: jkh (but this is a showstopper and fallout of
the above approved change)
2000-03-01 19:30:36 +00:00
Kazutaka YOKOTA
9e6f8bee0e Do not add children (atkbd and psm) if they are disabled.
Approved by: jkh
2000-02-25 11:40:31 +00:00
Gary Jennejohn
4f9d49f140 Newbus-ify the USR Sportster TA Intern driver.
Enable the driver in sys/conf/files.i386.

In isa/isavar.h increase ISA_NPORT from 32 to 50. This is required
because this brain-damaged card maps 49 (!) port ranges. This does
not have a negative impact because this value only specifies the maximum
number of entries in a linked list and not the size of an array which
is allocated in all drivers.

The register/fifo access routines were not newbus-ified because
1) I knew that the old code worked and is simpler and more efficient
2) the if_ed driver does something similar and
3) the newbus macros collapse to inb/outb anyway.

Reviewed and tested by:	hm
Approved by:	jkh
2000-02-21 02:10:10 +00:00
Bruce Evans
34ae9210dd Fixed regressions in rev.1.274:
1) Non-AST4 multiport cards were broken by bypassing the code that changes
   `idev' to the multiport master device.
2) AST4 multiport cards apparently were broken by inverting the test for
   the master device having an irq.
3) Error handling for nonexistent master devices was broken by removing a
   check for a null pointer.
4) `int' error codes returned by bus_get_resource() were assigned directly
   to the boolean variable com->no_irq.  Probably harmless, since the
   boolean is implemented as a u_char.

Submitted by:	part 1) by Chris Radek <cradek@in221.inetnebr.com>
		part 2) by yokota
Approved by:	jkh
2000-02-15 17:29:09 +00:00
Mike Smith
208cc52f94 When allocating resources in the following cases:
- trying for a fit for a PnP configuration from a device
 - soaking up resources from a configuration that were not allocated by
   the driver

do not attempt to activate them.  Only a device driver that is aware of
the nature of the resource and its suitability can be certain that
activating a resource, particularly a memory resource, is a safe thing
to do.

This was prompted by the discovery that many systems report all physical
memory through a PNP0c02 device; activating this resource maps all
physical memory into the kernel's virtual space, either blowing out the
kernel pagetable or in the worst case causing a panic in pmap_mapdev()
if the system has too much physical memory.

Authorised by:	jkh
Reviewed by:	dfr
2000-02-11 04:35:07 +00:00
Peter Wemm
8f8e587948 Use config's conditional compilation rather than using #ifdefs that make
modular compilation harder.  I'm doing this because people seem to like
cut/pasting examples of bad practices in existing code.
2000-01-29 15:08:56 +00:00
Peter Wemm
2b898d39e5 Remove #include "ppc.h" and #if NPPC > 0 - this is always true as it is
'optional ppc' in conf/files*
2000-01-29 14:02:30 +00:00
Bruce Evans
689315d4f7 "Completed" the previous fix. Return ENOMEM on memory allocation failure
in sioattach(), not ENXIO.  Free resources before returning early in
sioprobe() and sioattach().
2000-01-29 03:02:55 +00:00
Doug Rabson
d64d73c906 * Don't use ivars to access resources, bus_set/get_resource is much better.
* First approximation of making this work on alpha (not working yet).
2000-01-25 22:21:45 +00:00
Nick Hibma
9c918de3de Return ENXIO on error, not 0. Seems to have been skipped when converting
to newbus.

Reviewed by:	bde
2000-01-23 15:11:15 +00:00
Peter Wemm
5995e84e19 Add another four device ID's for isa pnp modems. The USR's seem to use
the same vendor and logical ID.  The rest I am not sure whether they
are vendor or logical, but it won't hurt if I've put a vendor ID here
as merely will not match.  These came from the old sio-pnp code, hence
the uncertainty about which ID it is.
2000-01-18 09:30:58 +00:00
Peter Wemm
2d77b66efb Add ADS7182 as a known Joystick. 2000-01-18 08:38:35 +00:00
Mike Smith
01fef73008 Don't mark unallocated resources as active; the goal is to reserve them,
and there may be a good reason for them being unallocated (eg. they're
nonsensical or not useful).  The goal here is simply to reserve them
against accidental use by other code.
2000-01-18 02:15:05 +00:00
Peter Wemm
a9d565fcd2 Don't do device_set_desc() until after checking for PnP probes. Otherwise
things like sound cards can get called "Parallel port".  A note to the
unwary; the isa-pnp devices in the system are probed like PCI - each
device ID is passed to *all* isa probe routines to find the best match.
If the driver is not prepared to deal with this, it must abort in this
scenario or it will try and claim all PnP devices.
2000-01-14 05:03:23 +00:00
Nicolas Souchu
0f210c922b Port of ppbus standalone framework to the newbus system.
Note1: the correct interrupt level is invoked correctly for each driver.
       For this purpose, drivers request the bus before being able to
       call BUS_SETUP_INTR and BUS_TEARDOWN_INTR call is forced by the ppbus
       core when drivers release it. Thus, when BUS_SETUP_INTR is called
       at ppbus driver level, ppbus checks that the caller owns the
       bus and stores the interrupt handler cookie (in order to unregister
       it later).

       Printing is impossible while plip link is up is still TRUE.
       vpo (ZIP driver) and lpt are make in such a way that
       using the ZIP and printing concurrently is permitted is also TRUE.

Note2: specific chipset detection is not done by default. PPC_PROBE_CHIPSET
       is now needed to force chipset detection. If set, the flags 0x40
       still avoid detection at boot.

Port of the pcf(4) driver to the newbus system (was previously directly
connected to the rootbus and attached by a bogus pcf_isa_probe function).
2000-01-14 00:18:06 +00:00
Andrew Gallatin
91dab55369 Make this compile on alpha 2000-01-13 02:09:44 +00:00
Kazutaka YOKOTA
e2f29c6e43 Make the mouse cursor char code configurable via the CONS_MOUSECTL
ioctl.

By popular demand.
2000-01-12 12:30:33 +00:00
Kazutaka YOKOTA
35e61cbd71 Add a new mechanism, cndbctl(), to tell the console driver that
ddb is entered.  Don't refer to `in_Debugger' to see if we
are in the debugger.  (The variable used to be static in Debugger()
and wasn't updated if ddb is entered via traps and panic anyway.)

- Don't refer to `in_Debugger'.
- Add `db_active' to i386/i386/db_interface.d (as in
  alpha/alpha/db_interface.c).
- Remove cnpollc() stub from ddb/db_input.c.
- Add the dbctl function to syscons, pcvt, and sio. (The function for
  pcvt and sio is noop at the moment.)

Jointly developed by: bde and me

(The final version was tweaked by me and not reviewed by bde.  Thus,
if there is any error in this commit, that is entirely of mine, not
his.)

Some changes were obtained from: NetBSD
2000-01-11 14:54:01 +00:00
Bruce Evans
66aeaaf280 Removed some more vestiges of ft.
Fixed some style bugs.
2000-01-09 17:13:35 +00:00
Peter Wemm
b6e5f28e51 Futher cleanup.. "device_print_prettyname(); printf()" -> device_printf()
It seems that the IDE system uses 0x3f6 for itself, which conflicts with
fdc's default 0x3f0-3f7 allocation range. Sigh.  Work around this.
Use bus_set_resource() rather than allocating specific areas, it makes
the code a little cleaner.

Based on work by:	dfr
2000-01-08 09:33:09 +00:00
Warner Losh
3b1782065f Merge most of FDC_YE into the mainline driver.
o Rename FDC_PCMCIA to FDC_NODMA to allow systems that don't have dma
  for floppies.
o Remove all but two FDC_YE ifdefs.  They aren't needed.
o Move defines for YE_DATAPORT to fdreg.h.

Not fixed:
o The pccard probe/attach.  However, motivated individuals can more
  easily add this now.

This is a merge of changes I've had in my tree for a long time.  These
fixes were tested on my VAIO with its normal floppy.  Please let me
know if I broke anything.

Prodded by: Peter Wemm <peter@freebsd.org>
2000-01-06 07:13:54 +00:00
Peter Wemm
b9da888fcb Make the evil broken pnpbios compensation slightly less evil.
This is the hack that compensates for when bios vendors "forget" to
include the fdc control (0x3f7) port in their io port mappings.  Instead
of accessing ports outside of a range allocated to a handle, simply
allocate the port directly.  It even shows up in the probe..
2000-01-05 17:42:43 +00:00
Peter Wemm
37286586ff Patch up some of the evilness left over from the early newbus porting.
In particular:
 - Don't leave resources allocated in the probe routine.  Allocate them
   during probe and release them.  Probe's job is to identify devices only.
 - Don't abuse the ivars pointer.. (!).  Create real ivars and use the
   proper access system.  (the bus_read_ivar method)
 - Don't add the children until attach() has successfully grabbed the
   hardware, otherwise there are potential leaks if attach fails.
2000-01-05 16:31:27 +00:00
Tor Egge
82916a1126 ISA device drivers use the ISA source interrupt number in locations where
the low level interrupt handler number should be used.  Change
setup_apic_irq_mapping() to allocate low level interrupt handler X (Xintr${X})
for any ISA interrupt X mentioned in the MP table.

Remove an assumption in the driver for the system clock (clock.c) that
interrupts mentioned in the MP table as delivered to IOAPIC #0 intpin Y
is handled by low level interrupt handler Y (Xintr${Y}) but don't assume
that low level interrupt handler 0 (Xintr0) is used.

Don't allocate two low level interrupt handlers for the system clock.
Reviewed by:	NOKUBI Hirotaka <hnokubi@yyy.or.jp>
2000-01-04 22:24:59 +00:00
Peter Wemm
7d674827c8 Recognize the CSC0101 ID for the Thinkpad series.
PR:		15633
Submitted by:	gibbs
1999-12-30 20:07:20 +00:00
Peter Wemm
c447342094 Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot).  This is consistant with the other
BSD's who made this change quite some time ago.  More commits to come.
1999-12-29 05:07:58 +00:00
KATO Takenori
6fb89845b4 Added following modes:
5in     HD 2 heads, 77 cylinders, 8 sectors/track, 1024 bytes/sector
 5/3.5in DD 2 heads, 80 cylinders, 8 sectors/track, 512 bytes/sector

Meanings of the rogrammer-readeble fd name were explained by Brian
Fundakowski Feldman and Peter Wemm in hackers list and NOKUBI
Hirotaka.

Reviewed by:	nyan
1999-12-28 07:38:38 +00:00
Peter Wemm
9928855f97 Recognize the GVC0505 (GVC 56k Faxmodem) as a sio device.
Obtained from: Dan J Fraser <dfraser@capybara.org> (for NetBSD)
1999-12-27 05:02:25 +00:00
Bruce Evans
0f19e631e2 Fixed races accessing the RTC. The races apparently caused
apm_default_resume() to sometimes set a very wrong time.
(1) Accesses to the RTC index and data registers were not atomic enough.
    Interrupts were not masked.  This was only good enough until an
    interrupt handler (rtcintr()) started accessing the RTC in FreeBSD-2.0.
(2) Access to the block of time registers in inittodr() was not atomic
    enough.  inittodr() has 244us to read the time registers.  Interrupts
    were not masked.  This was only good enough until something (apm)
    started calling inittodr() after boot time in FreeBSD-2.0.
The fix for (2) also makes the timecounter update more atomic, although
this is currently unimportant due to the low resolution of the RTC.

Problem reported by:	mckay
1999-12-25 15:30:31 +00:00
Peter Wemm
684fb19e34 Extract a list of extra isa pnp modem ID's from NetBSD and OpenBSD. Some
of these are bound to have a PNP05xx compatid, but there's no easy way to
tell.  Since it's just an ID list and uses the pnp header's description
strings rather than encoding strings here, it doesn't seem to be too
expensive to err on the safe side.
1999-12-21 09:16:03 +00:00
Joerg Wunsch
e34c71ea40 Add a flag to disable FIFO probing. The code seems to have a chance of
misdetecting FIFO capabilities, at least on my girlfriend's Thinkpad 755,
the driver doesn't work using the FIFO.

While i was at it, i (partially) fixed option FCC_YE since it would no
longer have compiled at all under -current.  I've also made an attempt
to document the device driver flags value (ab-)used internally by this
option.

RELENG_3 candidate, but with a slightly different patch there (will go
to jkh in email).
1999-12-21 08:33:03 +00:00
Peter Wemm
99c215c08b Add SUP2070 (Diamond SupraExpress 56i)
Submitted by:  Kenneth Wayne Culver <culverk@wam.umd.edu>

Add MOT4560
Obtained from: wollman
1999-12-20 20:31:23 +00:00
Peter Wemm
ec6e462d78 Remove references to register_intr() etc in comments. 1999-12-20 15:11:31 +00:00
Yoshihiro Takahashi
5e9136bbe2 Removed unnecessary include files. 1999-12-20 12:08:20 +00:00
Kazutaka YOKOTA
273157da59 - Add the device resume method. It supercedes the existing resume
routine which hooks the apm driver.
- Rename the PSM_HOOKAPM option to PSM_HOOKRESUME.
- Delete unnecessary #include.
1999-12-15 10:04:05 +00:00
Peter Wemm
d00177ef7e Make this kld'able (#include "joy.h" no longer required as there are no
references to NJOY any more after newbusification)
1999-12-12 20:39:35 +00:00
Warner Losh
0712c356a3 o Make pccard work at all by including card.h
o fix return type of sio_pccard_detach
o don't free softc in deatch, since that is done by newbus
o disconnect interrupt we used to have.  Add cookie to com so that we can
  tear down the interrupt on unload
o Set gone earlier, but likely doesn't matter

This makes sio pccards work again.  Cards that are active when ejects may
not work (but they might, softc goes away quickly).

These changes are unreviewed by bde.  I'll make any style changes he wants.
1999-12-10 08:19:19 +00:00
Peter Wemm
4246912f31 Fix a pair of silly warnings that I introduced (that would have been
nasty on an Alpha or some other sizeof(int) != sizeof(long) machine).
1999-12-06 17:52:20 +00:00
Peter Wemm
a2639a184d Add a truely evil workaround (hack!) for some unfortunate BIOS
programming practices.  It seems that newer fdc chips have an
alternative way of setting the transfer speed (including high speed
modes for floppy tape) that doesn't use the control register (which
we don't support - we use the old way only).  So, they (the BIOS
programmers) sometimes leave out the 0x3f6 control register from
the PnP ports descriptor(!!).  "Hey, it works with windows, so
what's the problem?" :-(  Anyway, this hack tries to compensate
for that.  This was discussed with dfr (who did the pnp attachment).
1999-12-06 06:59:09 +00:00
Peter Wemm
d0029cf5f3 Use bus_get_resource() instead of bus_get_resource_start() as the latter
returns "0" on failure, which is indistinguishable from (say) irq 0.  This
should stop a couple of stray messages that turn up.

Also, if a BUS_SETUP_INTR() fails with INTR_TYPE_FAST, try falling back to
a normal interrupt.  This might help pccard folks with a shared slot
interrupt.  This whole thing needs to be revisited.
1999-12-06 06:47:02 +00:00
Peter Wemm
2533e89e3b newbusify and port the joy driver to the Alpha. It now attaches to the
joystick port on PnP sound cards that have a suitable device ID on them.

Doug Rabson added timer code so it didn't have to beat on the isa timer.

Submitted by:   Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
1999-12-05 19:51:40 +00:00
Matthew N. Dodd
fe0d408987 Remove the 'ivars' arguement to device_add_child() and
device_add_child_ordered().  'ivars' may now be set using the
device_set_ivars() function.

This makes it easier for us to change how arbitrary data structures are
associated with a device_t.  Eventually we won't be modifying device_t
to add additional pointers for ivars, softc data etc.

Despite my best efforts I've probably forgotten something so let me know
if this breaks anything.  I've been running with this change for months
and its been quite involved actually isolating all the changes from
the rest of the local changes in my tree.

Reviewed by:	peter, dfr
1999-12-03 08:41:24 +00:00
Warner Losh
e09f49b6fa Fix the hang on card eject problem and maybe the hang on suspend
problem.

o Create new timeout routine so we don't detach the card inside a ISR
  but instead drop back to spl0 via a timeout of 0.
o Actually delete the child of the pccard device rather than just faking
  it badly.
o Fix sio, ed and ep to have pccard detach routines that are int rather
  than void.
o Fix ep and ed pccard detach routines to use if_detach rather than just
  if_down.  if_detach destroys the device, while if_down just marks it
  down.  In this incarnation of the pccard things, we map the disable
  the slot action to detach the driver, which removes the driver from the
  device tree.  When that is done, a panic would soon follow as the
  ifconfig tried to down the device.

Didn't fix:
o Should cache the pccard dev child's pointer in struct slot
o remove now unused parts of struct slot
o Any driver using softc after detach has been called.  sio's softc used
  to be statically allocated, so you could check sc->gone, but that is
  now gone.
o Didn't remove gone from softc of drivers that use the old pccard method.

Didn't test:
o ed driver changes
o sio driver changes on pccards
o suspend (no laptop or apm support on my desktop)
1999-12-01 07:38:54 +00:00
Andrew Gallatin
0e7e521cf3 Allow a DMA channel of 0. This gets the on-board mss audio device working
on Digital AlphaStations 200 and 500 machines (and probably others as well).

Submitted by: dfr
1999-11-22 14:30:41 +00:00
Peter Wemm
5ab0514321 Allow NULL for startp and/or countp in bus_get_resource() so that you can
get one of the two without having to use a dummy variable.
1999-11-20 14:56:55 +00:00
Peter Wemm
592b1c00b5 Argh, don't turn the IIR test on unless it's a pccard. These tests mess
up the subsequent probes.
1999-11-18 10:29:06 +00:00