Commit graph

932 commits

Author SHA1 Message Date
Thomas Cort 526eb34144 cat24c256: driver for the cat24c256 i2c eeprom
Change-Id: I682d136c80fc868d3f0a5edb0cf6c33c0f3a28ea
2013-07-15 17:03:18 -04:00
Thomas Cort 550fdfb443 i2c: initial bus drivers for am335x and dm37xx
Change-Id: I478704fbf30dbf6d3382bcbfb11e75b512c032a1
2013-07-15 11:11:13 -04:00
Ben Gras 456359aa72 retire 64-bit conversion functions
Change-Id: Ib6b81403f877c363a286c654e0524fa1cb781b80
2013-06-24 16:50:57 +02:00
Kees Jongenburger 964e313c94 arm:use the 4 bit mmc data bus if supported by the card.
Change-Id: I55de05db23ad1766e5faec93252e8410cbf59001
2013-06-24 09:12:11 +02:00
Kees Jongenburger 061fed753e arm:mmc driver refactor and timeout fix for BeagleBoneBlack.
When we send MMC commads that contain data the controller provides no
description of the order of events and we need to be able to send data
from and to the controller "when needed". Changed the code to react
on buffer read and buffer write ready based on interrupts.

Change-Id: I60c9140bf0e45b74be6475054564d4e1bd89f21e
2013-06-24 09:12:10 +02:00
Kees Jongenburger 718114d9b0 arm:mmc driver refactor.
Generalize the usage of mmc_send_cmd function to allow
it to transfer data and remove direct invocations to
mmchs_send_cmd.

Change-Id: Iabb9a7d3f4ec57536407b369531ded2b8b649cce
2013-06-18 14:35:44 +02:00
Anton Kuijsten 2e3046757a LLVM bitcode for almost the whole source tree
Change-Id: Ibc6f89de112e0649c3a3bfe49c2baa2ed0746212
2013-06-18 10:49:53 +02:00
Thomas Cort ba92d5219d clkconf: move clkconf from libgpio to it's own lib
Clock configuration will be needed by other/future subsystems such as i2c.
Extract the functionality from libgpio and put it into it's own library.

Change-Id: I6f6de0b3fb4d305ddfeac74123b78c983d1318dd
2013-06-18 09:09:23 +02:00
Ben Gras 71ac8a3a8a some arm uart fixes
. always keep reading data from uart so the interrupt is
	  not continually asserted if data is sent but no process
	  reads it
	. increase tx & rx fifo trigger levels -> reduces the number
	  of interrupts necessary
	. bigger rx/tx buffers

Change-Id: I3cf7c73b22ae2fc091b845d516ba4aa53e892cda
2013-06-14 23:58:44 +02:00
Ben Gras 93d9caa2d6 tty: i386: rs232 fix
. ignore interrupt (stop interrupt check loop) if
	  interrupt bit not set; limit loop too
	. mask off other bits when testing bits in the status register
	. this fixes rs232 output that would otherwise never get re-triggered
	  as too many bits were set in the status byte to match the
	  possibilities.

Change-Id: I311c93377fa8fb477ee9a756455fdeda780e6ba1
2013-06-12 07:04:52 +00:00
Kees Jongenburger b1e0ada171 arm:tty enable FIFO
Change-Id: Iaaa7c0bcb40c2cce2423c1defc14809ed6c70e9c
2013-06-05 19:19:38 +02:00
Ben Gras 2d2a1a077d panic: declare as printf-style-checked
. and related fixes

Change-Id: I5131ac57dc53d8aec8d421a34c5ceea383404d7a
2013-05-31 13:35:25 +00:00
Kees Jongenburger 758c8eaf41 arm:adapt MMC driver to also work on the AM335X platform.
Change-Id: I30e69b7bfd377d1dd2b0b458dd00ee411b060285
2013-05-24 15:47:04 +02:00
Kees Jongenburger 0748a95f88 arm:mmc only compile mmchs when targeting arm.
Change-Id: Ie8d0b6461b58c2a7becda98401dece81be607a01
2013-05-24 15:46:59 +02:00
Kees Jongenburger 742cf53aa9 arm:adapt tty driver for AM335X.
Change-Id: Ic861d68d0576c2abcdcb265a450c013ea2b28499
2013-05-24 14:03:14 +02:00
Ben Gras 225ed6d7bd at_wini: enable busmastering in pci if necessary 2013-05-18 15:57:30 +00:00
Ben Gras e8681e9929 virtio_blk: always start if found
Change-Id: Iec70c67e1b675297b5ffb800a9fb263feffa9271
2013-05-17 11:32:45 +00:00
Ben Gras 062d5d7811 Revert "virtio_blk: always start if found"
Wrong commit pushed, investigating.

This reverts commit a476662532.
2013-05-16 13:34:17 +00:00
Ben Gras a476662532 virtio_blk: always start if found
Change-Id: Iec70c67e1b675297b5ffb800a9fb263feffa9271
2013-05-16 12:02:48 +00:00
Ben Gras 717425320f kernel, random: adaptive entropy gathering
kernel: stop gathering timestamps once the bin is full per interrupt

random: once seeded, retrieve new entropy at a lower rate

Change-Id: I4ce6081d39274728d82c6889686d1650cfd5fc2e
2013-05-07 17:19:06 +00:00
Ben Gras 80846c4a79 kernel ipc debug: various fixes
. add receive hooks in the kernel to print asynchronously
	  delivered messages
	. do not rely on MF_REPLY_PEND to decide between calls and errors,
	  as that isn't reliable for asynchronous messages; try both instead
	. add _sendcall() that extract-mfield.sh can then reliably recognize
	  the fields for messages that are sent with just send()
	. add DEBUG_DUMPIPC_NAMES to restrict printed messages to
	  from/to given process names

