Commit Graph

424 Commits

Author SHA1 Message Date
christos
4c3cdcf099 kill sprintf, fix unused. 2014-03-26 08:17:59 +00:00
christos
16754bf12b fix unused, missing splx. 2014-03-26 08:17:32 +00:00
tsutsui
8e58ff0f9c Replace tsleep(9)/wakeup(9) with condvar(9) as practice.
Also replace malloc(9) with kmem_alloc(9).
Pevent more possible races.

Tested on both console and Xserver on X68030.
2014-03-21 16:58:54 +00:00
dholland
a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
tsutsui
2ea76048e0 Fix build botched in previous.
Christos, please at least compile before commit per the guideline.
2014-01-31 18:42:45 +00:00
christos
ebeed790b8 kill VM_DEFAULT_ADDRESS use. 2014-01-26 00:09:46 +00:00
christos
c96b1c993d kill bogus inline 2013-05-24 18:24:27 +00:00
isaki
7e67d439af Fix a kernel panic by printf(1).
The 2nd byte of ISO-2022-JP must be 0x21-0x7e.  Especially,
the character code less than 0x2121 causes SEGV, because a
font address points outside of the CGROM.
Reported by tsutsui@.  Should be pulled up to netbsd-6.
2013-04-28 14:44:46 +00:00
isaki
50aab03cd0 Detect emulators (and display it on dmesg). 2013-01-22 11:58:39 +00:00
chs
cbab9cadce split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
2012-10-27 17:17:22 +00:00
tsutsui
17a9010449 KNF and space nits 2012-10-14 19:06:25 +00:00
tsutsui
88ab3aa82d Add floppy format support. Mostly taken from sys/dev/isa/fd.c.
Tested both fdNa (1232KB, 1024bytes/sector, 8sectors/track) and
fdNc (1200KB, 512bytes/sector, 15sectors/track) format on X68030
using fdformat(1).

Finally we can prepare NetBSD/x68k install floppies without Human68k
(except actual initial bootstrap).
2012-10-14 18:38:32 +00:00
tsutsui
f5ea236221 Terminate DMAC and call bus_dmamap_unload(9) properly in all FDC xfer
error paths, as sys/dev/isa/fd.c does.  Fixes unexpected DMAC errors
(and possible VM panic due to un-unloaded dmamap) on the first floppy
access after read/write errors.
2012-10-14 17:25:59 +00:00
tsutsui
75c98cb8e5 Before probing floppy drives, call NE7CMD_SENSEI and fdcresult()
to drain possible pending FDC interrupts.  Taken from sys/dev/isa/fd.c.
Hopefully might fix occasional fd drive probe failure (but not confirmed).
2012-10-14 17:20:18 +00:00
tsutsui
e7496b5fd1 To abort DMA in dmac_abort_xfer(), set DMAC_CCR_SAB (software abort)
rather than DMAC_CCR_HLT (halt operation).

DMAC_CCR_HLT doesn't abort DMA xfers but only suspends DMA ops
(i.e. clearing HLT bit will resume DMA xfers), so previously
DMAC error always occurs on the next DMA xfer ops after
dmac_abort_xfer() is called.

Also suppress DMAC error messages in dmac_error() if it's caused
by software abort command because it can happen during normal
audio play/record DMA ops in vs(4) driver.
2012-10-14 16:36:31 +00:00
tsutsui
0c3cdf0030 Normalize autoconf(9) function arg names (parent, self, and aux)
for clarification.  from chs@.
2012-10-13 06:43:00 +00:00
tsutsui
4627401b70 Fix device_t/softc split bothces. From Chuck Silvers' patch posted on
current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html
and several more fixes by me.

Not sure if these are fatal (at least 6.0_RC2 works without thise fixes),
but needs more investigation.
2012-10-10 17:49:50 +00:00
tsutsui
19c63c3512 Fix device_t/softc split botches that could be fatal. From
Chuck Silvers' patch posted current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html

Should be pulled up to netbsd-6.
2012-10-10 16:51:50 +00:00
tsutsui
ece81734fb Make sure to take proc_lock mutex on calling psignal(9) in EV_WAKEUP() macro
as sys/dev/sun/event_var.h does.
Fixes immediate KASSERT(mutex_owned(proc_lock)) panic during running Xserver
on DIAGNOSTIC kernel.

