Commit Graph

438 Commits

Author SHA1 Message Date
christos
586ab73157 fix include filename. 2015-08-22 14:11:19 +00:00
christos
e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
kamil
f874bd0561 Improve spelling: regsiter -> register
This change is non-functional.

Approved by <riastradh>, <pgoyette>
2015-07-11 10:32:45 +00:00
ozaki-r
b8199900dc Remove leftover use of AF_NS and NS option
Unnecessary NETISR_NS is also removed.
2015-05-20 09:17:17 +00:00
mlelstv
6f00c789e1 Use C99-style initializers for struct dkdriver. 2015-04-26 15:15:19 +00:00
riastradh
445478ce67 MD rnd.h cleanups. Please let me know if I broke anything! 2015-04-13 21:18:40 +00:00
christos
c182898b0d We have three sets of DTYPE_ constants in the kernel:
altq		Drop 		Type
	disklabel	Disk 		Type
	file		Descriptor	Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
2015-01-02 19:42:05 +00:00
christos
ad0f8520fc restore part decl. 2015-01-02 15:53:25 +00:00
christos
555c17c325 declare error 2015-01-01 17:46:09 +00:00
christos
c60db2e923 make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
2014-12-31 19:52:04 +00:00
chs
6d40f9ff57 add a new "fo_mmap" fileops method to allow use of arbitrary uvm_objects for
mappings of file objects.  move vnode-specific details of mmap()ing a vnode
from uvm_mmap() to the new vnode-specific vn_mmap().  add new uvm_mmap_dev()
and uvm_mmap_anon() convenience functions for mapping character devices
and anonymous memory, and replace all other calls to uvm_mmap() with those.
use the new fileop in drm2 so that libdrm can use mmap() to map things
like on other platforms (instead of the ioctl that we have used so far).
2014-12-14 23:48:58 +00:00
tls
ea6af427bd Merge tls-earlyentropy branch into HEAD. 2014-08-10 16:44:32 +00:00
dholland
f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland
8c70ef39af Add d_discard to all struct bdevsw instances I could find.
I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
2014-07-25 08:02:18 +00:00
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