Change-Id: Ia65eb02a69a2b58e73bf9f009987be06dda774a3
2013-05-01 21:40:23 +00:00
Ben Gras 85fd078707 tty: non-overlapping code for FKEY_CONTROL
. to decode it in kernel/debug.c

Change-Id: I0d2cc66e87d97a362fa549b364b4d1b0e1225e66
2013-05-01 21:36:43 +00:00
Kees Jongenburger dfbe2f16ee build:Updated proto.dev from mkproto -s /dev
proto.dev was missing some entries and is currently used as base version for
the ARM root file system.
2013-04-29 11:47:40 +02:00
Michael W. Bombardieri cb51426c6a rs232: remove unneeded lock()/unlock() functions
Change-Id: Ie1d2a7f460132aa59791cd7d16c9068b79675f1b
2013-04-12 21:37:26 +02:00
Kees Jongenburger 9d9456ef7d arm:cleanup add assert. 2013-04-12 20:52:57 +02:00
Kees Jongenburger 1e9492a8b8 arm:cleanup omap serial, remove unused defines. 2013-04-12 20:52:57 +02:00
Kees Jongenburger 037aeb5a13 arm:rs232 fix.
The kernel API for requesting interrupts and the associated callback
have a somewhat strange behaviour. Requesting an interrupts is done
by calling sys_irqsetpolicy using an interrupt and a given id. This
id can be modified by the sys_irqsetpolicy and must be used for
subsequent calls to sys_irqenable/sys_irqdisable. However upon an
incoming call from the kernel NOTIFY_ARG contains the original value
encoded in a set e.g. if  1 << id == true the interrupt was raised.
2013-04-12 20:52:57 +02:00
Kees Jongenburger aa3db0e0e2 mmc:Change startup message in rc script. 2013-04-12 20:52:57 +02:00
Thomas Cort e67fc5771d libc: add clock_getres()/clock_gettime() system calls.
In order to make it more clear that ticks should be used for timers
and realtime should be used for timestamps / displaying the date/time,
getuptime() was renamed to getticks() and getuptime2() was renamed to
getuptime().

Servers, drivers, libraries, tests, etc that use getuptime()/getuptime2()
have been updated. In instances where a realtime was calculated, the
calculation was changed to use realtime.

System calls clock_getres() and clock_gettime() were added to PM/libc.
2013-04-04 15:04:53 +02:00
David van Moolenbroek 50e46307de Move MINIX reboot definitions into minix/reboot.h
Also fix a buffer overflow in commands/reboot/sh_wall.c.

Change-Id: I3a61057c4f0221d1700e14d44520b4ad17f1dbe1
2013-03-20 16:50:01 +00:00
David van Moolenbroek 3be9c7c33b Rename "struct partition" to "struct part_geom"
Change-Id: Ifaf9795ba70f5b933599b2a6ec9415e6bd13200c
2013-03-20 16:14:21 +00:00
Ben Gras 5acaa0814f kernel, ramdisk: some boot unification
To use the new SD building script, Linux has to be configured with
loop.max_part=15 on the command line (or set at module load time)
to make the loopback device see the partitions.

This commit removes a lot of differences between the ARM and x86
boot ramdisk and rc scripts. It changes the ARM build from running
from ramdisk to requiring a full filesystem on the SD image and
booting into it.

	. ramdisk: remove some arm-only utilities only used for running
	  from the shell
	. remove ARM-only rc.arm, proto.arm.small, ttys and mylogin.sh
	  boot-time ramdisk files
	. change kernel to add "arch" variable so userland knows what
	  we're running on from sysenv
	. make ARM use the regular ramdisk rc file, changed to distinguish
	  i386-only and ARM-only drivers; requires rootdevname to be set
	. change /etc/rc and /usr/etc/rc to start i386-only drivers only on
	  i386 systems
	. change the kernel/arm to have a special case for the memory
	  driver to load it higher so it can be bigger
	. add uEnv.txt, cmdline.txt and a for now highly linux-dependent
	  SD preparation script arm_sdimage.sh to the git repository in
	  releasetools/

Change-Id: I68910ba4e96ee80f7a12b65e48b5d39b43ca6397
2013-03-07 14:29:27 +00:00
Antoine Leca df04d571b1 Spanish keymap with tilde
and several small changes in keymaps, like cleaner
support for extended keypresses (those preceded with E0)
2013-03-06 18:13:46 +01:00
Lionel Sambuc 8f3fbf7cc1 Cleanup: Remove minix.bootprog.mk
The build system distinction between "bootprog" and "service" is
meaningless as boot programs are standard services.

As minix.service.mk simply imports minix.bootprog.mk, reduce confusion
by removing minix.bootprog.mk and placing the rules in minix.service.mk.

Change-Id: I4056b1e574bed59a8c890239b41b1a7c7cad63e8
2013-03-06 11:56:56 +01:00
Lionel Sambuc 46fcb04d36 Simplification in drivers/ramdisk
Periods are allowed in Make variable names, which let us simplify
a bit the Makefile.

Based on a proposition by Antoine LECA