Should be pulled up to netbsd-6.
2012-08-15 19:13:58 +00:00
matt
283ccd082a Another failed typedef fixed. 2012-07-29 00:08:19 +00:00
tsutsui
3bd688cacb - check bus_space_map(9) return value
- use BUS_SPACE_MAP_SHIFTED_ODD for clarify
- define and use proper macro instead of magic
2012-05-15 12:17:33 +00:00
tsutsui
140f97b123 KNF and cosmetics. No binary change. 2012-05-13 03:00:40 +00:00
tsutsui
888b558562 - use <sys/bus.h> rather than <machine/bus.h>
- no need to include uvm_extern.h
- include "ioconf.h" for struct cfdriver foo_cd
2012-05-13 00:47:16 +00:00
tsutsui
9a84d2f995 Explicitly specify a proper FDC data register address for HD63450 DMAC
to avoid confusion.

Previous one (fdc->sc_addr + fddata) wasn't a right address for
the FDC's data register but one for the command register by accident,
but FDC ignores A0 address input (connected to A1 of x68k address bus)
during DMA xfer (i.e. when DACK is asserted) so it happened to work
as expected on the real X680x0 hardware, but caused trouble on emulators.

The inconsistency was found by Y.Sugahara during debugging XM6i emulator
(and it will be fixed in the next release).
FDC behavior during DMA is confirmed by uPD72068 hardware application note.

XXX: There is no proper MI API to specify DMA address for DMA controller
     (like MC68450) to access devices mapped to memory space by bus_space(9).
2012-05-12 15:29:22 +00:00
tsutsui
bf4f59d877 Make x68k's floppy driver actually work with proper bounce buffer xfer ops
on machines with extended high memories:

- dev/fd.c:
 - add missing bus_dmamap_sync(9) POSTREAD/POSTWRITE ops

- x68k/machdep.c:
 - update avail_end variable (which is used to check DMA'able memory range
   in intio.c) properly per probed extended memory regions

The problem was found during debugging XM6i's FDC emulation by
Y.Sugahara, isaki@, and me.

Should be pulled up to netbsd-6.
2012-05-06 19:46:18 +00:00
tsutsui
231b9114f6 Finally switch PSX16550 fast serial board driver to using MI com(4) driver.
Based on isaki@'s patch and debugged by both isaki@ and tsutsui@.

PSX16550 specific hardware infomation is taken from Human68k's PSXIO driver:
http://retropc.net/x68000/software/hardware/psx16550/

XXX1: TL16C550C seems to have some timing critical issue around THRE interrupt
XXX2: auto hardware flow control of TL16C550 is not implemented in MI com(4)
2012-04-29 07:17:11 +00:00
tls
7b0b7dedd9 Entropy-pool implementation move and cleanup.
1) Move core entropy-pool code and source/sink/sample management code
   to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
   source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
   avoid expensive operations on disabled entropy sources; make the
   rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
   have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
   system events, and skew between clocks, with a sample implementation
   for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files).  Tested with release
builds on amd64 and evbarm and live testing on amd64.
2012-02-02 19:42:57 +00:00
para
89c9828deb converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
2012-01-27 18:52:47 +00:00
isaki
9289c438ac Add powsw(4) for x68k power switch. It substitutes for a part about
power switch handler of pow(4) deleted before.
Benefits than pow(4):
- separate a front switch (= powsw0) and an EXPWON line (= powsw1)
  completely. Only powsw0 is enabled in GENERIC by default.
- prevent chattering in some hardware individuals.
  thank you for a report and a test: Yasushi Oshima and Y.Sugahara.
2011-11-27 09:00:32 +00:00
jmcneill
8a962f23f2 Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

  Add MP locking to the audio drivers.

  Making the audio drivers MP safe is necessary before efforts
  can be made to make the VM system MP safe.

  The are two locks per device instance, an ISR lock and
  a character device lock. The ISR lock replaces calls to
  splaudio()/splx(), and will be held across calls to device
  methods which were called at splaudio() before (e.g.
  trigger_output). The character device lock is held across
  calls to nearly all of the methods, excluding some only
  used for initialization, e.g. get_locks.

Welcome to 5.99.57.
2011-11-23 23:07:28 +00:00
tls
3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
isaki
2ccb98927e Obsolete pow(4) and rtcalarm(8). Discussed in port-x68k@.
Probably the combination of pow(4) ioctl and rtcalarm(8) does
not work for a long time, and nobody uses them.
I'll rewrite a part about power switch handler as a new device.
2011-11-19 12:27:42 +00:00
tsutsui
a61d3c89b5 Calling psignal(9) (via EV_WAKEUP()) in interrupt handlers
could cause mutex error panic, so defer it via softint(9).
This should fix panic on heavy key strokes during running Xserver.