Change-Id: I759d7dc7721905a4775e8ab28e0371e48a443f25
2013-02-27 11:35:01 +01:00
Lionel Sambuc f640210005 Removing obsolete _NBSD_LIBC define
Change-Id: Ia6ce84ccdf36cf6f64540b990baaa7d85c53533d
2013-02-26 09:44:24 +00:00
Lionel Sambuc 8e4736f2df Removing obsolete _MINIX define
Change-Id: Id33ac7e973d1c0e249b690fe44a597474fac6076
2013-02-26 09:44:20 +00:00
Thomas Veerman 67434e545b fb: use timeout instead of microdelay for restart logo
Change-Id: I1cb192aae502ed917e757cf17f67a9a355d0059a
2013-02-22 13:08:21 +00:00
Thomas Veerman ba49a155b5 fb: introduce framebuffer support to Minix
This patch introduces a framebuffer to Minix. It's written for the ARM
port of Minix, but has an architectural split that separates the
hardware dependent part from the non-hardware dependent part. Futhermore,
this driver was developed using a screen that has a native resolution of
1024x600 pixels and having lack of support for obtaining EDID from the
screen. Consequently, it uses a hardcoded resolution of 1024x600.

The driver uses an interface based on the Linux ioctl API, but supports
only a very limited subset.
2013-02-21 10:29:08 +00:00
David van Moolenbroek 972156d595 TTY: "nobeep" setting to disable beeps
Disable the speaker by passing in "nobeep=1" as a boot option.
The option is preserved when updating the boot configuration.
Currently i386 only.
2013-02-15 11:06:34 +01:00
David van Moolenbroek 09b729b328 rtl8169: reduce verbosity 2013-02-15 11:05:43 +01:00
David van Moolenbroek 91cea699bb rtl8169: add support for RTL8101E family
All cards in this family (RTL8101E, RTL8102E, RTL8103E, RTL8105E,
possibly others) should be recognized based on the added PCI ID.
The hardware version number of the RTL8105E has been added only to
serve as an example of a card that does not require modification of
certain undocumented registers.
2013-02-15 11:05:35 +01:00
Kees Jongenburger 6a290814ae mmc:Ignore SIGTERM if open count > 0
Change-Id: I996497335b4209ff7ef95dfa977d97e5557456e9
2013-02-14 10:20:21 +01:00
David van Moolenbroek 9d89e72a5c ahci: more robustness against flaky devices
- if supported, override BSY/DRQ flags and start the port anyway if it
  times out with DET=3h status during device detection;
- no longer rely on the device signature to be set; unless a valid
  signature is obtained, try both ATA and ATAPI device identification.
2013-02-13 14:29:44 +00:00
David van Moolenbroek eb89b33d39 ahci: device detection rewrite
- do not start a port before the BSY and DRQ flags have been cleared;
  as such, poll on device status rather than signature availability.
- change "ahci_sig_timeout" to "ahci_device_timeout" variable setting
  accordingly; this variable determines the polling duration before a
  newly attached device is given up on, and uses 30 seconds as default;
- use port connect changes (PCS/X/DET->1h) to kick off polling for an
  attached device; detachment is still detected by means of PhyRdy
  status changes (PRCS/N/DET<->3h).
2013-02-13 14:26:48 +00:00
David van Moolenbroek 23b12e29a2 ahci: rewrite timeout initialization code
- the "ahci_sig_timeout" variable now denotes the entire checking
  period, and the delay between checks has been hardcoded; what was
  previously "ahci_sig_checks" is now computed from those two;
- timeout values are no longer used for both millisecond and clock
  tick values, and better typed;
- the computation of timeouts is no longer off by half a second.
2013-02-12 13:53:09 +00:00
David van Moolenbroek ad0b58fe83 ahci: centralize, fix port reset 2013-02-12 13:52:52 +00:00
David van Moolenbroek f2de719cfe ahci: link FIS receive mode to memory allocation
There is no need to set/clear PxCMD.FRE on every port start/stop.

Also remove some already useless and now also incomplete port
reinitialization at startup.
2013-02-12 13:52:33 +00:00
David van Moolenbroek 3c55fcbc13 ahci: use macros to access HBA and port registers 2013-02-12 13:52:01 +00:00
Ben Gras 1f6e0c8fa6 drivers: build random for arm too
Change-Id: I801643281fdacc6cb7950cc79a29bec28dcf40ec
2013-02-09 17:13:16 +01:00
Ben Gras 46e7c7a920 ramdisk Makefile: CLEANFILES fix 2013-02-07 23:09:18 +01:00
Kees Jongenburger 3357fcb24a GPIO:further development
* Generalize GPIO handling.
* Add libs to configure gpio's clocks and pads
* Add Interrupt handling.
* Introduce mmio.h and log.h

Change-Id: I928e4c807d15031de2eede4b3ecff62df795f8ac
2013-02-06 16:07:43 +01:00
Lionel Sambuc af18db5668 Fix warning about double rule for rc in ramdisk
Change-Id: I870364455e5cbfe178b3dba44a1c944ca7ed9d19
2013-02-02 01:20:09 +01:00
Lionel Sambuc 5f59a986e2 Upgrading sync
Change-Id: Ied34ebd1d2dc963f5a2af8fc3bbf8e6c94df61cf
2013-02-02 01:20:09 +01:00
Lionel Sambuc b7ef8cfb52 Upgrading ls
Change-Id: Ie0bacf04e727fac5c6df7b2bcf5039e9ce800616
2013-02-02 01:20:09 +01:00
Kees Jongenburger 3de9b14567 mmc:development
* let busy loops timeout.
* Start using interrupt handlers.
* Allocate the ramdisk only when used.

Change-Id: Ie08d66eefef3c8cd3ee16c04f74a9a50cc12b021
2013-02-01 13:31:10 +01:00
Kees Jongenburger e641d42a37 gpio:Initial GPIO driver.(ARM)
Small GPIO driver that exports a few pins using a virtual file
system. Currently the two user leds and the user button are exported.

Change-Id: I001d017ae27cd17b635587873f7da981054da459
2013-01-28 15:51:20 +01:00
Antoine Leca da26ee9d09 Ramdisk: remove mtab, as now obsolete 2013-01-25 18:44:17 +01:00
Thomas Veerman 31c6dc292d Ramdisk: fix ramdisk creation for ARM 2013-01-25 17:07:02 +00:00
Thomas Veerman a5f7ba46f5 Also build and install log for ARM 2013-01-25 17:07:02 +00:00
Thomas Veerman 28b81f9c3b ramdisk: traditional-cpp does not work with clang 2013-01-23 11:14:33 +00:00
Joachim Henke eddc5dd581 ramdisk: add virtio-blk to proto and boot option 2013-01-23 09:03:03 +00:00
Arne Welzel d19844d69c virtio: virtio-net driver 2013-01-23 09:03:03 +00:00
Arne Welzel a27b60af75 virtio: virtio-blk driver 2013-01-23 09:03:03 +00:00
Joachim Henke ac11e38fd5 pci: add virtio pci device ids 2013-01-23 09:03:03 +00:00
Ben Gras 4c6c911fdc Replace previous change by different test
. so contents always get overwritten in out-of-tree case
2013-01-17 16:05:50 +00:00
Lionel Sambuc f0a513440d drivers/ramdisk/Makefile fixup
Change-Id: I481830f19b650ff0d93bf319ca4d8e901657b8f8
2013-01-17 15:54:48 +01:00
Lionel Sambuc b1c4ba4ab6 ARM updates
Due to the ABI we are using we have to use the earm architecture
moniker for the build system to behave correctly. This involves
then some headers to move around.

There is also a few related Makefile updates as well as minor
source code corrections.
2013-01-17 10:03:58 +01:00
Lionel Sambuc b86af8be0b Toolchain adaptation for ARM MINIX support 2013-01-17 10:03:58 +01:00
Lionel Sambuc f14fb60209 Libraries updates and cleanup
* Updating common/lib
 * Updating lib/csu
 * Updating lib/libc
 * Updating libexec/ld.elf_so
 * Corrected test on __minix in featuretest to actually follow the
   meaning of the comment.
 * Cleaned up _REENTRANT-related defintions.
 * Disabled -D_REENTRANT for libfetch
 * Removing some unneeded __NBSD_LIBC defines and tests

Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
2013-01-14 11:36:26 +01:00
Kees Jongenburger 65c5a092c1 ramdisk:add support for cross building a dso ramdisk.
Change-Id: Ib2840bceab10cf98cb0abfbdb2393af4d59be102
2013-01-13 17:00:13 +01:00
Kees Jongenburger aacce8f40c ramdisk:replace proto.sh by the c processor.
Replace proto.sh by the c processor to generate proto.gen in order
for us to have a more flexible way of selecting the files we want
in the ramdisk.

Change-Id: Id82b9f1b73b498c4d885bb3156fcefaeb9d157e0
2013-01-13 17:00:13 +01:00
Lionel Sambuc b0814fec4e Fix release.sh to work with NetBSD Build system.
Also fix a potential issue where host tools would be compiled
dynamically under MINIX.

This also updates proto.common.dynamic to use the new placement
of the dynamic libraries (/usr/lib)
2012-11-26 10:46:19 +01:00
Lionel Sambuc d19d7d58aa Toolchain upgrade and portability improvements.
upgrade to NetBSD CVS release from 2012/10/17 12:00:00 UTC

Makefiles updates to imporve portability

Made sure to be consistent in the usage of braces/parenthesis at
least on a per file basis. For variables, it is recommended to
continue to use braces.
2012-11-15 16:07:29 +01:00
Lionel Sambuc 9152e1c5a7 Upgrading build system to new NetBSD revision
The tested targets are the followgin ones:
 * tools
 * distribution
 * sets
 * release

The remaining NetBSD targets have not been disabled nor tested
*at all*. Try them at your own risk, they may reboot the earth.

For all compliant Makefiles, objects and generated files are put in
MAKEOBJDIR, which means you can now keep objects between two branch
switching. Same for DESTDIR, please refer to build.sh options.

Regarding new or modifications of Makefiles a few things:
 * Read share/mk/bsd.README
 * If you add a subdirectory, add a Makefile in it, and have it called
   by the parent through the SUBDIR variable.
 * Do not add arbitrary inclusion which crosses to another branch of
   the hierarchy; If you can't do without it, put a comment on why.
   If possible, do not use inclusion at all.
 * Use as much as possible the infrastructure, it is here to make
   life easier, do not fight it.