Should be pulled up to netbsd-5.

XXX: amiga and atari might have the similar problem?
2011-10-23 13:21:54 +00:00
isaki
fec6c386cc Switch to 2-clause license. 2011-10-16 03:10:17 +00:00
tsutsui
a595e9f720 Add a comment for the previous change. 2011-05-05 13:44:35 +00:00
tsutsui
08bc844a54 Don't call mfp_init() in mfp_attach().
It's already called from early mfp_config_console() via config_console()
and reinitializing MFP could sometimes cause silent hang.
2011-05-04 12:27:03 +00:00
tsutsui
cc81f439dd Reset ZS chip properly in zscninit() so that zscngetc() works
even before zsc is attached during configure.
(i.e. make userconf(4) work on serial console)
2011-05-01 16:19:13 +00:00
rmind
2626d57668 Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency.  Remove some unnecessary malloc.h inclusions as well.
2011-04-24 16:26:51 +00:00
tsutsui
ef54da0a01 Fix hangup on the first floppy access since 2008.
Problem was reported by isaki@.

On X680x0 (and most other machines other than ISA FDC),
the ready line from FDD is connected to FDC and fdc driver can
be notified of the ready state after fd_set_motor() by interrupts.
In this case no need to use callout(9) to wait the FDD motor stabilized,
and the callout(9) method used in ISA fdc(4) driver rather caused
infinite unhandled interrupts since callout(9) was no longer invoked
during interrupt storm after vmlocking2 merge, I guess.

Should be pulled up to netbsd-5.
2011-04-10 15:23:06 +00:00
rmind
9b6bd2d968 Remove clause 3 (UCB advertising clause) from the University of Utah
copyright.  Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
2011-02-08 20:20:06 +00:00
isaki
bec4c1ae51 Probe not only ctrl address but also bank window address.
This prevents the wrong matching when other boards like
Neptune-X exist.  Reported by Yasushi Oshima.
2010-08-08 09:30:29 +00:00
isaki
09e97aa9a0 Probe not only Nereid Ctrl port but also SL811HS/T port. 2010-07-24 13:15:13 +00:00
mrg
fb81c7d694 fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h.  FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
2010-06-06 04:51:33 +00:00
mrg
bd01b4a30e fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h.  FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
2010-06-06 04:50:05 +00:00
isaki
4fc2ffd701 Correct rev1.11.
Fix panic reported by Yasushi Oshima.
2010-05-08 02:48:31 +00:00
tsutsui
8f7c20ed4f Put several fixes to ne(4) driver for better 8 bit mode support,
especially on RTL8019AS which is also used for non-ISA local bus of
embedded controllers and some m68k machines like atari and x68k.

 * move RTL8019 probe and attach code from each bus attachment
   to MI ne2000_detect() and ne2000_attach()
 * change a method for backend and attachment to specify 8 bit mode
   to use a new sc->sc_quirk member, instead of sc->sc_dmawidth
 * handle more NE2000 8 bit mode specific settings, including
   bus_space(9) access width and available size of buffer memory
 * add a function to detect NE2000 8 bit mode
   (disabled by default, but enalbed by options NE2000_DETECT_8BIT
    to avoid possible regression on various ISA clones)
 * fix ipkdb attachment accordingly (untested)

Tested on two NE2000 ISA variants (RTL8019AS and another clone named UL0001)
in both 8 bit and 16 bit mode on i386. "Looks good" from nonaka@.

See my post on tech-kern for details:
http://mail-index.NetBSD.org/tech-kern/2010/02/26/msg007423.html
2010-03-03 13:39:57 +00:00
pooka
10fe49d72c Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client.  This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached.  However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff.  ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
2010-01-19 22:06:18 +00:00
isaki
8cf7d2d787 Make compile with DEBUG. 2010-01-09 09:16:32 +00:00
isaki
bdc7b127e2 Correct return value of ne_*_match().
It's attach priority, not ne2000 model.
2009-11-28 03:10:09 +00:00
rmind
3dc24f5a91 Use lwp_getpcb() on m68k ports, clean from struct user usage. 2009-11-23 00:11:42 +00:00