Sets and package are now used to track files.
We have one set called "minix", composed of one package called "minix-sys"
2012-11-15 16:07:29 +01:00
Ben Gras 62aac7f191 retire nonsymbolic rootdev, dev2name 2012-11-06 12:22:12 +01:00
David van Moolenbroek 71d5865b10 TTY: fix crash obtaining kernel messages
Also fix a case of potential message loss in TTY and LOG.
2012-11-06 00:17:44 +01:00
Thomas Veerman b01e9ebfdb TTY: seperate hardware dependent parts + add new serial driver
.Split TTY in order to support both x86 and ARM.
.Add support for the TI 16750 UARTs on OMAP35x.
.Various other improvements:
  .Kernel messages are printed using generic terminal write
   functions. That is, they are no longer directly displayed
   on the console.
  .The console can now be displayed on any terminal. This
   is configured by the "console={tty00,tty01,ttyc2,ttyc3,ttyc4}"
   boot variable -- basically any valid /dev/tty* terminal.
  .Cutify kernel messages with colors. Configured by
   "kernelclr={1,2,3,4,5,6,7}" boot variable.
2012-10-30 11:33:29 +00:00
David van Moolenbroek 7dd6189cc7 drivers: fix various sys_irqsetpolicy calls 2012-10-24 11:29:10 +00:00
Kees Jongenburger 9a5aca794e mmc:Fixes for coverity.
Change-Id: I25e406126deb9172276844e1bb756e22e1f449f8
2012-10-22 13:40:22 +02:00
Kees Jongenburger de291cdb60 mmc:driver development added dummy driver.
* Add dummy driver to allow independent testing of mmcblk.
* Always build the mmc driver to prevent breakage.
* Allow to specify the mmc driver to be used at load time.

Change-Id: I4e14b912fb8f3612e252864b53733968b23ac023
2012-10-19 14:55:03 +02:00
Kees Jongenburger 3fab01cdb2 mmc:Indenting and code cleanup.
Change-Id: Ia1156c6b5e4dbc6c8af37d61b118258053f347ce
2012-10-16 08:40:43 +02:00
Kees Jongenburger 2d5f58d5ef mmc:Small fixup to run the driver on hardware.
Change-Id: I8e8d048da7cdfce5c9f2091969b0db5240e3e89f
2012-10-16 08:40:43 +02:00
David van Moolenbroek d2be2e7b41 mmc: various small fixes
- call blockdriver_announce() on startup;
- restart statelessly after a crash;
- resolve a clang warning.
2012-10-15 11:50:58 +00:00
Mohamed Katri d21a633ffb mkfs.mfs: dynamically size image from proto 2012-10-12 15:13:43 +02:00
Kees Jongenburger 49246fcdd5 MMC driver.
Change-Id: I0d460d63070855df9b11eaf3d33eb7bb89c570f1
2012-10-08 09:11:17 +02:00
Kees Jongenburger 4fda063232 Import MMC related bsd headers.
Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>

Change-Id: Ia183d522a6ef1528b045a6fc6cd2e8930c669c32
2012-10-08 09:11:16 +02:00
Arne Welzel 362e4c37a1 memory: use sys_safememset() for /dev/zero 2012-09-26 02:18:00 +02:00
Thomas Veerman e61268c454 TTY: printer better diagnostics
.tell when a line is not initialized
.don't print when a request has failed, we use error codes for that
2012-09-25 09:07:09 +00:00
Ben Gras ed1af3c86c VM: full munmap
complete munmap implementation; single-page references made
a general munmap() implementation possible to write cleanly.

	. memory: let the MIOCRAMSIZE ioctl set the imgrd device
	  size (but only to 0)
	. let the ramdisk command set sizes to 0
	. use this command to set /dev/imgrd to 0 after mounting /usr
	  in /etc/rc, so the boot time ramdisk is freed (about 4MB
	  currently)
2012-09-18 13:17:52 +02:00
Ben Gras 2cb560297c VM: remove unused dma memory support functions from vm
. unused calls / data structures
2012-09-18 13:17:47 +02:00
Thomas Veerman 992799b91f VFS: make all IPC asynchronous
By decoupling synchronous drivers from VFS, we are a big step closer to
supporting driver crashes under all circumstances. That is, VFS can't
become stuck on IPC with a synchronous driver (e.g., INET) and can
recover from crashing block drivers during open/close/ioctl or during
communication with an FS.

In order to maintain serialized communication with a synchronous driver,
the communication is wrapped by a mutex on a per driver basis (not major
numbers as there can be multiple majors with identical endpoints). Majors
that share a driver endpoint point to a single mutex object.

In order to support crashes from block drivers, the file reopen tactic
had to be changed; first reopen files associated with the crashed
driver, then send the new driver endpoint to FSes. This solves a
deadlock between the FS and the block driver;
  - VFS would send REQ_NEW_DRIVER to an FS, but he FS only receives it
    after retrying the current request to the newly started driver.
  - The block driver would refuse the retried request until all files
    had been reopened.
  - VFS would reopen files only after getting a reply from the initial
    REQ_NEW_DRIVER.

When a character special driver crashes, all associated files have to
be marked invalid and closed (or reopened if flagged as such). However,
they can only be closed if a thread holds exclusive access to it. To
obtain exclusive access, the worker thread (which handles the new driver
endpoint event from DS) schedules a new job to garbage collect invalid
files. This way, we can signal the worker thread that was talking to the
crashed driver and will release exclusive access to a file associated
with the crashed driver and prevent the garbage collecting worker thread
from dead locking on that file.

Also, when a character special driver crashes, RS will unmap the driver
and remap it upon restart. During unmapping, associated files are marked
invalid instead of waiting for an endpoint up event from DS, as that
event might come later than new read/write/select requests and thus
cause confusion in the freshly started driver.

When locking a filp, the usage counters are no longer checked. The usage
counter can legally go down to zero during filp invalidation while there
are locks pending.

DS events are handled by a separate worker thread instead of the main
thread as reopening files could lead to another crash and a stuck thread.
An additional worker thread is then necessary to unlock it.

Finally, with everything asynchronous a race condition in do_select
surfaced. A select entry was only marked in use after succesfully sending
initial select requests to drivers and having to wait. When multiple
select() calls were handled there was opportunity that these entries
were overwritten. This had as effect that some select results were
ignored (and select() remained blocking instead if returning) or do_select
tried to access filps that were not present (because thrown away by
secondary select()). This bug manifested itself with sendrecs, but was
very hard to reproduce. However, it became awfully easy to trigger with
asynsends only.
2012-09-17 11:01:45 +00:00
Ben Gras d69cc76e03 rename struct mem_range to minix_mem_range
. avoid a name clash with gdb
2012-08-15 15:17:25 +02:00
David van Moolenbroek 4aec9db571 dp8390: resolve Coverity warnings (encore) 2012-08-14 09:11:18 +00:00
David van Moolenbroek bc404a9401 TTY: resolve Coverity warnings 2012-08-14 09:11:17 +00:00
David van Moolenbroek 533f61249b random: resolve Coverity warnings 2012-08-14 09:11:16 +00:00
Arun Thomas 93eadc7040 Make memory driver arch-neutral
-Use PAGE_SIZE instead of I386_PAGE_SIZE
-No need to grant ioport access for ARM
2012-08-13 17:21:47 +02:00
David van Moolenbroek cff95276d9 pci: resolve Coverity warnings
Or rather, slightly improve the code based on a false positive.
2012-08-06 16:18:40 +00:00
David van Moolenbroek 2289c91010 lance: resolve Coverity warnings 2012-08-06 16:18:39 +00:00
David van Moolenbroek 431cd9f69c fxp: resolve Coverity warnings
This removes some unused and unsupported features, and leaves in support
for another currently unused feature that might be used in the future.
2012-08-06 16:18:38 +00:00
David van Moolenbroek c984359bb0 floppy: resolve Coverity warnings 2012-08-06 16:18:37 +00:00
David van Moolenbroek 4f877afeb6 e1000: resolve Coverity warnings 2012-08-06 16:18:36 +00:00
David van Moolenbroek 6199f090c8 dpeth: resolve Coverity warnings 2012-08-06 16:18:35 +00:00
David van Moolenbroek 6e3824d78b dp8390: resolve Coverity warnings 2012-08-06 16:18:34 +00:00
David van Moolenbroek ab6e62a523 dec21140A: resolve Coverity warnings 2012-08-06 16:18:33 +00:00
Arun Thomas 19ffad7692 Remove ACK EM_WSIZE/EM_PSIZE macro usage 2012-08-06 17:49:22 +02:00
Arun Thomas 6723dcfab7 Replace MACHINE/CHIP macros with compiler macros 2012-08-06 17:49:22 +02:00
David van Moolenbroek 90e2b939ab rtl8139: resolve Coverity warnings 2012-07-30 13:59:43 +00:00
David van Moolenbroek e34f611be3 rtl8169: resolve Coverity warnings 2012-07-30 12:10:15 +00:00
David van Moolenbroek db7a45926b filter: resolve Coverity warnings 2012-07-30 12:10:11 +00:00
David van Moolenbroek da915d36b7 atl2: resolve Coverity warnings 2012-07-30 12:10:10 +00:00
David van Moolenbroek 0ae9652177 at_wini: resolve Coverity warnings 2012-07-30 12:10:09 +00:00
David van Moolenbroek d75ef5a05c ahci: resolve Coverity warnings 2012-07-30 12:10:08 +00:00
Ben Gras b6ea15115c kernel: facility for user-visible memory
. map all objects named usermapped_*.o with globally visible
	  pages; usermapped_glo_*.o with the VM 'global' bit on, i.e.
	  permanently in tlb (very scarce resource!)
	. added kinfo, machine, kmessages and loadinfo for a start
	. modified log, tty to make use of the shared messages struct
2012-07-28 20:57:38 +00:00
David van Moolenbroek 8caec1b57b libsys: 64-bit numbers support for printf()
Change some drivers accordingly.
2012-07-26 09:45:05 +00:00
Ben Gras cbcdb838f1 various coverity-inspired fixes
. some strncpy/strcpy to strlcpy conversions
	. new <minix/param.h> to avoid including other minix headers
	  that have colliding definitions with library and commands code,
	  causing parse warnings
	. removed some dead code / assignments
2012-07-16 14:00:56 +02:00
Ben Gras 50e2064049 No more intel/minix segments.
This commit removes all traces of Minix segments (the text/data/stack
memory map abstraction in the kernel) and significance of Intel segments
(hardware segments like CS, DS that add offsets to all addressing before
page table translation). This ultimately simplifies the memory layout
and addressing and makes the same layout possible on non-Intel
architectures.

There are only two types of addresses in the world now: virtual
and physical; even the kernel and processes have the same virtual
address space. Kernel and user processes can be distinguished at a
glance as processes won't use 0xF0000000 and above.

No static pre-allocated memory sizes exist any more.

Changes to booting:
        . The pre_init.c leaves the kernel and modules exactly as
          they were left by the bootloader in physical memory
        . The kernel starts running using physical addressing,
          loaded at a fixed location given in its linker script by the
          bootloader.  All code and data in this phase are linked to
          this fixed low location.
        . It makes a bootstrap pagetable to map itself to a
          fixed high location (also in linker script) and jumps to
          the high address. All code and data then use this high addressing.
        . All code/data symbols linked at the low addresses is prefixed by
          an objcopy step with __k_unpaged_*, so that that code cannot
          reference highly-linked symbols (which aren't valid yet) or vice
          versa (symbols that aren't valid any more).
        . The two addressing modes are separated in the linker script by
          collecting the unpaged_*.o objects and linking them with low
          addresses, and linking the rest high. Some objects are linked
          twice, once low and once high.
        . The bootstrap phase passes a lot of information (e.g. free memory
          list, physical location of the modules, etc.) using the kinfo
          struct.
        . After this bootstrap the low-linked part is freed.
        . The kernel maps in VM into the bootstrap page table so that VM can
          begin executing. Its first job is to make page tables for all other
          boot processes. So VM runs before RS, and RS gets a fully dynamic,
          VM-managed address space. VM gets its privilege info from RS as usual
          but that happens after RS starts running.
        . Both the kernel loading VM and VM organizing boot processes happen
	  using the libexec logic. This removes the last reason for VM to
	  still know much about exec() and vm/exec.c is gone.

Further Implementation:
        . All segments are based at 0 and have a 4 GB limit.
        . The kernel is mapped in at the top of the virtual address
          space so as not to constrain the user processes.
        . Processes do not use segments from the LDT at all; there are
          no segments in the LDT any more, so no LLDT is needed.
        . The Minix segments T/D/S are gone and so none of the
          user-space or in-kernel copy functions use them. The copy
          functions use a process endpoint of NONE to realize it's
          a physical address, virtual otherwise.
        . The umap call only makes sense to translate a virtual address
          to a physical address now.
        . Segments-related calls like newmap and alloc_segments are gone.
        . All segments-related translation in VM is gone (vir2map etc).
        . Initialization in VM is simpler as no moving around is necessary.
        . VM and all other boot processes can be linked wherever they wish
          and will be mapped in at the right location by the kernel and VM
          respectively.

Other changes:
        . The multiboot code is less special: it does not use mb_print
          for its diagnostics any more but uses printf() as normal, saving
          the output into the diagnostics buffer, only printing to the
          screen using the direct print functions if a panic() occurs.
        . The multiboot code uses the flexible 'free memory map list'
          style to receive the list of free memory if available.
        . The kernel determines the memory layout of the processes to
          a degree: it tells VM where the kernel starts and ends and
          where the kernel wants the top of the process to be. VM then
          uses this entire range, i.e. the stack is right at the top,
          and mmap()ped bits of memory are placed below that downwards,
          and the break grows upwards.

Other Consequences:
        . Every process gets its own page table as address spaces
          can't be separated any more by segments.
        . As all segments are 0-based, there is no distinction between
          virtual and linear addresses, nor between userspace and
          kernel addresses.
        . Less work is done when context switching, leading to a net
          performance increase. (8% faster on my machine for 'make servers'.)
	. The layout and configuration of the GDT makes sysenter and syscall
	  possible.
2012-07-15 22:30:15 +02:00
Thomas Veerman 39dfb2bc55 Don't build ext2 ramdisk for cross compilation
. as mkfs.mfs is now cross compilable, we can remove the ext2 ramdisk
  special case for cross compilation.
2012-06-18 10:54:56 +00:00
Thomas Veerman aab6eb7615 Clean up generated files for ash,ramdisk,libutil,libc 2012-06-18 10:54:56 +00:00
Thomas Veerman 791aa4e16f Cross compile MFS ramdisk 2012-06-18 10:54:55 +00:00
Thomas Veerman 03ea1c1676 Dynamically determine which ramdisk to use
.Also, rename ext2_ramdisk to ramdisk_ext2.
2012-06-18 10:53:36 +00:00
Thomas Veerman f09c2e014f Use MACHINE_ARCH instead of ARCH 2012-06-18 10:53:35 +00:00
Thomas Veerman f93afa00e9 Remove MINIXSRCDIR and use NETBSDSRCDIR
NETBSDSRCDIR is used all over the place anyway, and this reduces
our diff with NetBSD a little.
2012-06-18 10:53:35 +00:00
Thomas Veerman d1301b26b3 Use buildsystem commands instead of {cp,mkdir} 2012-06-18 10:53:33 +00:00
Thomas Veerman acac1f2fda Cross-compilation fixes
. Some Makefile fixes to automatically differentiate between a normal
  compilation and cross-compilation. Also, build compressed images.
. Harmonize ramdisk rc scripts for normal use case and ext2 ramdisk.
. ext2_ramdisk filesystem prototype fixes.
2012-06-18 10:53:32 +00:00
Thomas Veerman 0bcc4c15c9 newroot is gone too 2012-06-18 10:53:31 +00:00
Thomas Veerman d0c7c2a5d2 bios_wini is no longer amongst us 2012-06-18 10:53:31 +00:00
Dirk Vogt 67ff0d71ed ext2 ramdisk: copy rc to correct destination 2012-06-18 10:53:28 +00:00
Dirk Vogt 56f6a77ead ramdisk: don't do anything at dependall 2012-06-18 10:53:27 +00:00
Dirk Vogt ed4df03113 Include ext2 ramdisk in build and remove sync
As the ramdisk and ext2 ramdisk don't build anything for the install
and all targets, memory does not have to wait for them anymore.
2012-06-18 10:53:26 +00:00
Dirk Vogt bfacef76c5 Add ext2 ramdisk, intended for cross compilation 2012-06-18 10:53:25 +00:00
Dirk Vogt a8f6f3ebc9 Make ramdisk location configurable
Also, the ramdisk is now built when the memory driver is compiled.
2012-06-18 10:53:25 +00:00
Dirk Vogt c2c39af6bb Make TTY cross-compilable 2012-06-18 10:53:23 +00:00
Ben Gras 2bfeeed885 drop segment from safecopy invocations
. all invocations were S or D, so can safely be dropped
	  to prepare for the segmentless world
	. still assign D to the SCP_SEG field in the message
	  to make previous kernels usable
2012-06-16 16:22:51 +00:00
Ben Gras 73379f0be5 set major version of shlibs to 0
WARNING: this will break existing dynamically linked binaries if they
exist. If you have any:
	. re-build world statically first if necessary
	. remove libraries from /lib and /usr/lib
	. then build world

This change:
	. avoids possible future dismay when interfacing other
	  systems' binaries; done until they are abi-compatible

Thanks to Antoine Leca for pointing this out.
2012-05-10 16:38:24 +02:00
Ben Gras cfb2d7bca5 retire BIOS_SEG and umap_bios
. readbios call is now a physical copy with range check in
	  the kernel call instead of BIOS_SEG+umap_bios
	. requires all access to physical memory in bios range to go
	  through sys_readbios
	. drivers/dpeth: wasn't using it
	. adjusted printer
2012-05-09 19:03:59 +02:00
Ben Gras b611e4c226 brazilian keymap
contributed by David Augusto.
2012-05-04 13:56:04 +02:00
Ben Gras b332803b6f release fixes
. make ramdisk buildable without ../etc having pwd.db
	. add cat to release bootstrap cmds
	. support running dynamically linked executables for
	  release bootstrap cmds
	. import netbsd chroot to help
2012-04-17 16:58:58 +02:00
Ben Gras 53f94f8ed4 dynamic executables on ramdisk support
See UPDATING about upgrading clang for dynamic linking.

	. allow executables on ramdisk to be dynamically linked; this means
	  putting a few required shared libraries and ld.elf_so on the ramdisk.
	. this makes the ramdisk (usage) smaller when they are dynamic, but
	  bigger when they're not.
	. also we can safely ditch newroot and call mount directly as that is
	  all newroot does.
	. create proto.common to share a bunch of entries between
	  small/nonsmall cases
2012-04-16 14:06:09 +02:00
Ben Gras 4b999f1962 build shared versions of libraries
building defaults to off until clang is updated.

current clang does not handle -shared, necessary to change the ld
invocation to build shared libraries properly. a new clang should be
installed and MKPIC defaults to no unless the newer clang is detected.

changes:

	. mainly small imports of a Makefile or two and small fixes
	  (turning things back on that were turned off in Makefiles)
	. e.g.: dynamic librefuse now depends on dynamic
	  libpuffs, so libpuffs has to be built dynamically too
	  and a make dependency barrier is needed in lib/Makefile
	. all library objects now have a PIC (for .so) and non-PIC
	  version, so everything is built twice.
	. generate PIC versions of the compat (un-RENAMEd) jump files,
	  include function type annotation in generated assembly
	. build progs with -static by default for now
	. also build ld.elf_so
	. also import NetBSD ldd
2012-04-16 05:21:20 +02:00
Thomas Veerman ca7a466f48 TTY: don't allow multiple readers on tty minor
TTY has no way of keeping track of multiple readers for a tty minor
device. Instead, it stores a read request for the last reader only.
Consequently, the first ("overwritten") reader gets stuck on a read
request that's never going to be finished. Also, the overwriting
causes a grant mismatch in VFS when TTY returns a reply for the
second reader.

This patch is a work around for the actual problem (i.e., keeping track
of multiple readers). It checks whether there is a read operation in
progress and returns an error if it is --preventing that reader from
getting overwritten and stuck. It fixes a bug triggered by executing
'top | more' and pressing the space bar for a while (easily reproducable
in a VM, not on hardware).
2012-04-13 13:22:13 +00:00
Ben Gras 511c977f93 retire bios_wini 2012-04-12 03:02:21 +02:00
David van Moolenbroek 6aa61efd09 VBOX: add host/guest communication interface
This interface can be used by other system processes by means of the
newly provided vbox API in libsys.
2012-04-09 15:56:20 +02:00
David van Moolenbroek fa805ebd1e Kernel/servers/drivers: resolve a few warnings
Flagged by clang 3.1.
2012-03-30 16:55:06 +02:00
Ben Gras 7336a67dfe retire PUBLIC, PRIVATE and FORWARD 2012-03-25 21:58:14 +02:00
Ben Gras 6a73e85ad1 retire _PROTOTYPE
. only good for obsolete K&R support
	. also remove a stray ansi.h and the proto cmd
2012-03-25 16:17:10 +02:00
David van Moolenbroek 186a4db672 ahci: use sys_vumap() instead of sys_umap()
This is only an optimization for CPU performance. Callers are
currently still required to supply contiguous memory.
2012-03-24 19:51:13 +01:00
David van Moolenbroek e8d2d2f6b6 libminc-related updates
- add files needed for acpi, ahci, fbd, vfs to libminc
- remove "-lc" from their respective makefiles
- remove setenv from libminc (requires initialization)
2012-03-12 23:16:45 +01:00
David van Moolenbroek 457d3884a2 pci: apply ACLs to device reservations 2012-03-08 23:52:17 +01:00
David van Moolenbroek e21c21a31a pci: USER_SPACE cleanup 2012-03-08 23:52:13 +01:00