work-3.2.1 squash commit
Squashed commit of the following:
commit 8fcdd34f87fe9daaac235315d3b6e1d4986ea0ed
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Nov 5 14:26:57 2013 +0100
Fix for ramdisk generation (?)
Change-Id: If7fd55d9a146d7d7b621da274ac0472a5b246c36
commit 5ffd24ad49bff556adceb050c7cbfddd774ed200
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Nov 5 13:16:56 2013 +0100
Rebase fixes
Too lazy to merge this into the appropriate patch.
Change-Id: I66505d6a0d65330656e78ec9615a026f892b8609
commit 0240220770e6cc18fe16bd0c82e6e5e2c88a4301
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Oct 6 15:58:54 2013 +0200
VFS: further cleanup of device code
- all TTY-related exceptions have now been merged into the regular
code paths, allowing non-TTY drivers to expose TTY-like devices;
- as part of this, CTTY_MAJOR is now fully managed by VFS instead of
being an ugly stepchild of the TTY driver;
- device styles have become completely obsolete, support for them has
been removed throughout the system; same for device flags, which had
already become useless a while ago;
- device map open/close and I/O function pointers have lost their use,
thus finally making the VFS device code actually readable;
- the device-unrelated pm_setsid has been moved to misc.c;
- some other small cleanup-related changes.
Change-Id: If90b10d1818e98a12139da3e94a15d250c9933da
commit 07d10dc91955475340005fa86adf71aa981712c8
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 14:59:59 2013 +0200
IS: dump number of in-use FDs for VFS
Change-Id: If0e2092d5a8c384c31b1f44cc0591bb119c6d8de
commit ced39723e3e7c39a4a2ef516834702a36a6a26c8
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 01:40:58 2013 +0200
TTY: fix earlier PTY select "improvement"
It was just plain wrong.
Change-Id: Ieab4b4f01d9461e05e0d0ba6427a99d863d6b98d
commit a4a63c15cc5f9daf2e149b84ec930834fe24a983
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 16:31:35 2013 +0200
Extend dupfrom(2) into copyfd(2)
This single function allows copying file descriptors from and to
processes, and closing a previously copied remote file descriptor.
This function replaces the five FD-related UDS backcalls. While it
limits the total number of in-flight file descriptors to OPEN_MAX,
this change greatly improves crash recovery support of UDS, since all
in-flight file descriptors will be closed instead of keeping them
open indefinitely (causing VFS to crash on system shutdown). With the
new copyfd call, UDS becomes simpler, and the concept of filps is no
longer exposed outside of VFS.
This patch also moves the checkperms(2) stub into libminlib, thus
fully abstracting away message details of VFS communication from UDS.
Change-Id: Idd32ad390a566143c8ef66955e5ae2c221cff966
commit 663e0abb01990da768f1701df6366a4d3bbd67c1
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 12:50:44 2013 +0200
VFS: better dupfrom(2) deadlock detection
Change-Id: I29f00075698888c7c8ca60b47ab82fba8c606f4e
commit 54c509663718cc109b0f11ab0adc196bfa82015b
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 21:10:01 2013 +0200
UDS: sendmsg/recvmsg fixes
- sendmsg: the accumulation of multiple in-flight file descriptors was
already described in the comments; now the code actually does what
the comments say :) -- also, added robustness in case of a failure;
- recvmsg: only create a socket rights message if there are file
descriptors pending at all;
- recvmsg: copy back the control message length;
- recvmsg: use CMSG_SPACE instead of CMSG_LEN to compute sizes.
Not sure if all of this is now working according to specification,
but at least tmux seems to be happy with it.
Change-Id: I8d076c14c3ff3220b7fea730e0f08f4b4254ede5
commit b0a891c329d721eb84e06ecac803789fe8197306
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 18:41:21 2013 +0200
UDS: add support for FIONREAD
Change-Id: I50030012b408242a86f8c55017429acdadff49d1
commit e81d59c874d57d0d0010d3b1ace2351d01f66766
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 18:00:42 2013 +0200
UDS: align struct sockaddr_un with NetBSD
Well, make a start, anyway. Our copy was missing a legacy field from
the structure, that could very well cause applications to fail trying
to set, clear, or check it. As a consequence, SUN_LEN now yields the
same result as on NetBSD.
Change-Id: I80f6aff7769be402b3bd3959f64d314509ed138c
commit 66f8ad9ac7f0e008cdf416877eeab63ed599477d
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 17:57:42 2013 +0200
UDS: support for nonblocking sockets
This patch includes several other fixes, which are now tested in the
test56 test set.
Change-Id: I9535d5a6c072abf966252838522c5f65b353c6c2
commit 9b4a7ba7ced0b40bf650451ec7baf2935b2ccfe7
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 16:46:18 2013 +0200
UDS: clean up source code
- move VFS calls to a separate source file;
- solve a few subtle bugs, mostly in error handling;
- simplify debug reporting code;
- make a few definitions more independent;
- restyle to something closer to KNF.
Change-Id: I7b0537adfccac8b92b5cc3e78dac9f5ce3c79f03
commit 881641da1fa711d2d4bf8687cb5beb843801daf8
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Oct 4 16:29:40 2013 +0200
UDS: split off from PFS
Change-Id: I769cbd64aa6e5e85a797caf0f8bbb4c20e145263
commit 2baef79e569c4cebda1a3f831b8e329295e449e6
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Oct 2 19:37:00 2013 +0200
at_wini: PCI-only now; one controller per instance
- remove non-PCI support, since all supported platforms with at_wini
devices also have PCI support by now;
- correspondingly, stop using information from the BIOS altogether;
- limit each driver instance to one controller, to be in line with
the general MINIX3 one-instance-per-controller driver model; this
limits the number of disks per at_wini instance to four;
- go through the controllers by the order of their occurrence in the
PCI table, thus removing the exception for compatibility devices;
- let the second at_wini instance shut down silently if there is only
one IDE controller;
- clean up some extra code we don't need anymore, and resolve some
WARNS=5 level warnings.
Overall, these changes should simplify automatic loading of the right
disk drivers at boot time in the future.
Change-Id: Ia64d08cfbeb9916abd68c9c2941baeb87d02a806
commit f7aaabe7e0ae93b439b02d3c21c38f11bae7bbcf
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Oct 1 00:42:41 2013 +0200
system.conf: subsystem VID/DID matching support
- change "vid/did" to "vid:did", old form still supported for now;
- allow "vid:did/subvid:subdid" specification in system.conf, in
which case a device will be visible to a driver if the subsystem
VID/DID also match.
Change-Id: I7aef54da1b0bc81e24b5d98f1a28416f38f8b266
commit 178d896a32140285e7e9f00dba7bb4a871752f60
Author: Lionel Sambuc <lionel@minix3.org>
Date: Tue Oct 8 19:00:16 2013 +0200
usr.bin/man: Update
Change-Id: I0c5d2115ba384687032f7b2af50d99dedc323b7a
commit 33e8e00217bbf38300f266dda5a494ad4e51bebd
Author: Lionel Sambuc <lionel@minix3.org>
Date: Tue Oct 8 18:05:29 2013 +0200
external/bsd/mdocml: Update
Change-Id: I17b54e52e8322676d83ed4386f586f8ef3029f72
commit e28c0794f18eae77faf3055dadbe76a963242c4e
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Oct 3 18:26:21 2013 +0200
Adapting build system to call MAKEDEV for /dev
* Remove static proto.dev
* Update releasetools/*image.sh not to use proto.dev, as well as
minor comments cleanup
* Add TOOL_TOPROTO
Change-Id: If7dc16d4ebb3b0c4e859786fad25d4af000c999f
commit d26b8149f47461aac67078b8a63ddae21ecdf4f8
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Oct 3 13:54:24 2013 +0200
MAKEDEV: Add mtree output, and ramdisk set.
Change-Id: I36cb7e9451960189a33a04a5c2e3ddb19c7be75e
commit 8dc3249c2ec209689922abb306b0e3d15e6a0347
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 20:24:25 2013 +0200
3.3.0 sync fixes
Keeping this version at 3.2.1 though, mainly for pkgsrc.
Change-Id: Ic91e326623f6dbad58754152c4a632e4406f1117
commit f61a525630a33734481bfd8f0994ae33fef6c3fb
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Oct 2 13:37:49 2013 +0200
keymaps: improve keypad slash support
Now that the keymaps can distinguish between the regular slash key
and the slash key on the numeric keypad, we can avoid localization
of the latter.
Change-Id: I20ead7d26a9baa82f5a522562524fd75d44efb42
commit 81e1e0e8e10c08459af9b7d24f51eff41225b62d
Author: Mikal Villa <mikal.villa@gmail.com>
Date: Wed Oct 2 12:30:03 2013 +0200
Norwegian keymap
Change-Id: I181234afc8f1a058e92af6c1fe88979463aaff45
commit c9fc72ef1769f677ad6c932e84959f8756b32264
Author: Thomas Cort <tcort@minix3.org>
Date: Fri Sep 6 21:40:42 2013 -0400
Importing usr.bin/uname
Change-Id: I4c316221e288edd839e26a2af4cb59f28bf722c1
commit 320e18fd3269219d4b68ba0df3ff8f8434a24a09
Author: Thomas Cort <tcort@minix3.org>
Date: Fri Sep 6 21:40:31 2013 -0400
uname: normalize release and version
Most systems provide the full version number in the
'release' field and the kernel version in 'version'.
Minix used to split the full version number between
release and version which caused problems for pkgsrc
and other applications. This patch brings Minix's
uname in line with other systems such as NetBSD.
It also brings the getty banner in line with NetBSD.
Old Minix uname:
sysname->Minix
nodename->10.0.2.15
release->3
version->2.1
machine->i686
New Minix uname:
sysname->Minix
nodename->10.0.2.15
release->3.2.1
version->Minix 3.2.1 (GENERIC)
machine->i686
Change-Id: I966633dfdcf2f9485966bb0d0d042afc45bbeb7d
commit 3840323699856b0ab67b3c6c3b79695acc25ffcb
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Sep 19 10:57:10 2013 +0200
Replacing timer_t by netbsd's timer_t
* Renamed struct timer to struct minix_timer
* Renamed timer_t to minix_timer_t
* Ensured all the code uses the minix_timer_t typedef
* Removed ifdef around _BSD_TIMER_T
* Removed include/timers.h and merged it into include/minix/timers.h
* Resolved prototype conflict by renaming kernel's (re)set_timer
to (re)set_kernel_timer.
Change-Id: I56f0f30dfed96e1a0575d92492294cf9a06468a5
commit 23906ce75094c89071c04c6a2a2da780d5d1d9d1
Author: Lionel Sambuc <lionel@minix3.org>
Date: Wed Oct 2 10:56:24 2013 +0200
ARM serial driver: Comment termios_baud_rate.
The B0-B115200 defines are flags, and not the actual speed they
represent.
This fixes an incoherency for B0 handling, and documents why it is
required to call the function again after changing the speed flag.
DFL_BAUD is set to one of the flag, so to translate it to an actual
speed, the function calls itself again, which will always be able to
finish without inducing another recursive call.
Change-Id: I04ebfaefee31a88d05f0b726352d1581a966147b
commit 92db382b054926bc494cf369731e67af91033cc8
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Oct 1 23:25:01 2013 +0200
TTY: skip /dev/log checks if console is serial
It is unclear why /dev/log has its own open/close rules, but those
rules conflict with serial console redirection. This does not solve
the root of the problem, but it puts back in place more or less the
same workaround that was already in place before the TTY overhaul.
Change-Id: Ib53abbc28a76c1f2b0befc8448aeed0173bc96a5
commit f1b6f94f744e82b0a4f0fbe8967a4986e079c7cd
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 19:45:42 2013 +0200
Corrections to keep VFS ABI-compatible
Change-Id: Id8a53a687577c1b6f83c11c2e5fb0b8ed1cd2a08
commit 1d9f12eec8edb0ed8b9bc3cb05eb342d6e4ffb03
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 19:35:11 2013 +0200
Remove support for obsolete 3.2.1 ABI
Change-Id: I76b4960bda41f55d9c42f8c99c5beae3424ca851
commit 93267010fcf5a6de5bc4ea511e1edab09c2362aa
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Aug 31 22:59:44 2013 +0200
Fix various file system warnings
Change-Id: Ied10498c3ae14f9f2fd06914f23239df330fa296
commit 42a4fca69efd41f11d28e5b4a4df45c3a14ea91f
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 19:22:13 2013 +0200
VFS/FS: replace protocol version with flag field
The main motivation for this change is that only Loris supports
multithreading, and Loris supports dynamic thread allocation, so the
number of supported threads can be implemented as a bit flag (i.e.,
either 1 or "at least as many as VFS has"). The ABI break obviates the
need to support file system versioning at this time, and several
other aspects are better implemented as flags as well. Other changes:
- replace peek/bpeek test upon mount with FS flag as well;
- mark libsffs as 64-bit file size capable;
- remove old (3.2.1) getdents support.
Change-Id: I313eace9c50ed816656c31cd47d969033d952a03
commit 6237d4580b2e7f4ca37222581c44f3898a9f2985
Author: Lionel Sambuc <lionel@minix3.org>
Date: Fri Apr 19 13:16:51 2013 +0200
usr.bin/stat Update
Change-Id: I029160c73baab1b3465bc5397a36c55886db225b
commit 9e7f974e9fa61e0e1d9cb519a69155eb71826f9d
Author: Lionel Sambuc <lionel@minix3.org>
Date: Fri Apr 19 09:54:51 2013 +0200
almost aligned ioctl prototype
Change-Id: I7f3eaa99d2a9767f71e8387cea5c7f56dcb28f99
commit b1a9440566584280bd07c6e646bb18d5b8133786
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Apr 18 14:42:15 2013 +0200
32 to 64 bits fsblkcnt_t and fsfilcnt_t.
Change-Id: I432229143c85cd178262b802a76ac606801ac59a
commit 8dea53df7843cf4a96601e019f941e7d13a878c0
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Apr 18 11:08:16 2013 +0200
moving prototypes to lib.h
Change-Id: If53d3f5ee761b10e0f3d4346a0c5b39ba7901c65
commit 0d00df150181bcc7ee20726801bbc34ebe978a29
Author: Lionel Sambuc <lionel@minix3.org>
Date: Thu Apr 18 11:07:44 2013 +0200
struct uucred
Change-Id: Ia97cb6c38bb566be30d568a252ae7b76142a21dd
commit 1e355e9d217877943e01c5b8859d66258e54b3e5
Author: Lionel Sambuc <lionel@minix3.org>
Date: Tue Apr 16 11:48:54 2013 +0200
Alignement on netbsd types, part 1
The following types are modified (old -> new):
* _BSD_USECONDS_T_ int -> unsigned int
* __socklen_t __int32_t -> __uint32_t
* blksize_t uint32_t -> int32_t
* rlim_t uint32_t -> uint64_t
On ARM:
* _BSD_CLOCK_T_ int -> unsigned int
On Intel:
* _BSD_CLOCK_T_ int -> unsigned long
bin/cat is also updated in order to fix warnings.
_BSD_TIMER_T_ has still to be aligned.
Change-Id: I2b4fda024125a19901120546c4e22e443ba5e9d7
commit e7b39757eac1ab7aac5a59d7aa124fc316a6e01f
Author: Lionel Sambuc <lionel@minix3.org>
Date: Fri Aug 23 20:27:27 2013 +0200
Adapt the type used for adjtime_delta
clock_t is currently a signed type, but in NetBSD this is not the
case. As we plan on aligning our types we have to change this as this
prevents negative delta from being correctly used.
Change-Id: I9bccdee2b41626b0262471dc1900de505a1991a7
commit 5a551dbe663b22760632c5232326e4101360b330
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 19:01:19 2013 +0200
Butchered version of "Bumping version.."
Change-Id: Ieb5f31fe037bcf45cc86a906f983a0ab3f636468
commit 6d601ae1d7072a8fb6cd908ff1d24ea4ca9bf1b0
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 18:57:04 2013 +0200
Trimmed version of "VFS: use 64-bit file..."
Change-Id: I1b53ef05e939f6afed97f507d443a1d60ed81a21
commit 7adaa6556051b3800670399ee26d246fa9f32486
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Oct 5 18:37:39 2013 +0200
Trimmed version of "stat.h: remove some big_ types"
Change-Id: I6c17d6e5e9d2ab4c1bbf33e461cec4c37b870266
commit 3da9bd17116b66416e8e10ce148599b8ea723680
Author: Thomas Veerman <thomas@minix3.org>
Date: Thu Mar 7 14:46:21 2013 +0000
Define protocol version of {mode,ino,uid,gid}_t
Change-Id: Ia2027749f2ce55a561d19eb895a5618505e9a2ac
commit 6ca17cd644c3b3e4f318faf7d1242855af473b6f
Author: Thomas Veerman <thomas@minix3.org>
Date: Mon Mar 25 21:09:10 2013 +0000
VFS-FS protocol: add versioning
Change-Id: Ice6fbfd4b535b7435653fa08b27a3378d1cfdbf8
commit a7ff601df7d61c0925241ce10aee3a7e99343b3a
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Sep 28 14:46:21 2013 +0200
Input infrastructure, INPUT server, PCKBD driver
This commit separates the low-level keyboard driver from TTY, putting
it in a separate driver (PCKBD). The commit also separates management
of raw input devices from TTY, and puts it in a separate server
(INPUT). All keyboard and mouse input from hardware is sent by drivers
to the INPUT server, which either sends it to a process that has
opened a raw input device, or otherwise forwards it to TTY for
standard processing.
Design by Dirk Vogt. Prototype by Uli Kastlunger.
Additional changes made to the prototype:
- the event communication is now based on USB HID codes; all input
drivers have to use USB codes to describe events;
- all TTY keymaps have been converted to USB format, with the effect
that a single keymap covers all keys; there is no (static) escaped
keymap anymore;
- further keymap tweaks now allow remapping of literally all keys;
- input device renumbering and protocol rewrite;
- INPUT server rewrite, with added support for cancel and select;
- PCKBD reimplementation, including PC/AT-to-USB translation;
- support for manipulating keyboard LEDs has been added;
- keyboard and mouse multiplexer devices have been added to INPUT,
primarily so that an X server need only open two devices;
- a new "libinputdriver" library abstracts away protocol details from
input drivers, and should be used by all future input drivers;
- both INPUT and PCKBD can be restarted;
- TTY is now scheduled by KERNEL, so that it won't be punished for
running a lot; without this, simply running "yes" on the console
kills the system;
- the KIOCBELL IOCTL has been moved to /dev/console;
- support for the SCANCODES termios setting has been removed;
- obsolete keymap compression has been removed;
- the obsolete Olivetti M24 keymap has been removed.
Change-Id: I3a672fb8c4fd566734e4b46d3994b4b7fc96d578
commit 0a3e629c0d4101a33c8b2e79c2e52d312978d34b
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Sep 27 11:56:29 2013 +0000
TTY: allow selecting on translated minors
Due to the existence of /dev/console and /dev/log, and the new
"console=" setting, it is now possible that a single non-PTY object
(e.g. serial) is accessible through two different minor numbers. This
poses a problem when sending late select replies (CDEV_SEL2_REPLY),
because the object's minor number can not be used to identify the
device. Since selecting on such objects through translated minor
numbers is actually required, we now save the minor number used to
initiate the select query in order to send a late reply.
The solution is suboptimal, as it is not possible to use two different
minors to select on the same object at once. In the future, there
should be at least one select record for each minor that can be used
with each object.
Change-Id: I4d39681d2ffd68b4047daf933d45b7bafe3c885e
commit fe2167a148dd17e15502d98e64057239fa122dd5
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Sep 21 17:35:15 2013 +0200
Take LOG out of the boot image
Change-Id: Id2629776b53aae46629b04a42c15cbbacac9b949
commit 81e138bb5ba168322eb780978ed4a90fc1ab7945
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Sep 21 15:03:20 2013 +0200
Kernel: make SIGKMESS target process list dynamic
The set of processes to which a SIGKMESS signal is sent whenever new
diagnostics messages are added to the kernel's message buffer, is now
no longer hardcoded. Instead, processes can (un)register themselves
to receive such notifications, by means of sys_diagctl().
Change-Id: I9d6ac006a5d9bbfad2757587a068fc1ec3cc083e
commit 9afa18ec208646a9244048a1d444c474ceb47c73
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Sep 21 00:58:46 2013 +0200
Rename SYSCTL kernel call to DIAGCTL
Change-Id: I1b17373f01808d887dcbeab493838946fbef4ef6
commit f82f1ec4b06240e96ed8e64e4bfdf5b06d688f89
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 20:13:59 2013 +0200
Prevent Jenkins from breaking on old df(1)
Change-Id: Ie8e1758bd9de4d5c95c597302f80d568058fbb68
commit 8a430b673dc97767306ddc9cb1a5367f333b7602
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 14:09:47 2013 +0200
Add testvnd.sh test script
As part of this, change the "run" script to allow certain scripts to
be run as root only.
Change-Id: I846e41037f9d4f6c7fc0b5ea8250303a7bd72f5d
commit fd57902664f398edd9274c2ab1d87daa0b4f4584
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 14:06:46 2013 +0200
Import NetBSD vndconfig(8)
The tool has been changed heavily to match our VND driver model.
NetBSD is in the process of renaming it from vnconfig(8) to
vndconfig(8). To keep things in sync, we have to play along.
Change-Id: Ie86df184f03ab00573ea76b43c9caa0412e8321d
commit 6809baec22122124a04d8bf8f4f8b5fc7778cb3d
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 14:02:17 2013 +0200
Add VND driver, providing loopback devices
Change-Id: I40fa695e28c67477a75383e6f1550e451afcab41
commit 4cb7efbfd17b934f914f633c8bebf5bec7934e5d
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 13:55:15 2013 +0200
VFS: add dupfrom(2) call
This call copies a file descriptor from a remote process into the
calling process. The call is for the VND driver only, and in the
future, ACLs will prevent any other process from using this call.
Change-Id: Ib16fdd1f1a12cb38a70d7e441dad91bc86898f6d
commit 378f893b1e710563e2ef2eee457255a6f3037885
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 11:46:08 2013 +0200
tests: do not skip installed shell tests
When installed, the test scripts lose their ".sh" suffix, causing them
to be skipped by the "run" script. With this patch, the tests are no
longer specified with ".sh" suffix in the run script, and the suffix
is added automatically as necessary.
Change-Id: I0b72312e79992b9818559c6546a0e52cd95184c2
commit ecdd53c03077c3cceb29485aa56021d99485d6a5
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 13:41:56 2013 +0200
blocktest: prepare to be run as part of tests
- fail SEF initialization if any of the subtests failed, so that the
party invoking the "service up" can tell whether the test succeeded;
- add "nocontig" option, because VM isn't particularly good at
allocating contiguous memory;
- add "silent" option, because it floods the console otherwise;
- allow the device size to be smaller than the maximum transfer size;
- install files to installed test directory.
Change-Id: I45c818f817c11d90c5f94ae26a2fc49e36e6761e
commit 848ef711847b7adcf20dce333435802c4e1018ea
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 18 13:38:36 2013 +0200
Enable devname(3)
There is no support for a device name database yet, so this call is
expected to be fairly slow.
Change-Id: I73aa5f267e2b6921b7d3bbdcc4beac463931132c
commit b84199849ad72030993bcf3f943da1509be15ded
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Sep 15 13:09:00 2013 +0200
libbdev: be less noisy about clean driver restarts
Change-Id: Ie02a459c9b544d361ab00bac431ef99de53b0c5f
commit 4f01352a2a6c82fc11465bc555c25e0344c5b970
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Sep 14 14:43:53 2013 +0200
Straighten ioctl.h
- include all ioctl subheaders, properly listing all letters;
- change FBD's ioctl calls to use 'B' instead of 'F', in
preparation of the VND driver.
Change-Id: Ia718979568cc057f47cf505a89238d5b3b6695d4
commit 0ee3f3aeb3d634133a9cd8c3b81589772235c617
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Sep 15 18:55:42 2013 +0200
VM: readd support for forgetting cached FS blocks
Not all services involved in block I/O go through VM to access the
blocks they need. As a result, the blocks in VM may become stale,
possibly causing corruption when the stale copy is restored by a
service that does go through VM later on. This patch restores support
for forgetting cached blocks that belong to a particular device, and
makes the relevant file systems use this functionality 1) when
requested by VFS through REQ_FLUSH, and 2) upon unmount.
Change-Id: I0758c5ed8fe4b5ba81d432595d2113175776aff8
commit c1652705b625a978ea2af169a21349352bd6575f
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 14:50:18 2013 +0200
filter: use libblockdriver
Change-Id: Ifbca2482e996ddca58036d45f557165e636fb3fa
commit ad99ccdb45b897afa7573f75b1a29c4a19767870
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 10 20:25:01 2013 +0200
Rewrite character driver protocol
As a side effect, remove the clone style, as the normal device style
supports device cloning now.
Change-Id: Ie82d1ef0385514a04a8faa139129a617895780b5
commit 4f91091ea26022877fd8c29094008d8072cf5e2b
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 10 16:06:37 2013 +0200
Remove support for reopening character devices
Previously, VFS would reopen a character device after a driver crash
if the associated file descriptor was opened with the O_REOPEN flag.
This patch removes support for this feature. The code was complex,
full of uncovered corner cases, and hard to test. Moreover, it did not
actually hide the crash from user applications: they would get an
error code to indicate that something went wrong, and have to decide
based on the nature of the underlying device how to continue.
- remove support for O_REOPEN, and make playwave(1) reopen its device;
- remove support for the DEV_REOPEN protocol message;
- remove all code in VFS related to reopening character devices;
- no longer change VFS filp reference count and FD bitmap upon filp
invalidation; instead, make get_filp* fail all calls on invalidated
FDs except when obtained with the locktype VNODE_OPCL which is used
by close_fd only;
- remove the VFS fproc file descriptor bitmap entirely, returning to
the situation that a FD is in use if its slot points to a filp; use
FILP_CLOSED as single means of marking a filp as invalidated.
Change-Id: I34f6bc69a036b3a8fc667c1f80435ff3af56558f
commit 8dfbb8fbe4f37642ac9700cc46ad0588687aa3a4
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 10 12:19:08 2013 +0200
VFS: rework device code
- block the calling thread on character device close;
- fully separate block and character open/close routines;
- reuse generic open/close code for the cloning case;
- zero all messages to drivers before filling them;
- use appropriate types for major/minor device numbers.
Change-Id: Ia90e6fe5688f212f835c5ee1bfca831cb249cf51
commit 9fabdb8b4edf637b47f1530bea145d68a028c319
Author: David van Moolenbroek <david@minix3.org>
Date: Mon Sep 9 00:04:12 2013 +0200
Make PFS backcalls regular VFS calls
- prefix them with VFS_ as they are going to VFS;
- give these calls normal call numbers;
- give them their own set of message field aliases;
- also make do_mapdriver a regular call.
Change-Id: I2140439f288b06d699a1f65438bd8306509b259e
commit 8fbd5d36fa175e2c31ed4a239be3f785e2995aef
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 12:48:10 2013 +0200
TTY: use libchardriver; clean up
- writing to a PTY master side blocks if there is not already a
blocked reader on the slave side, and select now reflects this;
- internally, TTY now uses a test based on "caller != NONE" rather
than "grant != GRANT_INVALID" to identify whether a call is
currently ongoing;
- "offset" fields have been removed as they equal the corresponding
"cum" fields;
- improved variable typing and function naming here and there;
- various other small fixes.
Change-Id: I6b51452888942e864b4e034e8c8490576184a23e
commit 53df30e2b876c03b26f8f52abeafcf8f601e6fd2
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 01:13:59 2013 +0200
VFS: select(2) fixes
- check each file descriptor's open access mode (filp_mode);
- treat an error returned by a character driver as a select error;
- check all filps in each set before finishing select;
- do not copy back file descriptor sets if an error occurred;
- remove the hardcoded list of supported character major devices,
since all drivers should now be capable of responding properly;
- add tests to test40 and fix its error count aggregation.
Change-Id: I57ef58d3afb82640fc50b59c859ee4b25f02db17
commit f08c75810f26adf75a757b5b65fdfa2589cf701d
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 01:07:28 2013 +0200
Retire EBADIOCTL in favor of ENOTTY
Change-Id: I6bd0e301d21ab7f2336e350e7e6e15d238c2c93d
commit 91b7de8257c92283648c796d882a9095a1f64707
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 4 15:42:36 2013 +0000
libnetsock: use libchardriver
Change-Id: Ia5b780cad0b0c636db9bd866c7223da0d38ef6ea
commit 6a3a64d9669c5b1d6ca9acc12f02cd2f21f22d0f
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 00:50:36 2013 +0200
LWIP: move chardev message parsing into libnetsock
Change-Id: Ie23fd003c9fa35811548f388c8e9b55e8d9de8d7
commit 39aa2794e04ad34aecc6dcf607c0987dad13c1ef
Author: David van Moolenbroek <david@minix3.org>
Date: Mon Sep 9 14:53:28 2013 +0000
INET: use libchardriver
Change-Id: Icf8a1a5769ce0aede1cc28da99b9daf7d328182c
commit 7c0d3f508d8e840a2d30da4d3e3af696b9ad2abc
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 3 02:00:20 2013 +0200
PFS: use libchardriver; clean up
- simplify and repair UDS request handling state machine;
- simplify interface used between internal modules;
- implement missing support for nonblocking I/O;
- fix select implementation;
- clean up global variables.
Change-Id: Ia82c5c6f05cc3f0a498efc9a26de14b1cde6eace
commit 5598aedb79b34fd02b3b81427d683014a3303e0c
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 3 01:59:20 2013 +0200
libaudiodriver: use libchardriver
Change-Id: I299d58d110ad14b69076276ba46c4325875c34ca
commit 2aadc0aa253427d18c1e3db597c33dd06d9c380e
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 3 01:57:41 2013 +0200
printer: use libchardriver
Change-Id: Ifa3cabeada74c32df2613b8279c00f86e831c775
commit aeaa28b7c68aced329d9cf5b4a01af07b2f3638e
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 3 01:49:38 2013 +0200
libchardriver: full API rewrite
The new API now covers the entire character driver protocol, while
hiding all the message details. It should therefore be used by all
new character drivers. All existing drivers that already made use of
libchardriver have been changed to use the new API.
As one of the most important API changes, support for scatter and
gather transfers has been removed, as several key drivers already
did not support this, and it could be supported at the safecopy
level instead (for a future readv/writev).
Additional changes include:
- respond to block device open requests to avoid hanging VFS threads;
- add support for sef_cancel.
Change-Id: I1bab6c1cb66916c71b87aeb1db54a9bdf171fe6b
commit 6fbd39f8a65178d8fafa260dc42fde5341eb9097
Author: David van Moolenbroek <david@minix3.org>
Date: Thu Aug 1 18:20:33 2013 +0200
blocktest: add support for no alignment
Some block drivers do not impose any alignment requirements, and this
patch allows such block drivers to pass the test set. As a side effect,
minimal support for min_write is added, but this part of blocktest is
in need of further improvement.
commit d70dc11950991506fa08d144067de3fe86b17136
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Apr 18 00:04:28 2012 +0200
libutil: let opendisk(3) try /dev
If a device node is given without path, and opening the node fails
initially, prepend "/dev/" to the node name and try opening again.
This is more in line with NetBSD behavior.
commit 4b6bf57bc77973874b041239c5a7809448e4d857
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 10 23:57:32 2013 +0200
Block drivers: make IOCTL request unsigned long
The block driver protocol and libblockdriver's bdr_ioctl hook are
changed, as well as the users of this hook. Other parts of the system
are expected to change accordingly eventually, since the ioctl(2)
prototype has been aligned with NetBSD's.
Change-Id: Ide46245b22cfa89ed267a38088fb0ab7696eba92
commit d74ea98bdfd90605dd5b0c57e12390dc4dba56e6
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Jul 27 00:49:49 2013 +0200
Block protocol: add user endpoint to IOCTL request
I/O control requests now come with the endpoint of the user process
that initiated the ioctl(2) call. It is stored in a new BDEV_USER
field, which is an alias for BDEV_FLAGS. The contents of this field
are to be used only in highly specific situations. It should be
preserved (not replaced!) by services that forward IOCTL requests,
and may be set to NONE for service-initiated IOCTL requests.
Change-Id: I68a01b9ce43eca00e61b985a9cf87f55ba683de4
commit 15afe7ddf85235f00e5a5d0e825d2894ac58549d
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Jul 27 00:49:49 2013 +0200
Block protocol: use own [RW]_BIT definitions
The original R_BIT and W_BIT definitions have nothing to do with the
way these bits are used. Their distinct usage is more apparent when
they have different names.
Change-Id: Ia984457f900078b2e3502ceed565fead4e5bb965
commit c4c9435b0df31b36c11f27370475694043c5b8e0
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Sep 10 23:35:15 2013 +0200
libblockdriver: expose BLOCKDRIVER_MAX_DEVICES
This constant determines the range of valid device_id_t values that
a block driver can return from the bdr_device hook: a value between
0 and (BLOCKDRIVER_MAX_DEVICES - 1) inclusive.
Change-Id: I80fac469e88ac13d4b869007e6f2c2f7569da433
commit 2c5bd1565b5d9b487899dee7a023a641343e65a9
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Sep 11 13:33:00 2013 +0200
libblockdriver: various updates
- internal structure rearrangement;
- respond to char device open requests to avoid hanging VFS threads;
- make drivers use designated initializers;
- use devminor_t for all minor device numbers;
- change bdr_other hook to take ipc_status and return nothing;
- fix default geometry computation;
- add support for sef_cancel.
Change-Id: Ia063a136a3ddb2b78de36180feda870605753d70
commit b1cfc3123b03d5a8c9452ae251892593dc328357
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Sep 1 14:34:17 2013 +0200
Block drivers: reply ENOTTY to unknown IOCTLs
Change-Id: Ie2e82d2491d546f4dd73b009100646e249a147b5
commit b5eab0554511ace3d7fae40883be0da139b0e2ab
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Jul 28 14:03:07 2013 +0200
Move SUB_PER_DRIVE definition into minix/drvlib.h
commit 20c8aedc6737fc935ccea0b394616851ff4fdece
Author: David van Moolenbroek <david@minix3.org>
Date: Mon Sep 2 17:34:44 2013 +0200
VFS: update filp_pos on chardev I/O (workaround)
Previously, reading from or writing to a character device would not
update the file position on the corresponding filp object. Performing
this update correctly is not trivial: during and after the I/O
operation, the filp object must not be locked. Ideally, read/write
requests on a filp that is already involved in a read/write operation,
should be queued. For now, we optimistically update the file position
at the start of the I/O; this works under the assumptions listed in
the corresponding comment.
Change-Id: I172a61781850423709924390ae3df1f2d1f94707
commit dbef7bae2308a2e4449b8f274898ed3b60b2add2
Author: David van Moolenbroek <david@minix3.org>
Date: Mon Sep 2 13:45:02 2013 +0200
I2C: change BUSC_I2C_xxx to use own protocol
Previously it would use bits of the character driver protocol, which
will change heavily. In the new situation, the BUSC_I2C_xxx requests
use a protocol more in line with the PCI protocol, with the reply code
in m_type.
Change-Id: I51597b3f191078c8178ce17372de123031f7a4c4
commit 7cdb9683ec718247b03cbae3c827d9834c484e91
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Aug 31 16:13:37 2013 +0200
tests: add test77 for opening/closing PTYs
Change-Id: I30e3418f75137aa08037fa6581ff3d4cce32a114
commit ed9ee8b9cd5a647130a81bd70af48cee4f6dca15
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Aug 31 16:08:25 2013 +0200
TTY: fix for PTY open/close logic
Opening and closing the master side of a pseudo terminal without
opening the slave side would result in the pseudo terminal becoming
permanently unavailable. In addition, reopening the slave side
would be possible but not allow for I/O. Finally, attempting to
open an in-use master would wipe its I/O state. These issues have
been resolved.
Change-Id: I9235e3d9aba321803f9280b86b6b5e3646ad5ef3
commit cd14d52a99df7fb6dd7c6c48a034e4bf7c170789
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 18:48:56 2013 +0200
tests: remove select subdirectory
This test set has been obsoleted by test40.
Change-Id: I55439152824906778ad07d409dfb327ac10bea70
commit 5ab6f6e7c2f4618648f163af6bd705e5ef2fafb8
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 18:43:23 2013 +0200
tests: add test76 for interrupting VFS operations
Change-Id: Ic436cac61de8c42e0c7ee2d442c647528654cde9
commit ad548d2c9f78e2f2dc2108c50b6c7ed6755a53f1
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Aug 28 13:08:16 2013 +0200
VFS: fix interruption of blocking pipe operations
POSIX states that when interrupted, partially successful pipe
operations should return the partial result rather than EINTR. VFS
previously wouldn't look at the partial result, and not clear it
either, which would result in a panic upon the next pipe operation.
Change-Id: Ia1eb72b4b77394051444e63a1390d49bb315eb04
commit 813198ce7b0ce171f79529e8f6c5a94ab26ce1cb
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 00:57:16 2013 +0200
libmthread: do not dump stack for free threads
Change-Id: Ic438a252f5bddaf1513f554c71173e6fffb0c674
commit 53b6001312428a1ac7379718616cb640614f53e6
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 14:00:50 2013 +0200
VFS: worker thread model overhaul
The main purpose of this patch is to fix handling of unpause calls
from PM while another call is ongoing. The solution to this problem
sparked a full revision of the threading model, consisting of a large
number of related changes:
- all active worker threads are now always associated with a process,
and every process has at most one active thread working for it;
- the process lock is always held by a process's worker thread;
- a process can now have both normal work and postponed PM work
associated to it;
- timer expiry and non-postponed PM work is done from the main thread;
- filp garbage collection is done from a thread associated with VFS;
- reboot calls from PM are now done from a thread associated with PM;
- the DS events handler is protected from starting multiple threads;
- support for a system worker thread has been removed;
- the deadlock recovery thread has been replaced by a parameter to the
worker_start() function; the number of worker threads has
consequently been increased by one;
- saving and restoring of global but per-thread variables is now
centralized in worker_suspend() and worker_resume(); err_code is now
saved and restored in all cases;
- the concept of jobs has been removed, and job_m_in now points to a
message stored in the worker thread structure instead;
- the PM lock has been removed;
- the separate exec lock has been replaced by a lock on the VM
process, which was already being locked for exec calls anyway;
- PM_UNPAUSE is now processed as a postponed PM request, from a thread
associated with the target process;
- the FP_DROP_WORK flag has been removed, since it is no longer more
than just an optimization and only applied to processes operating on
a pipe when getting killed;
- assignment to "fp" now takes place only when obtaining new work in
the main thread or a worker thread, when resuming execution of a
thread, and in the special case of exiting processes during reboot;
- there are no longer special cases where the yield() call is used to
force a thread to run.
Change-Id: I7a97b9b95c2450454a9b5318dfa0e6150d4e6858
commit 6fbb7f4167510fb1a71fdad2b965dc2f7417aef4
Author: David van Moolenbroek <david@minix3.org>
Date: Wed Aug 28 15:58:30 2013 +0200
Retire ptrace(T_DUMPCORE), dumpcore(1), gcore(1)
The T_DUMPCORE implementation was not only broken - it would currently
produce a coredump of the tracer process rather than the traced
process - but also deeply flawed, and fixing it would require serious
alteration of PM's internal state machine. It should be possible to
implement the same functionality in userland, and that is now the
suggested way forward. For now, also remove the (identical) utilities
using T_DUMPCORE: dumpcore(1) and gcore(1).
Change-Id: I1d51be19c739362b8a5833de949b76382a1edbcc
commit fde44a0523a26b5bad5a0e3fc2921b1b5821d5d4
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 13:42:51 2013 +0200
VFS: process char driver replies from main thread
Previously, processing of some replies coming from character drivers
could block on locks, and therefore, such processing was done from
threads that were associated to the character driver process. The
hidden consequence of this was that if all threads were in use, VFS
could drop replies coming from the driver. This patch returns VFS to
a situation where the replies from character drivers are processed
instantly from the main thread, by removing the situations that may
cause VFS to block while handling those replies.
- change the locking model for select, so that it will never block
on any processing that happens after the select call has been set
up, in particular processing of character driver select replies;
- clearly mark all select routines that may never block;
- protect against race conditions in do_select as result of the
locking that still does happen there (as is required for pipes);
- also handle select timers from the main thread;
- move processing of character driver replies into device.c.
Change-Id: I4dc8e69f265cbd178de0fbf321d35f58f067cc57
commit d5d67d293d4a7a2669eb179621a1c6d3e2796d97
Author: David van Moolenbroek <david@minix3.org>
Date: Sun Aug 25 00:26:38 2013 +0200
VFS: properly cancel select queries on unpause
Change-Id: I16e71db3f5c1bcc7ba6045bc9f02b13d71dc31eb
commit d0371a4fbdaddbf7bc543a8046bb91454e09283d
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 13:33:56 2013 +0200
VFS: remove support for sync char driver protocol
Change-Id: I57cc870a053b813b3a3fc45da46606ea84fe4cb1
commit 2b12ad511fabd5a1019f736221f2940bfe7e2781
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 13:00:44 2013 +0200
VFS: remove FP_BLOCKED_ON_DOPEN
These days, DEV_OPEN calls to character drivers block the calling
thread until completion or failure, and thus never return SUSPEND to
the caller. The same already applied to BDEV_OPEN calls to block
drivers. It has thus become impossible for a process to enter a state
of being blocked on a device open call.
There is currently no support for restarting device open calls to
restarted character drivers. This support was present in the _DOPEN
logic, but was already no longer triggering. In the future, this case
should be handled by the thread performing the open request.
Change-Id: I6cc1e7b4c9ed116c6ce160b315e6e060124dce00
commit 0eee377a337f5800760d2f5611d203c158ac6099
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 12:18:27 2013 +0200
PFS: remember request information for IOCTLs
Not doing so caused PFS to commit protocol violations by relying on
stale information when sending replies. This stale information always
happened to be correct, which is why the problem went unnoticed.
Change-Id: Ia42ca670718d6e731193cd2c34a3ff455f8a94d3
commit 3272c645aca015b6778a8fe945e014a0a5acc023
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 11:14:03 2013 +0200
Retire the synchronous character driver protocol
- change all sync char drivers into async drivers;
- retire support for the sync protocol in libchardev;
- remove async dev style, as this is now the default;
- remove dev_status from VFS;
- clean up now-unused protocol messages.
Change-Id: I6aacff712292f6b29f2ccd51bc1e7d7003723e87
commit 831d825d5a6891b79e97002e1a2d396dcb47bea6
Author: David van Moolenbroek <david@minix3.org>
Date: Fri Aug 30 10:48:34 2013 +0200
Sync char protocol: add nonblocking transfer flag
The async char protocol already has this, so this patch closes the
gap between the two protocols a bit. Support for this flag has been
added to all sync char drivers that support CANCEL at all.
The LOG driver was already using the asynchronous protocol, but it
did not support the nonblocking transfer flag. This has been fixed
as well.
Change-Id: Ia55432c9f102765b59ad3feb45a8bd47a782c93f
commit 4f5aec7328128b9d035ff1158f0e6a0f7bd393e4
Author: David van Moolenbroek <david@minix3.org>
Date: Sat Aug 24 12:29:39 2013 +0200
VFS: set w_drv_sendrec only when needed
As with w_task, this ensures that the field remains cleared if it is
not used. Without this, worker_stop could mistakenly identify a thread
as talking to a device driver rather than a (crashed) file server.
Change-Id: I7d3ebed3efc3cd4f5c891f61c67a6463109b6376
commit 9bbf923154733f1b9ba52a063872ccdbaa7ff0f0
Author: Thomas Veerman <thomas@minix3.org>
Date: Sat Aug 24 12:23:41 2013 +0200
VFS: set w_task only when needed
It was always set, but not always cleared, when talking to asynchronous
drivers. This could cause erratic behavior upon a driver crash.
Normally, a worker thread's w_task field is set when it's about to
communicate with a driver or FS. Then upon receiving a reply we can
do sanity checks (that the thread we want to wake up was actually
waiting for a reply). Also, when a driver/FS crashes, we can identify
which worker threads were talking to the crashed endpoint and handle
the error gracefully.
Asynchronous drivers are a bit special, though. In most cases, the
sender of the request is not interested in the reply (the sender was
suspended and only wants to know whether the request was successfully
caried out or not). However, the open request is special, as the reply
carries information needed by the sender. This is the only request
where a worker thread actually yields and waits for the result. This is
also the only case where we're interested in setting w_task for
asynchronous drivers.
Change-Id: Ia1ce2747937df376122b5e13b6a069de27fcc379
commit 2a293ca6703354cd7be8eb18147f7c4d18894132
Author: David van Moolenbroek <david@minix3.org>
Date: Mon Aug 19 20:34:15 2013 +0200
Import NetBSD df(1)
Change-Id: Ia60f8b23b961e4132efece1e7e38f0d63597c13b
commit c35fc992ccc052e1f3741be0db9b676682f68bf8
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 01:33:43 2013 +0200
Enable getmntinfo(3)
Change-Id: Id9d11a67cdcad331a52030127f7c7ead3c847919
commit 907b40860983a73fe22f45aa8b175b27cb7dc1d7
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 00:49:07 2013 +0200
test55: add tests for getvfsstat(2)
Change-Id: Iad4567068a82bb0e780891a478ba5a06b63f1d48
commit 3297eb8d103545690e9f2cb6c63fdd1ce3452c6d
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 01:28:23 2013 +0200
Implement support for [f]statvfs1(2)
The [f]statvfs(3) calls now use [f]statvfs1(2).
Change-Id: I56c92fe1c70670f476631c4a50e47351562712c6
commit 4f576aff9f046276974c4a769427a1cb8c2470a0
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 01:39:47 2013 +0200
Implement support for getvfsstat(2)
Change-Id: I4680c071b94fa855edfb6220b03cff6b20f3c1c9
commit 53485a9b35ec2e27ec0df232d8c80db1a829246b
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 01:37:18 2013 +0200
Redo mount(2)/umount(2) ABI
- pass in file system type through mount(2), and return this type in
statvfs structures as generated by [f]statvfs(2);
- align mount flags field with NetBSD's, splitting out service flags
which are not to be passed to VFS;
- remove limitation of mount ABI to 16-byte labels, so that labels
can be made larger in the future;
- introduce new m11 message union type for mount(2) as side effect.
Change-Id: Ia9ed4566d88af5239749c57274312be26bb61448
commit 6ebff29307cd1bacba965d1e8dfb465b6684ccb7
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 01:35:35 2013 +0200
Align "struct statvfs" with NetBSD
This is a requirement for implementing calls such as getmntinfo(3).
VFS is now responsible for filling in some of the structure's fields.
Change-Id: I457b463c70ea2f326b9c50de954a91cfefba0065
commit 9b5871fd21d37b0533b6546c408ff4ad4ae02952
Author: David van Moolenbroek <david@minix3.org>
Date: Tue Aug 20 00:55:49 2013 +0200
VFS/FS: remove fstatfs(2) and REQ_FSTATFS
The fstatfs(3) call now uses fstatvfs(2).
Change-Id: Ic6bbb040e1a8f01aaffe1a6a809dd4c7a2eae2f6
Change-Id: I44109a83fd9155f15a8b580e9471ed1aff952673
This commit is contained in:
parent
7d85156ac0
commit
db63c22446
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
SUBDIR= cat date echo ed expr kill ksh ln ls \
|
||||
SUBDIR= cat date df echo ed expr kill ksh ln ls \
|
||||
mkdir pax pwd rm rmdir sync test
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: cat.1,v 1.32 2006/09/23 11:24:44 wiz Exp $
|
||||
.\" $NetBSD: cat.1,v 1.34 2012/08/09 07:26:28 dholland Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
.\"
|
||||
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
|
||||
.\"
|
||||
.Dd September 23, 2006
|
||||
.Dd April 6, 2012
|
||||
.Dt CAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -54,6 +54,9 @@ A single dash represents the standard input,
|
|||
and may appear multiple times in the
|
||||
.Ar file
|
||||
list.
|
||||
If no
|
||||
.Ar file
|
||||
operands are given, standard input is read.
|
||||
.Pp
|
||||
The word
|
||||
.Dq concatenate
|
||||
|
|
@ -65,7 +68,7 @@ The options are as follows:
|
|||
.It Fl b
|
||||
Implies the
|
||||
.Fl n
|
||||
option but doesn't number blank lines.
|
||||
option, but doesn't number blank lines.
|
||||
.It Fl e
|
||||
Implies the
|
||||
.Fl v
|
||||
|
|
@ -139,7 +142,7 @@ to the file
|
|||
truncating
|
||||
.Ar file3
|
||||
if it already exists.
|
||||
See the manual page for your shell (i.e.,
|
||||
See the manual page for your shell (e.g.,
|
||||
.Xr sh 1 )
|
||||
for more information on redirection.
|
||||
.Pp
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $ */
|
||||
/* $NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
|
@ -44,7 +44,7 @@ __COPYRIGHT(
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $");
|
||||
__RCSID("$NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
|
@ -295,8 +295,8 @@ raw_cat(int rfd)
|
|||
if (buf == NULL) {
|
||||
struct stat sbuf;
|
||||
|
||||
if (fstat(wfd, &sbuf) == 0 &&
|
||||
sbuf.st_blksize > sizeof(fb_buf)) {
|
||||
if (fstat(wfd, &sbuf) == 0 && sbuf.st_blksize > 0 &&
|
||||
(size_t)sbuf.st_blksize > sizeof(fb_buf)) {
|
||||
bsize = sbuf.st_blksize;
|
||||
buf = malloc(bsize);
|
||||
}
|
||||
|
|
|
|||
11
bin/df/Makefile
Normal file
11
bin/df/Makefile
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# $NetBSD: Makefile,v 1.19 2011/08/28 08:20:58 christos Exp $
|
||||
# @(#)Makefile 8.3 (Berkeley) 5/8/95
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
PROG= df
|
||||
|
||||
LDADD+=-lutil
|
||||
DPADD+=${LIBUTIL}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
206
bin/df/df.1
Normal file
206
bin/df/df.1
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
.\" $NetBSD: df.1,v 1.44 2010/04/05 21:17:28 joerg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)df.1 8.2 (Berkeley) 1/13/92
|
||||
.\"
|
||||
.Dd March 4, 2008
|
||||
.Dt DF 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm df
|
||||
.Nd display free disk space
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl agklmn
|
||||
.Op Fl G | Fl i | Fl P
|
||||
.Op Fl t Ar type
|
||||
.Op Ar file | Ar file_system ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
displays statistics about the amount of free disk space on the specified
|
||||
.Ar file_system
|
||||
or on the file system of which
|
||||
.Ar file
|
||||
is a part.
|
||||
By default, all sizes are reported in 512-byte block counts.
|
||||
If neither a file or a
|
||||
.Ar file_system
|
||||
operand is specified,
|
||||
statistics for all mounted file systems are displayed
|
||||
(subject to the
|
||||
.Fl l
|
||||
and
|
||||
.Fl t
|
||||
options below).
|
||||
.Pp
|
||||
Note that the printed count of available blocks takes
|
||||
.Va minfree
|
||||
into account, and thus will be negative when the number of free blocks
|
||||
on the filesystem is less than
|
||||
.Va minfree .
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl a
|
||||
Show all mount points,
|
||||
including those that were mounted with the
|
||||
.Dv MNT_IGNORE
|
||||
flag.
|
||||
.It Fl G
|
||||
Display all the fields of the structure(s) returned by
|
||||
.Xr statvfs 2 .
|
||||
This option cannot be used with the
|
||||
.Fl i
|
||||
or
|
||||
.Fl P
|
||||
options, and it is modelled after the Solaris
|
||||
.Fl g
|
||||
option.
|
||||
This option will override the
|
||||
.Fl g ,
|
||||
.Fl h ,
|
||||
.Fl k ,
|
||||
and
|
||||
.Fl m
|
||||
options, as well as any setting of
|
||||
.Ev BLOCKSIZE .
|
||||
.It Fl g
|
||||
The
|
||||
.Fl g
|
||||
option causes the numbers to be reported in gigabytes (1024*1024*1024
|
||||
bytes).
|
||||
.It Fl h
|
||||
"Human-readable" output.
|
||||
Use unit suffixes: Byte, Kilobyte, Megabyte,
|
||||
Gigabyte, Terabyte, Petabyte, Exabyte in order to reduce the number of
|
||||
digits to four or less.
|
||||
.It Fl i
|
||||
Include statistics on the number of free inodes.
|
||||
.It Fl k
|
||||
By default, all sizes are reported in 512-byte block counts.
|
||||
The
|
||||
.Fl k
|
||||
option causes the numbers to be reported in kilobytes (1024 bytes).
|
||||
.It Fl l
|
||||
Display statistics only about mounted file systems with the
|
||||
.Dv MNT_LOCAL
|
||||
flag set.
|
||||
If a non-local file system is given as an argument, a
|
||||
warning is issued and no information is given on that file system.
|
||||
.It Fl m
|
||||
The
|
||||
.Fl m
|
||||
option causes the numbers to be reported in megabytes (1024*1024 bytes).
|
||||
.It Fl n
|
||||
Print out the previously obtained statistics from the file systems.
|
||||
This option should be used if it is possible that one or more
|
||||
file systems are in a state such that they will not be able to provide
|
||||
statistics without a long delay.
|
||||
When this option is specified,
|
||||
.Nm
|
||||
will not request new statistics from the file systems, but will respond
|
||||
with the possibly stale statistics that were previously obtained.
|
||||
.It Fl P
|
||||
Produce output in the following portable format:
|
||||
.Pp
|
||||
If both the
|
||||
.Fl P
|
||||
and
|
||||
.Fl k
|
||||
option are specified, the output will be preceded by the following header
|
||||
line, formatted to match the data following it:
|
||||
.Bd -literal
|
||||
"Filesystem 1024-blocks Used Available Capacity Mounted on\en"
|
||||
.Ed
|
||||
.Pp
|
||||
If the
|
||||
.Fl P
|
||||
option is specified without the
|
||||
.Fl k
|
||||
options, the output will be preceded by the following header line,
|
||||
formatted to match the data following it:
|
||||
.Bd -literal
|
||||
"Filesystem \*[Lt]blksize\*[Gt]-blocks Used Available Capacity Mounted on\en"
|
||||
.Ed
|
||||
.Pp
|
||||
The header line is followed by data formatted as follows:
|
||||
.Bd -literal
|
||||
"%s %d %d %d %d%% %s\en", \*[Lt]file system name\*[Gt], \*[Lt]total space\*[Gt],
|
||||
\*[Lt]space used\*[Gt], \*[Lt]space free\*[Gt], \*[Lt]percentage used\*[Gt],
|
||||
\*[Lt]file system root\*[Gt]
|
||||
.Ed
|
||||
.Pp
|
||||
Note that the
|
||||
.Fl i
|
||||
option may not be specified with
|
||||
.Fl P .
|
||||
.It Fl t Ar type
|
||||
Is used to indicate the actions should only be taken on
|
||||
filesystems of the specified type.
|
||||
More than one type may be specified in a comma-separated list.
|
||||
The list of filesystem types can be prefixed with
|
||||
.Dq no
|
||||
to specify the filesystem types for which action should
|
||||
.Em not
|
||||
be taken.
|
||||
If a file system is given on the command line that is not of
|
||||
the specified type, a warning is issued and no information is given on
|
||||
that file system.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width BLOCKSIZE
|
||||
.It Ev BLOCKSIZE
|
||||
If the environment variable
|
||||
.Ev BLOCKSIZE
|
||||
is set, and the
|
||||
.Fl g ,
|
||||
.Fl h ,
|
||||
.Fl k
|
||||
and
|
||||
.Fl m
|
||||
options are not specified, the block counts will be displayed in units of that
|
||||
size block.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr quota 1 ,
|
||||
.Xr fstatvfs 2 ,
|
||||
.Xr getvfsstat 2 ,
|
||||
.Xr statvfs 2 ,
|
||||
.Xr getbsize 3 ,
|
||||
.Xr getmntinfo 3 ,
|
||||
.Xr fs 5 ,
|
||||
.Xr fstab 5 ,
|
||||
.Xr mount 8 ,
|
||||
.Xr quot 8 ,
|
||||
.Xr tunefs 8
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm
|
||||
utility appeared in
|
||||
.At v6 .
|
||||
520
bin/df/df.c
Normal file
520
bin/df/df.c
Normal file
|
|
@ -0,0 +1,520 @@
|
|||
/* $NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__COPYRIGHT(
|
||||
"@(#) Copyright (c) 1980, 1990, 1993, 1994\
|
||||
The Regents of the University of California. All rights reserved.");
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
#include <util.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
static char *getmntpt(const char *);
|
||||
static void prtstat(struct statvfs *, int);
|
||||
static int selected(const char *, size_t);
|
||||
static void maketypelist(char *);
|
||||
static size_t regetmntinfo(struct statvfs **, size_t);
|
||||
__dead static void usage(void);
|
||||
static void prthumanval(int64_t, const char *);
|
||||
static void prthuman(struct statvfs *, int64_t, int64_t);
|
||||
|
||||
static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag;
|
||||
static long usize;
|
||||
static char **typelist;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct stat stbuf;
|
||||
struct statvfs *mntbuf;
|
||||
long mntsize;
|
||||
int ch, i, maxwidth, width;
|
||||
char *mntpt;
|
||||
|
||||
setprogname(argv[0]);
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
while ((ch = getopt(argc, argv, "aGghiklmnPt:")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
case 'g':
|
||||
hflag = 0;
|
||||
usize = 1024 * 1024 * 1024;
|
||||
break;
|
||||
case 'G':
|
||||
gflag = 1;
|
||||
break;
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
usize = 0;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
break;
|
||||
case 'k':
|
||||
hflag = 0;
|
||||
usize = 1024;
|
||||
break;
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
case 'm':
|
||||
hflag = 0;
|
||||
usize = 1024 * 1024;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'P':
|
||||
Pflag = 1;
|
||||
break;
|
||||
case 't':
|
||||
if (typelist != NULL)
|
||||
errx(EXIT_FAILURE,
|
||||
"only one -t option may be specified.");
|
||||
maketypelist(optarg);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
if (gflag && (Pflag || iflag))
|
||||
errx(EXIT_FAILURE,
|
||||
"only one of -G and -P or -i may be specified");
|
||||
if (Pflag && iflag)
|
||||
errx(EXIT_FAILURE,
|
||||
"only one of -P and -i may be specified");
|
||||
#if 0
|
||||
/*
|
||||
* The block size cannot be checked until after getbsize() is called.
|
||||
*/
|
||||
if (Pflag && (hflag || (usize != 1024 && usize != 512)))
|
||||
errx(EXIT_FAILURE,
|
||||
"non-standard block size incompatible with -P");
|
||||
#endif
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
if (mntsize == 0)
|
||||
err(EXIT_FAILURE,
|
||||
"retrieving information on mounted file systems");
|
||||
|
||||
if (*argv == NULL) {
|
||||
mntsize = regetmntinfo(&mntbuf, mntsize);
|
||||
} else {
|
||||
if ((mntbuf = malloc(argc * sizeof(*mntbuf))) == NULL)
|
||||
err(EXIT_FAILURE, "can't allocate statvfs array");
|
||||
mntsize = 0;
|
||||
for (/*EMPTY*/; *argv != NULL; argv++) {
|
||||
if (stat(*argv, &stbuf) < 0) {
|
||||
if ((mntpt = getmntpt(*argv)) == 0) {
|
||||
warn("%s", *argv);
|
||||
continue;
|
||||
}
|
||||
} else if (S_ISBLK(stbuf.st_mode)) {
|
||||
if ((mntpt = getmntpt(*argv)) == 0)
|
||||
mntpt = *argv;
|
||||
} else
|
||||
mntpt = *argv;
|
||||
/*
|
||||
* Statfs does not take a `wait' flag, so we cannot
|
||||
* implement nflag here.
|
||||
*/
|
||||
if (!statvfs(mntpt, &mntbuf[mntsize]))
|
||||
if (lflag &&
|
||||
(mntbuf[mntsize].f_flag & MNT_LOCAL) == 0)
|
||||
warnx("Warning: %s is not a local %s",
|
||||
*argv, "file system");
|
||||
else if
|
||||
(!selected(mntbuf[mntsize].f_fstypename,
|
||||
sizeof(mntbuf[mntsize].f_fstypename)))
|
||||
warnx("Warning: %s mounted as a %s %s",
|
||||
*argv,
|
||||
mntbuf[mntsize].f_fstypename,
|
||||
"file system");
|
||||
else
|
||||
++mntsize;
|
||||
else
|
||||
warn("%s", *argv);
|
||||
}
|
||||
}
|
||||
|
||||
maxwidth = 0;
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
width = (int)strlen(mntbuf[i].f_mntfromname);
|
||||
if (width > maxwidth)
|
||||
maxwidth = width;
|
||||
}
|
||||
for (i = 0; i < mntsize; i++)
|
||||
prtstat(&mntbuf[i], maxwidth);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
getmntpt(const char *name)
|
||||
{
|
||||
size_t mntsize, i;
|
||||
struct statvfs *mntbuf;
|
||||
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
if (mntsize == 0)
|
||||
err(EXIT_FAILURE, "Can't get mount information");
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if (!strcmp(mntbuf[i].f_mntfromname, name))
|
||||
return mntbuf[i].f_mntonname;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum { IN_LIST, NOT_IN_LIST } which;
|
||||
|
||||
static int
|
||||
selected(const char *type, size_t len)
|
||||
{
|
||||
char **av;
|
||||
|
||||
/* If no type specified, it's always selected. */
|
||||
if (typelist == NULL)
|
||||
return 1;
|
||||
for (av = typelist; *av != NULL; ++av)
|
||||
if (!strncmp(type, *av, len))
|
||||
return which == IN_LIST ? 1 : 0;
|
||||
return which == IN_LIST ? 0 : 1;
|
||||
}
|
||||
|
||||
static void
|
||||
maketypelist(char *fslist)
|
||||
{
|
||||
size_t i;
|
||||
char *nextcp, **av;
|
||||
|
||||
if ((fslist == NULL) || (fslist[0] == '\0'))
|
||||
errx(EXIT_FAILURE, "empty type list");
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* Note: the syntax is "noxxx,yyy" for no xxx's and
|
||||
* no yyy's, not the more intuitive "noyyy,noyyy".
|
||||
*/
|
||||
if (fslist[0] == 'n' && fslist[1] == 'o') {
|
||||
fslist += 2;
|
||||
which = NOT_IN_LIST;
|
||||
} else
|
||||
which = IN_LIST;
|
||||
|
||||
/* Count the number of types. */
|
||||
for (i = 1, nextcp = fslist;
|
||||
(nextcp = strchr(nextcp, ',')) != NULL; i++)
|
||||
++nextcp;
|
||||
|
||||
/* Build an array of that many types. */
|
||||
if ((av = typelist = malloc((i + 1) * sizeof(*av))) == NULL)
|
||||
err(EXIT_FAILURE, "can't allocate type array");
|
||||
av[0] = fslist;
|
||||
for (i = 1, nextcp = fslist;
|
||||
(nextcp = strchr(nextcp, ',')) != NULL; i++) {
|
||||
*nextcp = '\0';
|
||||
av[i] = ++nextcp;
|
||||
}
|
||||
/* Terminate the array. */
|
||||
av[i] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a pass over the filesystem info in ``mntbuf'' filtering out
|
||||
* filesystem types not in ``fsmask'' and possibly re-stating to get
|
||||
* current (not cached) info. Returns the new count of valid statvfs bufs.
|
||||
*/
|
||||
static size_t
|
||||
regetmntinfo(struct statvfs **mntbufp, size_t mntsize)
|
||||
{
|
||||
size_t i, j;
|
||||
struct statvfs *mntbuf;
|
||||
|
||||
if (!lflag && typelist == NULL && aflag)
|
||||
return nflag ? mntsize : (size_t)getmntinfo(mntbufp, MNT_WAIT);
|
||||
|
||||
mntbuf = *mntbufp;
|
||||
j = 0;
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if (!aflag && (mntbuf[i].f_flag & MNT_IGNORE) != 0)
|
||||
continue;
|
||||
if (lflag && (mntbuf[i].f_flag & MNT_LOCAL) == 0)
|
||||
continue;
|
||||
if (!selected(mntbuf[i].f_fstypename,
|
||||
sizeof(mntbuf[i].f_fstypename)))
|
||||
continue;
|
||||
if (nflag)
|
||||
mntbuf[j] = mntbuf[i];
|
||||
else {
|
||||
struct statvfs layerbuf = mntbuf[i];
|
||||
(void)statvfs(mntbuf[i].f_mntonname, &mntbuf[j]);
|
||||
/*
|
||||
* If the FS name changed, then new data is for
|
||||
* a different layer and we don't want it.
|
||||
*/
|
||||
if (memcmp(layerbuf.f_mntfromname,
|
||||
mntbuf[j].f_mntfromname, MNAMELEN))
|
||||
mntbuf[j] = layerbuf;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
static void
|
||||
prthumanval(int64_t bytes, const char *pad)
|
||||
{
|
||||
char buf[6];
|
||||
|
||||
(void)humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
|
||||
bytes, "", HN_AUTOSCALE,
|
||||
HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||
|
||||
(void)printf("%s %6s", pad, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
prthuman(struct statvfs *sfsp, int64_t used, int64_t bavail)
|
||||
{
|
||||
|
||||
prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), " ");
|
||||
prthumanval((int64_t)(used * sfsp->f_frsize), " ");
|
||||
prthumanval((int64_t)(bavail * sfsp->f_frsize), " ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert statvfs returned filesystem size into BLOCKSIZE units.
|
||||
* Attempts to avoid overflow for large filesystems.
|
||||
*/
|
||||
#define fsbtoblk(num, fsbs, bs) \
|
||||
(((fsbs) != 0 && (uint64_t)(fsbs) < (uint64_t)(bs)) ? \
|
||||
(int64_t)(num) / (int64_t)((bs) / (fsbs)) : \
|
||||
(int64_t)(num) * (int64_t)((fsbs) / (bs)))
|
||||
|
||||
/*
|
||||
* Print out status about a filesystem.
|
||||
*/
|
||||
static void
|
||||
prtstat(struct statvfs *sfsp, int maxwidth)
|
||||
{
|
||||
static long blocksize;
|
||||
static int headerlen, timesthrough;
|
||||
static const char *header;
|
||||
static const char full[] = "100";
|
||||
static const char empty[] = " 0";
|
||||
int64_t used, availblks, inodes;
|
||||
int64_t bavail;
|
||||
char pb[64];
|
||||
|
||||
if (gflag) {
|
||||
/*
|
||||
* From SunOS-5.6:
|
||||
*
|
||||
* /var (/dev/dsk/c0t0d0s3 ): 8192 block size 1024 frag size
|
||||
* 984242 total blocks 860692 free blocks 859708 available 249984 total files
|
||||
* 248691 free files 8388611 filesys id
|
||||
* ufs fstype 0x00000004 flag 255 filename length
|
||||
*
|
||||
*/
|
||||
(void)printf("%10s (%-12s): %7ld block size %12ld frag size\n",
|
||||
sfsp->f_mntonname, sfsp->f_mntfromname,
|
||||
sfsp->f_iosize, /* On UFS/FFS systems this is
|
||||
* also called the "optimal
|
||||
* transfer block size" but it
|
||||
* is of course the file
|
||||
* system's block size too.
|
||||
*/
|
||||
sfsp->f_bsize); /* not so surprisingly the
|
||||
* "fundamental file system
|
||||
* block size" is the frag
|
||||
* size.
|
||||
*/
|
||||
(void)printf("%10" PRId64 " total blocks %10" PRId64
|
||||
" free blocks %10" PRId64 " available\n",
|
||||
(uint64_t)sfsp->f_blocks, (uint64_t)sfsp->f_bfree,
|
||||
(uint64_t)sfsp->f_bavail);
|
||||
(void)printf("%10" PRId64 " total files %10" PRId64
|
||||
" free files %12lx filesys id\n",
|
||||
(uint64_t)sfsp->f_ffree, (uint64_t)sfsp->f_files,
|
||||
sfsp->f_fsid);
|
||||
(void)printf("%10s fstype %#15lx flag %17ld filename "
|
||||
"length\n", sfsp->f_fstypename, sfsp->f_flag,
|
||||
sfsp->f_namemax);
|
||||
(void)printf("%10lu owner %17" PRId64 " syncwrites %12" PRId64
|
||||
" asyncwrites\n\n", (unsigned long)sfsp->f_owner,
|
||||
sfsp->f_syncwrites, sfsp->f_asyncwrites);
|
||||
|
||||
/*
|
||||
* a concession by the structured programming police to the
|
||||
* indentation police....
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if (maxwidth < 12)
|
||||
maxwidth = 12;
|
||||
if (++timesthrough == 1) {
|
||||
switch (blocksize = usize) {
|
||||
case 1024:
|
||||
header = Pflag ? "1024-blocks" : "1K-blocks";
|
||||
headerlen = (int)strlen(header);
|
||||
break;
|
||||
case 1024 * 1024:
|
||||
header = "1M-blocks";
|
||||
headerlen = (int)strlen(header);
|
||||
break;
|
||||
case 1024 * 1024 * 1024:
|
||||
header = "1G-blocks";
|
||||
headerlen = (int)strlen(header);
|
||||
break;
|
||||
default:
|
||||
if (hflag) {
|
||||
header = "Size";
|
||||
headerlen = (int)strlen(header);
|
||||
} else
|
||||
header = getbsize(&headerlen, &blocksize);
|
||||
break;
|
||||
}
|
||||
if (Pflag) {
|
||||
/*
|
||||
* either:
|
||||
* "Filesystem 1024-blocks Used Available Capacity Mounted on\n"
|
||||
* or:
|
||||
* "Filesystem 512-blocks Used Available Capacity Mounted on\n"
|
||||
*/
|
||||
if (blocksize != 1024 && blocksize != 512)
|
||||
errx(EXIT_FAILURE,
|
||||
"non-standard block size incompatible with -P");
|
||||
(void)printf("Filesystem %s Used Available Capacity "
|
||||
"Mounted on\n", header);
|
||||
} else {
|
||||
(void)printf("%-*.*s %s Used Avail %%Cap",
|
||||
maxwidth - (headerlen - 10),
|
||||
maxwidth - (headerlen - 10),
|
||||
"Filesystem", header);
|
||||
if (iflag)
|
||||
(void)printf(" iUsed iAvail %%iCap");
|
||||
(void)printf(" Mounted on\n");
|
||||
}
|
||||
}
|
||||
used = sfsp->f_blocks - sfsp->f_bfree;
|
||||
bavail = sfsp->f_bfree - sfsp->f_bresvd;
|
||||
availblks = bavail + used;
|
||||
if (Pflag) {
|
||||
assert(hflag == 0);
|
||||
assert(blocksize > 0);
|
||||
/*
|
||||
* "%s %d %d %d %s %s\n", <file system name>, <total space>,
|
||||
* <space used>, <space free>, <percentage used>,
|
||||
* <file system root>
|
||||
*/
|
||||
(void)printf("%s %" PRId64 " %" PRId64 " %" PRId64 " %s%% %s\n",
|
||||
sfsp->f_mntfromname,
|
||||
fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize),
|
||||
fsbtoblk(used, sfsp->f_frsize, blocksize),
|
||||
fsbtoblk(bavail, sfsp->f_frsize, blocksize),
|
||||
availblks == 0 ? full : strspct(pb, sizeof(pb), used,
|
||||
availblks, 0), sfsp->f_mntonname);
|
||||
/*
|
||||
* another concession by the structured programming police to
|
||||
* the indentation police....
|
||||
*
|
||||
* Note iflag cannot be set when Pflag is set.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
(void)printf("%-*.*s ", maxwidth, maxwidth, sfsp->f_mntfromname);
|
||||
|
||||
if (hflag)
|
||||
prthuman(sfsp, used, bavail);
|
||||
else
|
||||
(void)printf("%10" PRId64 " %10" PRId64 " %10" PRId64,
|
||||
fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize),
|
||||
fsbtoblk(used, sfsp->f_frsize, blocksize),
|
||||
fsbtoblk(bavail, sfsp->f_frsize, blocksize));
|
||||
(void)printf(" %3s%%",
|
||||
availblks == 0 ? full :
|
||||
strspct(pb, sizeof(pb), used, availblks, 0));
|
||||
if (iflag) {
|
||||
inodes = sfsp->f_files;
|
||||
used = inodes - sfsp->f_ffree;
|
||||
(void)printf(" %8jd %8jd %3s%%",
|
||||
(intmax_t)used, (intmax_t)sfsp->f_ffree,
|
||||
inodes == 0 ? (used == 0 ? empty : full) :
|
||||
strspct(pb, sizeof(pb), used, inodes, 0));
|
||||
}
|
||||
(void)printf(" %s\n", sfsp->f_mntonname);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [-aGgln] [-hkm|-ihkm|-Pk] [-t type] [file | "
|
||||
"file_system ...]\n",
|
||||
getprogname());
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
@ -126,10 +126,6 @@ do
|
|||
;;
|
||||
4,125) des="video output" dev=video
|
||||
;;
|
||||
4,126) des="auxiliary input" dev=kbdaux
|
||||
;;
|
||||
4,127) des="keyboard input" dev=kbd
|
||||
;;
|
||||
4,12[89]|4,1[3-8]?|4,19[01])
|
||||
p=`expr \\( $minor - 128 \\) / 16 | tr '0123' 'pqrs'`
|
||||
n=`expr $minor % 16`
|
||||
|
|
@ -196,6 +192,40 @@ do
|
|||
18,0)
|
||||
des="UNIX domain socket" dev=uds
|
||||
;;
|
||||
5[6-9],0|6[0-3],0)
|
||||
drive=`expr $major - 56`
|
||||
des="vnode disk $drive" dev=vnd$drive
|
||||
;;
|
||||
5[6-9],[1-4]|6[0-3],[1-4])
|
||||
drive=`expr $major - 56`
|
||||
par=`expr $minor - 1`
|
||||
des="vnode disk $drive partition $par" dev=vnd${drive}p${par}
|
||||
;;
|
||||
5[6-9],12[89]|5[6-9],13[0-9]|5[6-9],14[0-3]|6[0-3],12[89]|5[6-9],13[0-9]|5[6-9],14[0-3])
|
||||
drive=`expr $major - 56`
|
||||
par=`expr \\( \\( $minor - 128 \\) / 4 \\) % 4`
|
||||
sub=`expr \\( $minor - 128 \\) % 4`
|
||||
des="vnode disk $drive partition $par slice $sub"
|
||||
dev=vnd${drive}p${par}s${sub}
|
||||
;;
|
||||
64,0)
|
||||
des="keyboard input multiplexer"
|
||||
dev=kbdmux
|
||||
;;
|
||||
64,[1-4])
|
||||
n=`expr $minor - 1`
|
||||
des="keyboard input $n"
|
||||
dev=kbd$n
|
||||
;;
|
||||
64,64)
|
||||
des="mouse input multiplexer"
|
||||
dev=mousemux
|
||||
;;
|
||||
64,6[5-8])
|
||||
n=`expr $minor - 65`
|
||||
des="mouse input $n"
|
||||
dev=mouse$n
|
||||
;;
|
||||
BAD,BAD)
|
||||
des= dev=
|
||||
;;
|
||||
|
|
|
|||
57
commands/MAKEDEV/MAKEDEV.8
Normal file
57
commands/MAKEDEV/MAKEDEV.8
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
.Dd October 4, 2013
|
||||
.Dt MAKEDEV 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm MAKEDEV, DESCRIBE
|
||||
.Nd make/describe device files
|
||||
.Sh SYNOPSIS
|
||||
.Nm MAKEDEV
|
||||
.Op Fl n | Fl m
|
||||
.Op Fl r | Fl s
|
||||
.Op key ...
|
||||
.Nm DESCRIBE
|
||||
.Op device ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm MAKEDEV
|
||||
may be used to create the device files normally found in the /dev directory.
|
||||
.Nm MAKEDEV
|
||||
knows about all supported devices and will create them in the current
|
||||
directory with the proper owner and mode. For many devices
|
||||
.Nm MAKEDEV
|
||||
will not only create the device you want, but also the devices related
|
||||
to it that you will probably want too. Naming one floppy device will
|
||||
create all floppy devices for the same drive for instance.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Xxxexcludexfilexx
|
||||
.It Fl n
|
||||
echo the commands it would execute when you call it without that flag.
|
||||
.It Fl m
|
||||
echo
|
||||
.Nm mtree(8)
|
||||
formatted lines instead of creating the device nodes.
|
||||
.It Fl r
|
||||
Restricted set of devices. This set is used when generating the ramdisk.
|
||||
.It Fl s
|
||||
Standard set of devices. This set is used when popluating /dev.
|
||||
.El
|
||||
.Pp
|
||||
.Ar key
|
||||
arguments are simply the names of the devices you want to create. Call
|
||||
.Nm MAKEDEV
|
||||
without arguments to see a list of keys that it understands.
|
||||
.Pp
|
||||
The command
|
||||
.Nm DESCRIBE
|
||||
will give you a one-line description of a given device. By default It
|
||||
will list all devices in /dev.
|
||||
.Sh "SEE ALSO"
|
||||
.Xr dev 4 ,
|
||||
.Xr mknod 8
|
||||
.Sh BUGS
|
||||
The eagerness of
|
||||
.Nm MAKEDEV
|
||||
to create devices may cause many "File exists" errors from
|
||||
.Nm mknod .
|
||||
.Sh AUTHORS
|
||||
Written by Kees J. Bot (kjb@cs.vu.nl) and Lionel A. Sambuc (lionel@minix3.org)
|
||||
735
commands/MAKEDEV/MAKEDEV.sh
Normal file → Executable file
735
commands/MAKEDEV/MAKEDEV.sh
Normal file → Executable file
|
|
@ -1,43 +1,115 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# MAKEDEV 3.3 - Make special devices. Author: Kees J. Bot
|
||||
# 3.4 - Rewritten to allow mtree line to be printed, Lionel A. Sambuc
|
||||
# also use getopt for argument parsing
|
||||
umask 077
|
||||
|
||||
case $1 in
|
||||
-n) e=echo; shift ;; # Just echo when -n is given.
|
||||
*) e=
|
||||
esac
|
||||
MTREE=false
|
||||
STD=false
|
||||
RAMDISK=false
|
||||
ECHO=
|
||||
EXIT=0
|
||||
|
||||
case $#:$1 in
|
||||
1:std) # Standard devices.
|
||||
set -$- mem fd0 fd1 fd0p0 fd1p0 \
|
||||
c0d0 c0d0p0 c0d0p0s0 c0d1 c0d1p0 c0d1p0s0 \
|
||||
c0d2 c0d2p0 c0d2p0s0 c0d3 c0d3p0 c0d3p0s0 \
|
||||
c0d4 c0d4p0 c0d4p0s0 c0d5 c0d5p0 c0d5p0s0 \
|
||||
c0d6 c0d6p0 c0d6p0s0 c0d7 c0d7p0 c0d7p0s0 \
|
||||
c1d0 c1d0p0 c1d0p0s0 c1d1 c1d1p0 c1d1p0s0 \
|
||||
c1d2 c1d2p0 c1d2p0s0 c1d3 c1d3p0 c1d3p0s0 \
|
||||
c1d4 c1d4p0 c1d4p0s0 c1d5 c1d5p0 c1d5p0s0 \
|
||||
c1d6 c1d6p0 c1d6p0s0 c1d7 c1d7p0 c1d7p0s0 \
|
||||
tty ttyc1 ttyc2 ttyc3 tty00 tty01 tty02 tty03 \
|
||||
ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9 \
|
||||
ttypa ttypb ttypc ttypd ttype ttypf \
|
||||
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 \
|
||||
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf \
|
||||
eth klog random uds filter fbd hello fb0 \
|
||||
i2c-1 i2c-2 i2c-3 \
|
||||
eepromb1s50 eepromb1s51 eepromb1s52 eepromb1s53 \
|
||||
eepromb1s54 eepromb1s55 eepromb1s56 eepromb1s57 \
|
||||
eepromb2s50 eepromb2s51 eepromb2s52 eepromb2s53 \
|
||||
eepromb2s54 eepromb2s55 eepromb2s56 eepromb2s57 \
|
||||
eepromb3s50 eepromb3s51 eepromb3s52 eepromb3s53 \
|
||||
eepromb3s54 eepromb3s55 eepromb3s56 eepromb3s57 \
|
||||
tsl2550b1s39 tsl2550b2s39 tsl2550b3s39 \
|
||||
sht21b1s40 sht21b2s40 sht21b3s40 \
|
||||
# console => lp tty log
|
||||
# boot => kmem mem null ram zero
|
||||
RAMDISK_DEVICES="
|
||||
boot
|
||||
console
|
||||
input
|
||||
c0d0 c0d0p0 c0d0p0s0 c0d1 c0d1p0 c0d1p0s0
|
||||
c0d2 c0d2p0 c0d2p0s0 c0d3 c0d3p0 c0d3p0s0
|
||||
c0d4 c0d4p0 c0d4p0s0 c0d5 c0d5p0 c0d5p0s0
|
||||
c0d6 c0d6p0 c0d6p0s0 c0d7 c0d7p0 c0d7p0s0
|
||||
c1d0 c1d0p0 c1d0p0s0 c1d1 c1d1p0 c1d1p0s0
|
||||
c1d2 c1d2p0 c1d2p0s0 c1d3 c1d3p0 c1d3p0s0
|
||||
c1d4 c1d4p0 c1d4p0s0 c1d5 c1d5p0 c1d5p0s0
|
||||
c1d6 c1d6p0 c1d6p0s0 c1d7 c1d7p0 c1d7p0s0
|
||||
fd0 fd1 fd0p0 fd1p0
|
||||
ttyc1 ttyc2 ttyc3 tty00 tty01 tty02 tty03
|
||||
ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9
|
||||
ttypa ttypb ttypc ttypd ttype ttypf
|
||||
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9
|
||||
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf
|
||||
"
|
||||
|
||||
#eth => ip tcp udp
|
||||
STD_DEVICES="
|
||||
${RAMDISK_DEVICES}
|
||||
bmp085b1s77 bmp085b2s77 bmp085b3s77
|
||||
;;
|
||||
0:|1:-\?)
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [-n] key ...
|
||||
eepromb1s50 eepromb1s51 eepromb1s52 eepromb1s53
|
||||
eepromb1s54 eepromb1s55 eepromb1s56 eepromb1s57
|
||||
eepromb2s50 eepromb2s51 eepromb2s52 eepromb2s53
|
||||
eepromb2s54 eepromb2s55 eepromb2s56 eepromb2s57
|
||||
eepromb3s50 eepromb3s51 eepromb3s52 eepromb3s53
|
||||
eepromb3s54 eepromb3s55 eepromb3s56 eepromb3s57
|
||||
eth fb0 fbd filter hello
|
||||
i2c-1 i2c-2 i2c-3
|
||||
klog random
|
||||
sht21b1s40 sht21b2s40 sht21b3s40
|
||||
tsl2550b1s39 tsl2550b2s39 tsl2550b3s39
|
||||
uds
|
||||
vnd0 vnd0p0 vnd0p0s0 vnd1 vnd1p0 vnd1p0s0
|
||||
vnd2 vnd3 vnd4 vnd5 vnd6 vnd7
|
||||
"
|
||||
|
||||
#makedev ${dev} $type ${major} ${minor} ${uname} ${gname} ${permissions} [link_target]
|
||||
#When called for a link, major and minor are ignored
|
||||
makedev()
|
||||
{
|
||||
# Check that all the arguments are there, we trust the caller to put
|
||||
# values which make sens.
|
||||
[ $# -eq 7 ] || [ $# -eq 8 ] || return 1;
|
||||
|
||||
local _dev=$1
|
||||
local __type=$2
|
||||
local _major=$3
|
||||
local _minor=$4
|
||||
local _uname=$5
|
||||
local _gname=$6
|
||||
local _mode=$7
|
||||
|
||||
case ${__type} in
|
||||
b)_type=block;;
|
||||
c) _type=char;;
|
||||
l) _type=link; _target=$8;;
|
||||
*) return 2;;
|
||||
esac
|
||||
|
||||
if [ ${MTREE} = "yes" ]
|
||||
then
|
||||
if [ ${_type} = "link" ]
|
||||
then
|
||||
echo ./dev/${_dev} type=${_type} \
|
||||
uname=${_uname} gname=${_gname} mode=${_mode} \
|
||||
link=${_target}
|
||||
else
|
||||
echo ./dev/${_dev} type=${_type} \
|
||||
uname=${_uname} gname=${_gname} mode=${_mode} \
|
||||
device=native,${_major},${_minor}
|
||||
fi
|
||||
else
|
||||
if [ ${_type} = "link" ]
|
||||
then
|
||||
${ECHO} ln -f ${_target} ${_dev}
|
||||
else
|
||||
${ECHO} mknod ${_dev} ${__type} ${_major} ${_minor}
|
||||
${ECHO} chmod ${_mode} ${_dev}
|
||||
${ECHO} chown ${_uname}:${_gname} ${_dev}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# no_return usage()
|
||||
usage()
|
||||
{
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [-n|-m] [-s|-r] key ...
|
||||
-n: print the commands instead of executing them
|
||||
-m: print mtree(8) line
|
||||
-s: standard set of devices
|
||||
-r: reduced for ramdisk set of devices
|
||||
|
||||
Where key is one of the following:
|
||||
ram mem kmem null boot zero # One of these makes all these memory devices
|
||||
fb0 # Make /dev/fb0
|
||||
|
|
@ -61,280 +133,341 @@ Where key is one of the following:
|
|||
klog # Make /dev/klog
|
||||
random # Make /dev/random, /dev/urandom
|
||||
uds # Make /dev/uds
|
||||
kbd # Make /dev/kbd
|
||||
kbdaux # Make /dev/kbdaux
|
||||
filter # Make /dev/filter
|
||||
fbd # Make /dev/fbd
|
||||
hello # Make /dev/hello
|
||||
video # Make /dev/video
|
||||
std # All standard devices
|
||||
vnd0 vnd0p0 vnd0p0s0 .. # Make vnode disks /dev/vnd[0-7] and (sub)partitions
|
||||
input # Make /dev/kbdmux, /dev/kbd[0-3], idem /dev/mouse~
|
||||
EOF
|
||||
exit 1
|
||||
esac
|
||||
exit 1
|
||||
}
|
||||
|
||||
umask 077
|
||||
ex=0
|
||||
|
||||
for dev
|
||||
# Parse options
|
||||
while getopts "nmrs" arg
|
||||
do
|
||||
case $dev in # One of the controllers? Precompute major device nr.
|
||||
c0*) maj=3 ;;
|
||||
c1*) maj=8 ;;
|
||||
c2*) maj=10 ;;
|
||||
c3*) maj=12 ;;
|
||||
esac
|
||||
|
||||
case $dev in
|
||||
ram|mem|kmem|null|boot|zero|imgrd)
|
||||
# Memory devices.
|
||||
#
|
||||
$e mknod ram b 1 0; $e chmod 600 ram
|
||||
$e mknod mem c 1 1; $e chmod 640 mem
|
||||
$e mknod kmem c 1 2; $e chmod 640 kmem
|
||||
$e mknod null c 1 3; $e chmod 666 null
|
||||
$e mknod boot b 1 4; $e chmod 600 ram
|
||||
$e mknod zero c 1 5; $e chmod 644 zero
|
||||
$e mknod imgrd b 1 6; $e chmod 644 zero
|
||||
for n in 0 1 2 3 4 5
|
||||
do $e mknod ram$n b 1 $((7+$n)); $e chmod 600 ram$n
|
||||
done
|
||||
$e chgrp kmem ram* mem kmem null boot zero imgrd
|
||||
;;
|
||||
fd[0-3])
|
||||
# Floppy disk drive n.
|
||||
#
|
||||
d=`expr $dev : '.*\\(.\\)'` # Drive number.
|
||||
$e mknod $dev b 2 $d
|
||||
$e chmod 666 $dev
|
||||
;;
|
||||
pc[0-3]|at[0-3]|qd[0-3]|ps[0-3]|pat[0-3]|qh[0-3]|PS[0-3])
|
||||
# Obsolete density locked floppy disk drive n.
|
||||
#
|
||||
d=`expr $dev : '.*\\(.\\)'` # Drive number.
|
||||
m=$d # Minor device number.
|
||||
|
||||
$e mknod pc$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod at$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod qd$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod ps$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod pat$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod qh$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod PS$d b 2 $m; m=`expr $m + 4`
|
||||
|
||||
$e chmod 666 pc$d at$d qd$d ps$d pat$d qh$d PS$d
|
||||
;;
|
||||
fd[0-3]p[0-3])
|
||||
# Floppy disk partitions.
|
||||
#
|
||||
n=`expr $dev : '\\(.*\\)..'` # Name prefix.
|
||||
d=`expr $dev : '..\\(.\\)'` # Drive number.
|
||||
m=`expr 112 + $d` # Minor of partition 0.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
m=`expr 112 + $d + $p '*' 4` # Minor of partition $p.
|
||||
$e mknod ${n}p${p} b 2 $m # Make e.g. fd0p0 - fd0p3
|
||||
alldev="$alldev ${n}p${p}"
|
||||
done
|
||||
$e chmod 666 $alldev
|
||||
;;
|
||||
c[0-3]d[0-7])
|
||||
# Whole disk devices.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
m=`expr $d '*' 5` # Minor device number.
|
||||
$e mknod $dev b $maj $m
|
||||
$e chmod 600 $dev
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3])
|
||||
# Disk primary partitions.
|
||||
n=`expr $dev : '\\(.*\\).'` # Name prefix.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
m=`expr $d '*' 5 + 1 + $p` # Minor device number.
|
||||
$e mknod $n$p b $maj $m
|
||||
alldev="$alldev $n$p"
|
||||
done
|
||||
echo $alldev | xargs $e chmod 600
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3]s[0-3])
|
||||
# Disk subpartition.
|
||||
n=`expr $dev : '\\(.*\\)...'` # Name prefix.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
m=`expr 128 + $d '*' 16 + $p '*' 4 + $s` # Minor device nr.
|
||||
$e mknod ${n}${p}s${s} b $maj $m
|
||||
alldev="$alldev ${n}${p}s${s}"
|
||||
done
|
||||
done
|
||||
echo $alldev | xargs $e chmod 600
|
||||
;;
|
||||
c[0-3]t[0-7]|c[0-3]t[0-7]n)
|
||||
# Tape devices.
|
||||
n=`expr $dev : '\\(....\\)'` # Name prefix.
|
||||
t=`expr $dev : '...\\(.\\)'` # Tape number.
|
||||
m=`expr 64 + $t '*' 2` # Minor device number.
|
||||
$e mknod ${n}n c $maj $m
|
||||
$e mknod ${n} c $maj `expr $m + 1`
|
||||
$e chmod 660 ${n}n ${n}
|
||||
;;
|
||||
console|lp|tty|log|kbd|kbdaux|video)
|
||||
# Console, line printer, anonymous tty, diagnostics device,
|
||||
# raw keyboard, ps/2 mouse, video.
|
||||
$e mknod console c 4 0
|
||||
$e chmod 600 console
|
||||
$e chgrp tty console
|
||||
$e mknod tty c 5 0
|
||||
$e chmod 666 tty
|
||||
$e mknod lp c 6 0
|
||||
$e chown daemon lp
|
||||
$e chgrp daemon lp
|
||||
$e chmod 200 lp
|
||||
$e mknod log c 4 15
|
||||
$e chmod 222 log
|
||||
$e mknod kbd c 4 127
|
||||
$e mknod kbdaux c 4 126
|
||||
$e chmod 660 kbd kbdaux
|
||||
$e chgrp operator kbd kbdaux
|
||||
$e mknod video c 4 125
|
||||
$e chmod 600 video
|
||||
$e chgrp operator video
|
||||
;;
|
||||
ttyc[1-7])
|
||||
# Virtual consoles.
|
||||
#
|
||||
m=`expr $dev : '....\\(.*\\)'` # Minor device number.
|
||||
$e mknod $dev c 4 $m
|
||||
$e chgrp tty $dev
|
||||
$e chmod 600 $dev
|
||||
;;
|
||||
tty0[0-3])
|
||||
# Serial lines.
|
||||
#
|
||||
n=`expr $dev : '.*\\(.\\)'`
|
||||
$e mknod $dev c 4 `expr $n + 16`
|
||||
$e chmod 666 $dev
|
||||
$e chgrp tty $dev
|
||||
;;
|
||||
tty[p-s][0-9a-f]|pty[p-s][0-9a-f])
|
||||
# Pseudo ttys.
|
||||
#
|
||||
dev=`expr $dev : '...\\(..\\)'`
|
||||
g=`expr $dev : '\\(.\\)'` # Which group.
|
||||
g=`echo $g | tr 'pqrs' '0123'`
|
||||
n=`expr $dev : '.\\(.\\)'` # Which pty in the group.
|
||||
case $n in
|
||||
[a-f]) n=1`/bin/echo $n | tr 'abcdef' '012345'`
|
||||
case "$arg" in
|
||||
n)
|
||||
ECHO=echo
|
||||
;;
|
||||
m)
|
||||
MTREE=yes
|
||||
;;
|
||||
r)
|
||||
RAMDISK=yes
|
||||
;;
|
||||
s)
|
||||
STD=yes
|
||||
;;
|
||||
h|\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
$e mknod tty$dev c 4 `expr $g '*' 16 + $n + 128`
|
||||
$e mknod pty$dev c 4 `expr $g '*' 16 + $n + 192`
|
||||
$e chgrp tty tty$dev pty$dev
|
||||
$e chmod 666 tty$dev pty$dev
|
||||
;;
|
||||
eth|ip|tcp|udp|eth0|ip0|tcp0|udp0)
|
||||
# TCP/IP devices.
|
||||
#
|
||||
$e mknod eth0 c 7 0 # Network 0 (Ethernet)
|
||||
$e mknod ip0 c 7 1
|
||||
$e mknod tcp0 c 7 2
|
||||
$e mknod udp0 c 7 3
|
||||
$e chmod 600 eth0 ip0
|
||||
$e chmod 666 tcp0 udp0
|
||||
$e ln -f eth0 eth # Default interface
|
||||
$e ln -f ip0 ip
|
||||
$e ln -f tcp0 tcp
|
||||
$e ln -f udp0 udp
|
||||
;;
|
||||
audio|mixer)
|
||||
# Audio devices.
|
||||
#
|
||||
$e mknod audio c 13 0
|
||||
$e mknod mixer c 13 1
|
||||
$e chmod 666 audio mixer
|
||||
;;
|
||||
random|urandom)
|
||||
# random data generator.
|
||||
$e mknod random c 16 0; $e chmod 644 random
|
||||
$e mknod urandom c 16 0; $e chmod 644 urandom
|
||||
$e chgrp operator random urandom
|
||||
;;
|
||||
uds)
|
||||
# unix domain sockets device
|
||||
$e mknod uds c 18 0;
|
||||
$e chgrp operator uds
|
||||
$e chmod 666 uds
|
||||
;;
|
||||
klog)
|
||||
# logging device.
|
||||
$e mknod klog c 15 0
|
||||
$e chmod 600 klog
|
||||
;;
|
||||
filter)
|
||||
# filter driver
|
||||
$e mknod filter b 11 0
|
||||
$e chmod 600 filter
|
||||
;;
|
||||
fbd)
|
||||
# faulty block device driver
|
||||
$e mknod fbd b 14 0
|
||||
$e chmod 600 fbd
|
||||
;;
|
||||
hello)
|
||||
# hello driver
|
||||
$e mknod hello c 17 0
|
||||
$e chmod 644 hello
|
||||
;;
|
||||
fb0)
|
||||
# framebuffer driver
|
||||
$e mknod fb0 c 19 0
|
||||
$e chmod 644 fb0
|
||||
;;
|
||||
i2c-[1-3])
|
||||
# i2c driver
|
||||
b=`expr $dev : '....\\(.*\\)'` # bus number
|
||||
m=`expr $dev : '....\\(.*\\)' - 1` # least significant digit of major
|
||||
$e mknod i2c-${b} c 2${m} 0
|
||||
$e chmod 600 i2c-${b}
|
||||
;;
|
||||
eepromb[1-3]s5[0-7])
|
||||
# cat24c256 driver
|
||||
b=`expr $dev : 'eepromb\\(.*\\)s'` # bus number
|
||||
s=`expr $dev : 'eepromb.s5\\(.*\\)'` # configurable part of slave addr
|
||||
m=`expr ${b} \* 8 + ${s} + 17`
|
||||
$e mknod eepromb${b}s5${s} b ${m} 0
|
||||
$e chmod 600 eepromb${b}s5${s}
|
||||
;;
|
||||
tsl2550b[1-3]s39)
|
||||
b=`expr $dev : 'tsl2550b\\(.*\\)s39'` #bus number
|
||||
m=`expr ${b} + 46`
|
||||
$e mknod tsl2550b${b}s39 c ${m} 0
|
||||
$e chmod 444 tsl2550b${b}s39
|
||||
;;
|
||||
sht21b[1-3]s40)
|
||||
b=`expr $dev : 'sht21b\\(.*\\)s40'` #bus number
|
||||
m=`expr ${b} + 49`
|
||||
$e mknod sht21b${b}s40 c ${m} 0
|
||||
$e chmod 444 sht21b${b}s40
|
||||
;;
|
||||
bmp085b[1-3]s77)
|
||||
b=`expr $dev : 'bmp085b\\(.*\\)s77'` #bus number
|
||||
m=`expr ${b} + 52`
|
||||
$e mknod bmp085b${b}s77 c ${m} 0
|
||||
$e chmod 444 bmp085b${b}s77
|
||||
;;
|
||||
*)
|
||||
echo "$0: don't know about $dev" >&2
|
||||
ex=1
|
||||
esac
|
||||
done
|
||||
|
||||
exit $ex
|
||||
if [ ${STD} = "yes" ]
|
||||
then
|
||||
DEVICES=${STD_DEVICES}
|
||||
elif [ ${RAMDISK} = "yes" ]
|
||||
then
|
||||
DEVICES=${RAMDISK_DEVICES}
|
||||
else
|
||||
while [ $OPTIND -gt 1 ]
|
||||
do
|
||||
shift
|
||||
OPTIND=$((${OPTIND} - 1))
|
||||
done
|
||||
while [ ! -z "$1" ]
|
||||
do
|
||||
DEVICES="${DEVICES} $1"
|
||||
shift
|
||||
done
|
||||
fi
|
||||
|
||||
for dev in ${DEVICES}
|
||||
do
|
||||
# Reset the defaults
|
||||
uname=root
|
||||
gname=operator
|
||||
permissions=600
|
||||
|
||||
case ${dev} in
|
||||
c0*) major=3 ;;
|
||||
c1*) major=8 ;;
|
||||
c2*) major=10 ;;
|
||||
c3*) major=12 ;;
|
||||
vnd*) # Whole vnode disk devices.
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
major=`expr ${disk} + 56`
|
||||
;;
|
||||
esac
|
||||
|
||||
# The following is lexicographicaly ordered
|
||||
case ${dev} in
|
||||
audio|mixer)
|
||||
# Audio devices.
|
||||
makedev audio c 13 0 ${uname} ${gname} 666
|
||||
makedev mixer c 13 1 ${uname} ${gname} 666
|
||||
;;
|
||||
bmp085b[1-3]s77)
|
||||
# Weather Cape: temperature & pressure sensor
|
||||
bus=`expr ${dev} : 'bmp085b\\(.*\\)s77'` #bus number
|
||||
major=`expr ${bus} + 52`
|
||||
|
||||
makedev bmp085b${bus}s77 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
c[0-3]d[0-7])
|
||||
# Whole disk devices.
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
minor=`expr ${disk} '*' 5`
|
||||
|
||||
makedev ${dev} b ${major} ${minor} ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3])
|
||||
# Disk primary partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr ${disk} '*' 5 + 1 + ${p}`
|
||||
makedev ${prefix}${p} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3]s[0-3])
|
||||
# Disk subpartition.
|
||||
prefix=`expr ${dev} : '\\(.*\\)...'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
minor=`expr 128 + ${disk} '*' 16 + ${p} '*' 4 + ${s}`
|
||||
makedev ${prefix}${p}s${s} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
done
|
||||
;;
|
||||
c[0-3]t[0-7]|c[0-3]t[0-7]n)
|
||||
# Tape devices.
|
||||
prefix=`expr ${dev} : '\\(....\\)'`
|
||||
tape=`expr ${dev} : '...\\(.\\)'`
|
||||
minor=`expr 64 + ${tape} '*' 2`
|
||||
|
||||
makedev ${prefix}n c ${major} ${minor} ${uname} ${gname} 660
|
||||
makedev ${prefix} c ${major} `expr ${minor} + 1` ${uname} ${gname} 660
|
||||
;;
|
||||
console|lp|tty|log|video)
|
||||
# Console, line printer, anonymous tty, diagnostics device, video.
|
||||
makedev console c 4 0 ${uname} tty ${permissions}
|
||||
makedev tty c 5 0 ${uname} ${gname} 666
|
||||
makedev lp c 6 0 daemon daemon 200
|
||||
makedev log c 4 15 ${uname} ${gname} 222
|
||||
makedev video c 4 125 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
eepromb[1-3]s5[0-7])
|
||||
# cat24c256 driver
|
||||
bus=`expr ${dev} : 'eepromb\\(.*\\)s'`
|
||||
# configurable part of slave addr
|
||||
slave_low=`expr ${dev} : 'eepromb.s5\\(.*\\)'`
|
||||
major=`expr ${bus} '*' 8 + ${slave_low} + 17`
|
||||
|
||||
makedev eepromb${bus}s5${slave_low} b ${major} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
eth|ip|tcp|udp|eth0|ip0|tcp0|udp0)
|
||||
# TCP/IP devices.
|
||||
makedev ipstat c 7 0 ${uname} ${gname} 666
|
||||
makedev eth0 c 7 1 ${uname} ${gname} ${permissions}
|
||||
makedev ip0 c 7 2 ${uname} ${gname} ${permissions}
|
||||
makedev tcp0 c 7 3 ${uname} ${gname} 666
|
||||
makedev udp0 c 7 4 ${uname} ${gname} 666
|
||||
|
||||
# Default interface
|
||||
makedev eth c 7 1 ${uname} ${gname} ${permissions}
|
||||
makedev ip c 7 2 ${uname} ${gname} ${permissions}
|
||||
makedev tcp c 7 3 ${uname} ${gname} 666
|
||||
makedev udp c 7 4 ${uname} ${gname} 666
|
||||
;;
|
||||
fb0)
|
||||
# Framebuffer driver
|
||||
makedev ${dev} c 19 0 ${uname} ${gname} 644
|
||||
;;
|
||||
fbd)
|
||||
# Faulty block device driver
|
||||
makedev ${dev} b 14 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
fd[0-3])
|
||||
# Floppy disk drive N has minor N.
|
||||
minor=`expr ${dev} : '..\\(.\\)'`
|
||||
|
||||
makedev ${dev} b 2 ${minor} ${uname} ${gname} 666
|
||||
;;
|
||||
fd[0-3]p[0-3])
|
||||
# Floppy disk partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
drive=`expr ${dev} : '..\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr 112 + ${drive} + ${p} '*' 4`
|
||||
makedev ${prefix}${p} b 2 ${minor} \
|
||||
${uname} ${gname} 666
|
||||
done
|
||||
;;
|
||||
filter)
|
||||
# Filter driver
|
||||
makedev ${dev} b 11 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
hello)
|
||||
# Hello driver
|
||||
makedev ${dev} c 17 0 ${uname} ${gname} 644
|
||||
;;
|
||||
i2c-[1-3])
|
||||
# i2c driver
|
||||
bus=`expr ${dev} : '....\\(.*\\)'` # bus number
|
||||
# least significant digit of major
|
||||
major_low=`expr ${dev} : '....\\(.*\\)'`
|
||||
major_low=`expr ${major_low} - 1`
|
||||
|
||||
makedev "i2c-${bus}" c 2${major_low} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
input)
|
||||
# Input server
|
||||
makedev kbdmux c 64 0 ${uname} ${gname} ${permissions}
|
||||
makedev mousemux c 64 64 ${uname} ${gname} ${permissions}
|
||||
|
||||
for n in 0 1 2 3
|
||||
do
|
||||
minor_keyboard=`expr ${n} + 1`
|
||||
minor_mouse=`expr ${n} + 65`
|
||||
|
||||
makedev kbd${n} c 64 ${minor_keyboard} ${uname} ${gname} ${permissions}
|
||||
makedev mouse${n} c 64 ${minor_mouse} ${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
klog)
|
||||
# Logging device.
|
||||
makedev ${dev} c 15 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
pc[0-3]|at[0-3]|qd[0-3]|ps[0-3]|pat[0-3]|qh[0-3]|PS[0-3])
|
||||
# Obsolete density locked floppy disk drive n.
|
||||
drive=`expr ${dev} : '.*\\(.\\)'`
|
||||
minor=${drive}
|
||||
|
||||
for prefix in pc at qd ps pat qh PS
|
||||
do
|
||||
makedev ${prefix}${drive} b 2 ${minor} \
|
||||
${uname} ${gname} 666
|
||||
minor=`expr ${minor} + 4`
|
||||
done
|
||||
;;
|
||||
ram|mem|kmem|null|boot|zero|imgrd)
|
||||
# Memory devices.
|
||||
makedev ram b 1 0 ${uname} kmem ${permissions}
|
||||
makedev mem c 1 1 ${uname} kmem 640
|
||||
makedev kmem c 1 2 ${uname} kmem 640
|
||||
makedev null c 1 3 ${uname} kmem 666
|
||||
makedev boot b 1 4 ${uname} kmem ${permissions}
|
||||
makedev zero c 1 5 ${uname} kmem 644
|
||||
makedev imgrd b 1 6 ${uname} kmem ${permissions}
|
||||
|
||||
for n in 0 1 2 3 4 5
|
||||
do
|
||||
minor=`expr ${n} + 7`
|
||||
|
||||
makedev ram${n} b 1 ${minor} ${uname} kmem ${permissions}
|
||||
done
|
||||
;;
|
||||
random|urandom)
|
||||
# Random data generator.
|
||||
makedev random c 16 0 ${uname} ${gname} 644
|
||||
makedev urandom c 16 0 ${uname} ${gname} 644
|
||||
;;
|
||||
sht21b[1-3]s40)
|
||||
# Weather Cape: relative humidity & temperature sensor
|
||||
bus=`expr ${dev} : 'sht21b\\(.*\\)s40'`
|
||||
major=`expr ${bus} + 49`
|
||||
|
||||
makedev sht21b${bus}s40 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
tsl2550b[1-3]s39)
|
||||
# Weather Cape: ambient light sensor
|
||||
bus=`expr ${dev} : 'tsl2550b\\(.*\\)s39'`
|
||||
major=`expr ${bus} + 46`
|
||||
|
||||
makedev tsl2550b${bus}s39 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
tty0[0-3])
|
||||
# Serial lines.
|
||||
line=`expr ${dev} : '.*\\(.\\)'`
|
||||
minor=`expr ${line} + 16`
|
||||
|
||||
makedev ${dev} c 4 ${minor} ${uname} tty 666
|
||||
;;
|
||||
tty[p-s][0-9a-f]|pty[p-s][0-9a-f])
|
||||
# Pseudo ttys.
|
||||
dev=`expr ${dev} : '...\\(..\\)'`
|
||||
group=`expr ${dev} : '\\(.\\)'`
|
||||
group=`echo ${group} | tr 'pqrs' '0123'`
|
||||
pty=`expr ${dev} : '.\\(.\\)'`
|
||||
case ${pty} in
|
||||
[a-f]) pty=1`/bin/echo ${pty} | tr 'abcdef' '012345'`
|
||||
esac
|
||||
minor_tty=`expr ${group} '*' 16 + ${pty} + 128`
|
||||
minor_pty=`expr ${group} '*' 16 + ${pty} + 192`
|
||||
|
||||
makedev tty${dev} c 4 ${minor_tty} ${uname} tty 666
|
||||
makedev pty${dev} c 4 ${minor_pty} ${uname} tty 666
|
||||
;;
|
||||
ttyc[1-7])
|
||||
# Virtual consoles.
|
||||
minor=`expr ${dev} : '....\\(.*\\)'`
|
||||
|
||||
makedev ${dev} c 4 ${minor} ${uname} tty ${permissions}
|
||||
;;
|
||||
uds)
|
||||
# Unix domain sockets device
|
||||
makedev ${dev} c 18 0 ${uname} ${gname} 666
|
||||
;;
|
||||
vnd[0-7])
|
||||
# Whole vnode disk devices.
|
||||
makedev ${dev} b ${major} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
vnd[0-7]p[0-3])
|
||||
# Vnode disk primary partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr 1 + ${p}`
|
||||
|
||||
makedev ${prefix}${p} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
vnd[0-7]p[0-3]s[0-3])
|
||||
# Vnode disk subpartition.
|
||||
prefix=`expr ${dev} : '\\(.*\\)...'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
minor=`expr 128 + ${p} '*' 4 + ${s}`
|
||||
|
||||
makedev ${prefix}${p}s${s} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "$0: don't know about ${dev}" >&2
|
||||
EXIT=1
|
||||
esac
|
||||
done
|
||||
|
||||
exit $EXIT
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
SCRIPTS= MAKEDEV.sh
|
||||
MAN=
|
||||
MAN= MAKEDEV.8
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ SUBDIR= add_route arp ash at backup btrace \
|
|||
cawf cd cdprobe cpp \
|
||||
chmod chown ci cleantmp cmp co \
|
||||
compress cp crc cron crontab \
|
||||
dd decomp16 DESCRIBE devmand devsize df dhcpd \
|
||||
dhrystone diff diskctl dumpcore \
|
||||
dd decomp16 DESCRIBE devmand devsize dhcpd \
|
||||
dhrystone diff diskctl \
|
||||
eject factor fbdctl \
|
||||
find fix format fortune fsck.mfs \
|
||||
gcore gcov-pull getty grep host \
|
||||
gcov-pull getty grep host \
|
||||
hostaddr id ifconfig ifdef \
|
||||
intr ipcrm ipcs irdpd isoread last \
|
||||
less loadkeys loadramdisk logger look lp \
|
||||
|
|
@ -27,7 +27,7 @@ SUBDIR= add_route arp ash at backup btrace \
|
|||
stty svclog svrctl swifi synctree sysenv \
|
||||
syslogd tail tcpd tcpdp tcpstat telnet \
|
||||
telnetd term termcap tget time touch \
|
||||
truncate udpstat umount uname \
|
||||
truncate udpstat umount \
|
||||
unstack update uud uue version vol \
|
||||
whereis which writeisofs fetch \
|
||||
zdump zmodem pkgin_cd pkgin_all \
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
PROG= df
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
237
commands/df/df.c
237
commands/df/df.c
|
|
@ -1,237 +0,0 @@
|
|||
/* df - disk free block printout Author: Andy Tanenbaum
|
||||
*
|
||||
* 91/04/30 Kees J. Bot (kjb@cs.vu.nl)
|
||||
* Map filename arguments to the devices they live on.
|
||||
* Changed output to show percentages.
|
||||
*
|
||||
* 92/12/12 Kees J. Bot
|
||||
* Posixized. (Almost, the normal output is in kilobytes, it should
|
||||
* be 512-byte units. 'df -P' and 'df -kP' are as it should be.)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <minix/minlib.h>
|
||||
|
||||
struct mtab { /* List of mounted devices from /etc/mtab. */
|
||||
struct mtab *next;
|
||||
dev_t device;
|
||||
char *devname;
|
||||
char *mountpoint;
|
||||
} *mtab= NULL;
|
||||
|
||||
struct mtab *searchtab(char *name);
|
||||
static void readmtab(const char *type);
|
||||
int df(const struct mtab *mt);
|
||||
|
||||
int iflag= 0; /* Focus on inodes instead of blocks. */
|
||||
int Pflag= 0; /* Posix standard output. */
|
||||
int kflag= 0; /* Output in kilobytes instead of 512 byte units for -P. */
|
||||
int istty; /* isatty(1) */
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: df [-ikP] [-t type] [device]...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int unitsize;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
struct mtab *mt;
|
||||
char *type= "dev";
|
||||
int ex= 0;
|
||||
|
||||
while (argc > 1 && argv[1][0] == '-') {
|
||||
char *opt= argv[1]+1;
|
||||
|
||||
while (*opt != 0) {
|
||||
switch (*opt++) {
|
||||
case 'i': iflag= 1; break;
|
||||
case 'k': kflag= 1; break;
|
||||
case 'P': Pflag= 1; break;
|
||||
case 't':
|
||||
if (argc < 3) usage();
|
||||
type= argv[2];
|
||||
argv++;
|
||||
argc--;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
istty= isatty(1);
|
||||
|
||||
readmtab(type);
|
||||
|
||||
if(!Pflag || (Pflag && kflag)) unitsize = 1024;
|
||||
else unitsize = 512;
|
||||
|
||||
if (Pflag) {
|
||||
if (!iflag)
|
||||
printf("\
|
||||
Filesystem %4d-blocks Used Available Capacity Mounted on\n",
|
||||
unitsize);
|
||||
else
|
||||
printf("\
|
||||
Filesystem Inodes IUsed IFree %%IUsed Mounted on\n"
|
||||
);
|
||||
} else {
|
||||
printf("%s\n", !iflag ? "\
|
||||
Filesystem Size (kB) Free Used % Files% Mounted on" : "\
|
||||
Filesystem Files Free Used % BUsed% Mounted on"
|
||||
);
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
for (mt= mtab; mt != NULL; mt= mt->next) ex |= df(mt);
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) ex |= df(searchtab(argv[i]));
|
||||
}
|
||||
exit(ex);
|
||||
}
|
||||
|
||||
static void readmtab(const char *type)
|
||||
/* Turn the mounted file table into a list. */
|
||||
{
|
||||
struct mtab **amt= &mtab, *new;
|
||||
struct stat st;
|
||||
char devname[PATH_MAX], mountpoint[PATH_MAX], version[MNTNAMELEN],
|
||||
rw_flag[MNTFLAGLEN];
|
||||
|
||||
if (load_mtab("df") < 0) exit(1);
|
||||
|
||||
while (get_mtab_entry(devname, mountpoint, version, rw_flag),
|
||||
devname[0] != 0) {
|
||||
if (strcmp(type, "dev") != 0 && strcmp(type, version) != 0) continue;
|
||||
|
||||
/* Make new list cell. */
|
||||
if ((new= (struct mtab *) malloc(sizeof(*new))) == NULL
|
||||
|| (new->devname= (char *) malloc(strlen(devname) + 1)) == NULL
|
||||
|| (new->mountpoint= (char *) malloc(strlen(mountpoint) + 1)) == NULL
|
||||
) break;
|
||||
|
||||
if (strcmp(devname, "none") != 0 && stat(devname, &st) == 0 &&
|
||||
S_ISBLK(st.st_mode)) {
|
||||
new->device= st.st_rdev;
|
||||
} else if (stat(mountpoint, &st) == 0) {
|
||||
new->device= st.st_dev;
|
||||
}
|
||||
strcpy(new->devname, devname);
|
||||
strcpy(new->mountpoint, mountpoint);
|
||||
|
||||
*amt= new; /* Add the cell to the end. */
|
||||
amt= &new->next;
|
||||
*amt= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct mtab *searchtab(char *name)
|
||||
/* See what we can do with a user supplied name, there are three possibilities:
|
||||
* 1. It's a device and it is in the mtab: Return mtab entry.
|
||||
* 2. It's a file and lives on a device in the mtab: Return mtab entry.
|
||||
* 3. It's anything else: Return something df() will choke on.
|
||||
*/
|
||||
{
|
||||
static struct mtab unknown;
|
||||
struct mtab *mt;
|
||||
struct stat st;
|
||||
|
||||
unknown.devname= name;
|
||||
unknown.mountpoint= "";
|
||||
|
||||
if (stat(name, &st) < 0) return &unknown; /* Case 3. */
|
||||
|
||||
unknown.device= S_ISBLK(st.st_mode) ? st.st_rdev : st.st_dev;
|
||||
|
||||
for (mt= mtab; mt != NULL; mt= mt->next) {
|
||||
if (unknown.device == mt->device)
|
||||
return mt; /* Case 1 & 2. */
|
||||
}
|
||||
|
||||
return &unknown; /* Case 3. */
|
||||
}
|
||||
|
||||
/* (num / tot) in percentages rounded up. */
|
||||
#define percent(num, tot) \
|
||||
((tot > 0) ? ((int) ((100ULL * (num) + ((tot) - 1)) / (tot))) : 0)
|
||||
|
||||
int df(const struct mtab *mt)
|
||||
{
|
||||
long totblocks, busyblocks, totinodes, busyinodes;
|
||||
struct statvfs sv;
|
||||
int n;
|
||||
|
||||
if (statvfs(mt->mountpoint, &sv) < 0) {
|
||||
fprintf(stderr, "df: %s: %s\n", mt->devname, strerror(errno));
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Print results. */
|
||||
printf("%s", mt->devname);
|
||||
n= strlen(mt->devname);
|
||||
if (n > 15 && istty) { putchar('\n'); n= 0; }
|
||||
while (n < 15) { putchar(' '); n++; }
|
||||
|
||||
totblocks = sv.f_blocks;
|
||||
busyblocks = sv.f_blocks - sv.f_bfree;
|
||||
|
||||
busyblocks = busyblocks * (sv.f_bsize/512) / (unitsize/512);
|
||||
totblocks = totblocks * (sv.f_bsize/512) / (unitsize/512);
|
||||
|
||||
totinodes = sv.f_files;
|
||||
busyinodes = sv.f_files - sv.f_ffree;
|
||||
|
||||
if (!Pflag && !iflag) {
|
||||
printf(" %9ld %9ld %9ld %3d%% %3d%% %s\n",
|
||||
totblocks, /* Blocks */
|
||||
totblocks - busyblocks, /* free */
|
||||
busyblocks, /* used */
|
||||
percent(busyblocks, totblocks), /* % */
|
||||
percent(busyinodes, totinodes), /* FUsed% */
|
||||
mt->mountpoint /* Mounted on */
|
||||
);
|
||||
}
|
||||
if (!Pflag && iflag) {
|
||||
printf(" %9ld %9ld %9ld %3d%% %3d%% %s\n",
|
||||
totinodes, /* Files */
|
||||
totinodes - busyinodes, /* free */
|
||||
busyinodes, /* used */
|
||||
percent(busyinodes, totinodes), /* % */
|
||||
percent(busyblocks, totblocks), /* BUsed% */
|
||||
mt->mountpoint /* Mounted on */
|
||||
);
|
||||
}
|
||||
if (Pflag && !iflag) {
|
||||
printf(" %9ld %9ld %9ld %4d%% %s\n",
|
||||
totblocks, /* Blocks */
|
||||
busyblocks, /* Used */
|
||||
totblocks - busyblocks, /* Available */
|
||||
percent(busyblocks, totblocks), /* Capacity */
|
||||
mt->mountpoint /* Mounted on */
|
||||
);
|
||||
}
|
||||
if (Pflag && iflag) {
|
||||
printf(" %9ld %9ld %9ld %4d%% %s\n",
|
||||
totinodes, /* Inodes */
|
||||
busyinodes, /* IUsed */
|
||||
totinodes - busyinodes, /* IAvail */
|
||||
percent(busyinodes, totinodes), /* Capacity */
|
||||
mt->mountpoint /* Mounted on */
|
||||
);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
PROG= dumpcore
|
||||
CPPFLAGS+= -I${NETBSDSRCDIR}
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/* dumpcore - create core file of running process */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <minix/config.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/ipc.h>
|
||||
#include <minix/const.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <timers.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
#define CLICK_WORDS (CLICK_SIZE / sizeof(unsigned long))
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
int r, status;
|
||||
|
||||
if(argc != 2) {
|
||||
printf("usage: %s <pid>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid = atoi(argv[1]);
|
||||
|
||||
if (ptrace(T_ATTACH, pid, 0, 0) != 0) {
|
||||
perror("ptrace(T_ATTACH)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (waitpid(pid, &status, 0) != pid) {
|
||||
perror("waitpid");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (WIFSTOPPED(status) && WSTOPSIG(status) != SIGSTOP) {
|
||||
/* whatever happens here is fine */
|
||||
ptrace(T_RESUME, pid, 0, WSTOPSIG(status));
|
||||
|
||||
if (waitpid(pid, &status, 0) != pid) {
|
||||
perror("waitpid");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!WIFSTOPPED(status)) {
|
||||
fprintf(stderr, "process died while attaching\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ptrace(T_DUMPCORE, pid, 0, 0) != 0) {
|
||||
fprintf(stderr, "warning, dumpcore failed (%s)\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (ptrace(T_DETACH, pid, 0, 0)) {
|
||||
fprintf(stderr, "warning, detaching failed (%s)\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ char *secbuf;
|
|||
int badbases;
|
||||
int badsizes;
|
||||
int badorders;
|
||||
char *devname;
|
||||
char *dev_name;
|
||||
int nhead;
|
||||
int nsec;
|
||||
int ncyl = 1024;
|
||||
|
|
@ -161,9 +161,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (argn == argc)
|
||||
devname = DEFAULT_DEV;
|
||||
dev_name = DEFAULT_DEV;
|
||||
else if (argn == argc - 1)
|
||||
devname = argv[argn];
|
||||
dev_name = argv[argn];
|
||||
else
|
||||
usage();
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ void getgeom(void)
|
|||
|
||||
if (override) return;
|
||||
|
||||
if ((fd= open(devname, O_RDONLY)) < 0) return;
|
||||
if ((fd= open(dev_name, O_RDONLY)) < 0) return;
|
||||
|
||||
r = ioctl(fd, DIOCGETP, &geom);
|
||||
close(fd);
|
||||
|
|
@ -242,21 +242,21 @@ void getgeom(void)
|
|||
nsec = geom.sectors;
|
||||
ncyl = geom.cylinders;
|
||||
|
||||
printf("Geometry of %s: %dx%dx%d\n", devname, ncyl, nhead, nsec);
|
||||
printf("Geometry of %s: %dx%dx%d\n", dev_name, ncyl, nhead, nsec);
|
||||
}
|
||||
|
||||
static int devfd;
|
||||
|
||||
void getboot(char *buffer)
|
||||
{
|
||||
devfd = open(devname, 2);
|
||||
devfd = open(dev_name, 2);
|
||||
if (devfd < 0) {
|
||||
printf("No write permission on %s\n", devname);
|
||||
printf("No write permission on %s\n", dev_name);
|
||||
readonly = 1;
|
||||
devfd = open(devname, 0);
|
||||
devfd = open(dev_name, 0);
|
||||
}
|
||||
if (devfd < 0) {
|
||||
printf("Cannot open device %s\n", devname);
|
||||
printf("Cannot open device %s\n", dev_name);
|
||||
exit(1);
|
||||
}
|
||||
if (read(devfd, buffer, SECSIZE) != SECSIZE) {
|
||||
|
|
@ -264,7 +264,7 @@ void getboot(char *buffer)
|
|||
exit(1);
|
||||
}
|
||||
if (* (unsigned short *) &buffer[510] != 0xAA55) {
|
||||
printf("Invalid boot sector on %s.\n", devname);
|
||||
printf("Invalid boot sector on %s.\n", dev_name);
|
||||
printf("Partition table reset and boot code installed.\n");
|
||||
memset(buffer, 0, 512);
|
||||
memcpy(buffer, bootstrap, sizeof(bootstrap));
|
||||
|
|
@ -514,8 +514,8 @@ int chk_table(void)
|
|||
printf(
|
||||
"Disk appears to have mis-specified number of heads or sectors.\n");
|
||||
printf("Try fdisk -h%d -s%d %s instead of\n",
|
||||
maxhead + 1, maxsec, devname);
|
||||
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, devname);
|
||||
maxhead + 1, maxsec, dev_name);
|
||||
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, dev_name);
|
||||
seenpart = 0;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -695,12 +695,12 @@ void getboot(char *buffer)
|
|||
|
||||
segread(&sregs); /* get ds */
|
||||
|
||||
if (devname[1] != ':') {
|
||||
printf("Invalid drive %s\n", devname);
|
||||
if (dev_name[1] != ':') {
|
||||
printf("Invalid drive %s\n", dev_name);
|
||||
exit(1);
|
||||
}
|
||||
if (*devname >= 'a') *devname += 'A' - 'a';
|
||||
drivenum = (*devname - 'C') & 0xff;
|
||||
if (*dev_name >= 'a') *dev_name += 'A' - 'a';
|
||||
drivenum = (*dev_name - 'C') & 0xff;
|
||||
if (drivenum < 0 || drivenum > 7) {
|
||||
printf("Funny drive number %d\n", drivenum);
|
||||
exit(1);
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ char **clist;
|
|||
if (input(buf, 80)) ip->i_mode = atoo(buf);
|
||||
printf(" nlinks = %6u", ip->i_nlinks);
|
||||
if (input(buf, 80)) ip->i_nlinks = atol(buf);
|
||||
printf(" size = %6ld", ip->i_size);
|
||||
printf(" size = %6d", ip->i_size);
|
||||
if (input(buf, 80)) ip->i_size = atol(buf);
|
||||
if (yes("Write this back")) {
|
||||
devwrite(inoblock(ino), inooff(ino), (char *) ip,
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
PROG= gcore
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* gcore - create core file of running process */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
||||
if(argc != 2) {
|
||||
printf("usage: %s <pid>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid = atoi(argv[1]);
|
||||
|
||||
if (ptrace(T_ATTACH, pid, 0, 0) != 0) {
|
||||
perror("ptrace(T_ATTACH)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (waitpid(pid, &status, 0) != pid) {
|
||||
perror("waitpid");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (WIFSTOPPED(status) && WSTOPSIG(status) != SIGSTOP) {
|
||||
/* whatever happens here is fine */
|
||||
ptrace(T_RESUME, pid, 0, WSTOPSIG(status));
|
||||
|
||||
if (waitpid(pid, &status, 0) != pid) {
|
||||
perror("waitpid");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!WIFSTOPPED(status)) {
|
||||
fprintf(stderr, "process died while attaching\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ptrace(T_DUMPCORE, pid, 0, 0)) {
|
||||
fprintf(stderr, "warning, dumpcore failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (ptrace(T_DETACH, pid, 0, 0)) {
|
||||
fprintf(stderr, "warning, detaching failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ void do_getty(char *name, size_t len, char **args, const char *ttyname)
|
|||
int ch;
|
||||
struct utsname utsname;
|
||||
char **banner, *t;
|
||||
static char *def_banner[] = { "%s Release %r Version %v (%t)\n\n%n login: ", 0 };
|
||||
static char *def_banner[] = { "%s/%p (%t)\n\n%n login: ", 0 };
|
||||
|
||||
/* Clean up tty name. */
|
||||
if((t = strrchr(ttyname, '/'))) ttyname = t + 1;
|
||||
|
|
|
|||
|
|
@ -6,86 +6,51 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if __minix_vmd
|
||||
#define KBD_DEVICE "/dev/kbd"
|
||||
#else
|
||||
#define KBD_DEVICE "/dev/console"
|
||||
#endif
|
||||
|
||||
u16_t keymap[NR_SCAN_CODES * MAP_COLS];
|
||||
u8_t comprmap[4 + NR_SCAN_CODES * MAP_COLS * 9/8 * 2 + 1];
|
||||
|
||||
|
||||
void tell(char *s)
|
||||
{
|
||||
write(2, s, strlen(s));
|
||||
}
|
||||
|
||||
|
||||
void fatal(char *say)
|
||||
{
|
||||
int err = errno;
|
||||
tell("loadkeys: ");
|
||||
if (say != NULL) {
|
||||
tell(say);
|
||||
tell(": ");
|
||||
}
|
||||
tell(strerror(err));
|
||||
tell("\n");
|
||||
exit(1);
|
||||
fprintf(stderr, "loadkeys: %s: %s\n", say, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
tell("Usage: loadkeys mapfile\n");
|
||||
exit(1);
|
||||
fprintf(stderr, "usage: loadkeys <mapfile>\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
u8_t *cm;
|
||||
u16_t *km;
|
||||
int fd, n, fb;
|
||||
char sig[4];
|
||||
keymap_t keymap;
|
||||
int fd;
|
||||
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
if ((fd = open(argv[1], O_RDONLY)) < 0) fatal(argv[1]);
|
||||
|
||||
if (read(fd, comprmap, sizeof(comprmap)) < 0) fatal(argv[1]);
|
||||
if (read(fd, sig, sizeof(sig)) < sizeof(sig)) fatal(argv[1]);
|
||||
|
||||
if (memcmp(comprmap, KEY_MAGIC, 4) != 0) {
|
||||
tell("loadkeys: ");
|
||||
tell(argv[1]);
|
||||
tell(": not a keymap file\n");
|
||||
exit(1);
|
||||
if (memcmp(sig, KEY_MAGIC, sizeof(sig)) != 0) {
|
||||
fprintf(stderr, "loadkeys: %s: not a keymap file\n", argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (read(fd, keymap, sizeof(keymap)) < sizeof(keymap)) fatal(argv[1]);
|
||||
|
||||
close(fd);
|
||||
|
||||
/* Decompress the keymap data. */
|
||||
cm = comprmap + 4;
|
||||
n = 8;
|
||||
for (km = keymap; km < keymap + NR_SCAN_CODES * MAP_COLS; km++) {
|
||||
if (n == 8) {
|
||||
/* Need a new flag byte. */
|
||||
fb = *cm++;
|
||||
n = 0;
|
||||
}
|
||||
*km = *cm++; /* Low byte. */
|
||||
if (fb & (1 << n)) {
|
||||
*km |= (*cm++ << 8); /* One of the few special keys. */
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
if ((fd = open(KBD_DEVICE, O_WRONLY)) < 0) fatal(KBD_DEVICE);
|
||||
|
||||
if (ioctl(fd, KIOCSMAP, keymap) < 0) fatal(KBD_DEVICE);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ int main(argc, argv)
|
|||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int all = 0, i, v = 0, mountflags;
|
||||
int all = 0, i, v = 0, mountflags, srvflags;
|
||||
char **ap, *opt, *err, *type, *args, *device;
|
||||
|
||||
if (argc == 1) list(); /* just list /etc/mtab */
|
||||
mountflags = 0;
|
||||
srvflags = 0;
|
||||
type = NULL;
|
||||
args = NULL;
|
||||
ap = argv+1;
|
||||
|
|
@ -36,12 +37,12 @@ char *argv[];
|
|||
if (argv[i][0] == '-') {
|
||||
opt = argv[i]+1;
|
||||
while (*opt != 0) switch (*opt++) {
|
||||
case 'r': mountflags |= MS_RDONLY; break;
|
||||
case 'r': mountflags |= MNT_RDONLY; break;
|
||||
case 't': if (++i == argc) usage();
|
||||
type = argv[i];
|
||||
break;
|
||||
case 'i': mountflags |= MS_REUSE; break;
|
||||
case 'e': mountflags |= MS_EXISTING; break;
|
||||
case 'i': srvflags |= MS_REUSE; break;
|
||||
case 'e': srvflags |= MS_EXISTING; break;
|
||||
case 'n': write_mtab = 0; break;
|
||||
case 'o': if (++i == argc) usage();
|
||||
args = argv[i];
|
||||
|
|
@ -75,7 +76,7 @@ char *argv[];
|
|||
}
|
||||
}
|
||||
|
||||
if (mount(device, argv[2], mountflags, type, args) < 0) {
|
||||
if (mount(device, argv[2], mountflags, srvflags, type, args) < 0) {
|
||||
err = strerror(errno);
|
||||
fprintf(stderr, "mount: Can't mount %s on %s: %s\n",
|
||||
argv[1], argv[2], err);
|
||||
|
|
@ -141,7 +142,7 @@ mount_all()
|
|||
if (has_opt(fs->fs_mntops, "ro"))
|
||||
ro = 1;
|
||||
if (ro) {
|
||||
mountflags |= MS_RDONLY;
|
||||
mountflags |= MNT_RDONLY;
|
||||
}
|
||||
|
||||
device = fs->fs_spec;
|
||||
|
|
@ -152,7 +153,7 @@ mount_all()
|
|||
if (!strcmp(device, "none"))
|
||||
device = NULL;
|
||||
|
||||
if (mount(device, mountpoint, mountflags, fs->fs_vfstype,
|
||||
if (mount(device, mountpoint, mountflags, 0, fs->fs_vfstype,
|
||||
fs->fs_mntops) != 0) {
|
||||
err = strerror(errno);
|
||||
fprintf(stderr, "mount: Can't mount %s on %s: %s\n",
|
||||
|
|
|
|||
|
|
@ -66,15 +66,36 @@ void usage()
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
int open_audio(unsigned int *fragment_size, unsigned int channels,
|
||||
unsigned int samples_per_sec, unsigned int bits)
|
||||
{
|
||||
unsigned int sign;
|
||||
int audio;
|
||||
|
||||
/* Open DSP */
|
||||
if ((audio = open("/dev/audio", O_RDWR | O_REOPEN)) < 0)
|
||||
{
|
||||
printf("Cannot open /dev/audio: %s\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ioctl(audio, DSPIOMAX, fragment_size); /* Get maximum fragment size. */
|
||||
|
||||
/* Set DSP parameters (should check return values..) */
|
||||
ioctl(audio, DSPIOSIZE, fragment_size); /* Use max. fragment size. */
|
||||
ioctl(audio, DSPIOSTEREO, &channels);
|
||||
ioctl(audio, DSPIORATE, &samples_per_sec);
|
||||
ioctl(audio, DSPIOBITS, &bits);
|
||||
sign = (bits == 16 ? 1 : 0);
|
||||
ioctl(audio, DSPIOSIGN, &sign);
|
||||
return audio;
|
||||
}
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
int i, r, audio, file;
|
||||
char *buffer, *file_name = NULL;
|
||||
unsigned int sign;
|
||||
unsigned int fragment_size;
|
||||
unsigned int channels;
|
||||
unsigned int bits;
|
||||
unsigned int fragment_size, fragment_size2;
|
||||
long data_pos;
|
||||
int showinfo = 0;
|
||||
|
||||
|
|
@ -91,22 +112,6 @@ int main ( int argc, char *argv[] )
|
|||
}
|
||||
else file_name = argv[1];
|
||||
|
||||
/* Open DSP */
|
||||
if ((audio = open("/dev/audio", O_RDWR | O_REOPEN)) < 0)
|
||||
{
|
||||
printf("Cannot open /dev/audio: %s\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Get maximum fragment size and try to allocate a buffer */
|
||||
ioctl(audio, DSPIOMAX, &fragment_size);
|
||||
if ((buffer = malloc(fragment_size)) == (char *)0)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate buffer\n");
|
||||
exit(-1);
|
||||
}
|
||||
ioctl(audio, DSPIOSIZE, &fragment_size);
|
||||
|
||||
/* Open wav file */
|
||||
if((file = open(file_name, O_RDONLY)) < 0)
|
||||
{
|
||||
|
|
@ -141,15 +146,15 @@ int main ( int argc, char *argv[] )
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Set DSP parameters */
|
||||
channels = c_fields.Channels;
|
||||
channels--;
|
||||
bits = s_fields.BitsPerSample;
|
||||
ioctl(audio, DSPIOSTEREO, &channels);
|
||||
ioctl(audio, DSPIORATE, &c_fields.SamplesPerSec);
|
||||
ioctl(audio, DSPIOBITS, &bits);
|
||||
sign = (bits == 16 ? 1 : 0);
|
||||
ioctl(audio, DSPIOSIGN, &sign);
|
||||
/* Open audio device and set DSP parameters */
|
||||
audio = open_audio(&fragment_size, c_fields.Channels - 1,
|
||||
c_fields.SamplesPerSec, s_fields.BitsPerSample);
|
||||
|
||||
if ((buffer = malloc(fragment_size)) == (char *)0)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate buffer\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Goto data chunk */
|
||||
lseek(file, data_pos, SEEK_SET);
|
||||
|
|
@ -203,6 +208,20 @@ int main ( int argc, char *argv[] )
|
|||
{
|
||||
fprintf(stderr, "playwave: write to audio device failed: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
/* If we get EIO, the driver might have restarted. Reopen the
|
||||
* audio device.
|
||||
*/
|
||||
if (errno == EIO) {
|
||||
close(audio);
|
||||
audio = open_audio(&fragment_size2,
|
||||
c_fields.Channels - 1, c_fields.SamplesPerSec,
|
||||
s_fields.BitsPerSample);
|
||||
if (fragment_size2 != fragment_size) {
|
||||
fprintf(stderr, "Fragment size has changed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ static char *prrecv(struct pstat *ps)
|
|||
case FSTATE_LOCK: blkstr = "flock"; break;
|
||||
case FSTATE_POPEN: blkstr = "popen"; break;
|
||||
case FSTATE_SELECT: blkstr = "select"; break;
|
||||
case FSTATE_DOPEN: blkstr = "dopen"; break;
|
||||
case FSTATE_TASK: blkstr = taskname(ps->ps_ftask); break;
|
||||
default: blkstr = "??"; break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -519,7 +519,7 @@ static void do_io(config_t *cpe, struct rs_start *rs_start)
|
|||
|
||||
static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
|
||||
{
|
||||
u16_t vid, did;
|
||||
u16_t vid, did, sub_vid, sub_did;
|
||||
char *check, *check2;
|
||||
|
||||
/* Process a list of PCI device IDs */
|
||||
|
|
@ -536,13 +536,26 @@ static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
|
|||
cpe->file, cpe->line);
|
||||
}
|
||||
vid= strtoul(cpe->word, &check, 0x10);
|
||||
if (check[0] == '/')
|
||||
did= strtoul(check+1, &check2, 0x10);
|
||||
if (check[0] != '/' || check2[0] != '\0')
|
||||
{
|
||||
if (check[0] != ':' && /* LEGACY: */ check[0] != '/') {
|
||||
fatal("do_pci_device: bad ID '%s' at %s:%d",
|
||||
cpe->word, cpe->file, cpe->line);
|
||||
}
|
||||
did= strtoul(check+1, &check, 0x10);
|
||||
if (check[0] == '/') {
|
||||
sub_vid= strtoul(check+1, &check, 0x10);
|
||||
if (check[0] == ':')
|
||||
sub_did= strtoul(check+1, &check2, 0x10);
|
||||
if (check[0] != ':' || check2[0] != '\0') {
|
||||
fatal("do_pci_device: bad ID '%s' at %s:%d",
|
||||
cpe->word, cpe->file, cpe->line);
|
||||
}
|
||||
} else if (check[0] != '\0') {
|
||||
fatal("do_pci_device: bad ID '%s' at %s:%d",
|
||||
cpe->word, cpe->file, cpe->line);
|
||||
} else {
|
||||
sub_vid = NO_SUB_VID;
|
||||
sub_did = NO_SUB_DID;
|
||||
}
|
||||
if (rs_start->rss_nr_pci_id >= RS_NR_PCI_DEVICE)
|
||||
{
|
||||
fatal("do_pci_device: too many device IDs (max %d)",
|
||||
|
|
@ -550,6 +563,8 @@ static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
|
|||
}
|
||||
rs_start->rss_pci_id[rs_start->rss_nr_pci_id].vid= vid;
|
||||
rs_start->rss_pci_id[rs_start->rss_nr_pci_id].did= did;
|
||||
rs_start->rss_pci_id[rs_start->rss_nr_pci_id].sub_vid= sub_vid;
|
||||
rs_start->rss_pci_id[rs_start->rss_nr_pci_id].sub_did= sub_did;
|
||||
rs_start->rss_nr_pci_id++;
|
||||
}
|
||||
}
|
||||
|
|
@ -734,6 +749,7 @@ struct
|
|||
{ "PROCCTL", VM_PROCCTL },
|
||||
{ "MAPCACHEPAGE", VM_MAPCACHEPAGE },
|
||||
{ "SETCACHEPAGE", VM_SETCACHEPAGE },
|
||||
{ "CLEARCACHE", VM_CLEARCACHE },
|
||||
{ "VFS_MMAP", VM_VFS_MMAP },
|
||||
{ "VFS_REPLY", VM_VFS_REPLY },
|
||||
{ NULL, 0 },
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ service \- Manage an operating system service.
|
|||
.PP
|
||||
\fBservice [-b -c -n -p -r] (up|run|edit|update)\fR \fI<binary|self>\fR
|
||||
[\fB-args\fR \fI<args>\fR] [\fB-dev\fR \fI<special>\fR]
|
||||
[\fB-devstyle\fR \fI<style>\fR] [\fB-period\fR \fI<ticks>\fR]
|
||||
[\fB-period\fR \fI<ticks>\fR]
|
||||
[\fB-script\fR \fI<path>\fR] [\fB-label\fR \fI<name>\fR]
|
||||
[\fB-config\fR \fI<path>\fR] [\fB-state\fR \fI<state>\fR]
|
||||
[\fB-maxtime\fR \fI<time>\fR]
|
||||
|
|
@ -103,12 +103,6 @@ given by \fI<binary>\fR. The default is to use no arguments.
|
|||
specifies the device file to associate to the system service (used only for
|
||||
device drivers). The default is to associate no device file to the service.
|
||||
.TP
|
||||
.BI \-devstyle " <style>"
|
||||
specifies the device style to associate to the system service (used only for
|
||||
device drivers). The list of supported device styles is available in
|
||||
the header file \fB<minix/dmap.h>\fR.
|
||||
The default is to associate no device style (\fBSTYLE_NDEV\fR) to the service.
|
||||
.TP
|
||||
.BI \-period " <ticks>"
|
||||
specifies the period to use for the system service.
|
||||
When a period is specified, \fBRS\fR sends a ping request to
|
||||
|
|
@ -160,7 +154,7 @@ label \fI<name>\fR. This action can be used to dynamically update the
|
|||
properties of any system service, including those contained in the
|
||||
boot image (e.g. \fBVM\fR). There are a few exceptions to the properties
|
||||
that can be actually overridden dynamically. For example, the device file
|
||||
and the device style associated to the service will no be updated. This
|
||||
associated to the service will no be updated. This
|
||||
action takes the same options supported by the \fBup\fR action.
|
||||
.PP
|
||||
.SS
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include <configfile.h>
|
||||
|
||||
#include <machine/archtypes.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <err.h>
|
||||
#include "kernel/proc.h"
|
||||
|
||||
|
|
@ -86,7 +86,6 @@ static char *known_requests[] = {
|
|||
#define ARG_ARGS "-args" /* list of arguments to be passed */
|
||||
#define ARG_DEV "-dev" /* major device number for drivers */
|
||||
#define ARG_MAJOR "-major" /* major number */
|
||||
#define ARG_DEVSTYLE "-devstyle" /* device style */
|
||||
#define ARG_PERIOD "-period" /* heartbeat period in ticks */
|
||||
#define ARG_SCRIPT "-script" /* name of the script to restart a
|
||||
* system service
|
||||
|
|
@ -113,7 +112,6 @@ static char *req_path_self = SELF_REQ_PATH;
|
|||
static char *req_args = "";
|
||||
static int req_major = 0;
|
||||
static int devman_id = 0;
|
||||
static int req_dev_style = STYLE_NDEV;
|
||||
static long req_period = 0;
|
||||
static char *req_script = NULL;
|
||||
static char *req_config = PATH_CONFIG;
|
||||
|
|
@ -131,9 +129,9 @@ static void print_usage(char *app_name, char *problem)
|
|||
fprintf(stderr, "Warning, %s\n", problem);
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr,
|
||||
" %s [%s %s %s %s] (up|run|edit|update) <binary|%s> [%s <args>] [%s <special>] [%s <style>] [%s <major_nr>] [%s <dev_id>] [%s <ticks>] [%s <path>] [%s <name>] [%s <path>] [%s <state>] [%s <time>]\n",
|
||||
" %s [%s %s %s %s] (up|run|edit|update) <binary|%s> [%s <args>] [%s <special>] [%s <major_nr>] [%s <dev_id>] [%s <ticks>] [%s <path>] [%s <name>] [%s <path>] [%s <state>] [%s <time>]\n",
|
||||
app_name, OPT_COPY, OPT_REUSE, OPT_NOBLOCK, OPT_REPLICA, SELF_BINARY,
|
||||
ARG_ARGS, ARG_DEV, ARG_DEVSTYLE, ARG_MAJOR, ARG_DEVMANID, ARG_PERIOD, ARG_SCRIPT,
|
||||
ARG_ARGS, ARG_DEV, ARG_MAJOR, ARG_DEVMANID, ARG_PERIOD, ARG_SCRIPT,
|
||||
ARG_LABELNAME, ARG_CONFIG, ARG_LU_STATE, ARG_LU_MAXTIME);
|
||||
fprintf(stderr, " %s down <label>\n", app_name);
|
||||
fprintf(stderr, " %s refresh <label>\n", app_name);
|
||||
|
|
@ -315,9 +313,6 @@ static int parse_arguments(int argc, char **argv, u32_t *rss_flags)
|
|||
exit(EINVAL);
|
||||
}
|
||||
req_major = major(stat_buf.st_rdev);
|
||||
if(req_dev_style == STYLE_NDEV) {
|
||||
req_dev_style = STYLE_DEV;
|
||||
}
|
||||
}
|
||||
else if (strcmp(argv[i], ARG_MAJOR)==0) {
|
||||
if (req_major != 0) {
|
||||
|
|
@ -329,26 +324,7 @@ static int parse_arguments(int argc, char **argv, u32_t *rss_flags)
|
|||
} else {
|
||||
exit(EINVAL);
|
||||
}
|
||||
if(req_dev_style == STYLE_NDEV) {
|
||||
req_dev_style = STYLE_DEV;
|
||||
}
|
||||
}
|
||||
else if (strcmp(argv[i], ARG_DEVSTYLE)==0) {
|
||||
char* dev_style_keys[] = { "STYLE_DEV", "STYLE_DEVA", "STYLE_TTY",
|
||||
"STYLE_CTTY", "STYLE_CLONE", "STYLE_CLONE_A", NULL };
|
||||
int dev_style_values[] = { STYLE_DEV, STYLE_DEVA, STYLE_TTY,
|
||||
STYLE_CTTY, STYLE_CLONE, STYLE_CLONE_A };
|
||||
for(j=0;dev_style_keys[j]!=NULL;j++) {
|
||||
if(!strcmp(dev_style_keys[j], argv[i+1])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(dev_style_keys[j] == NULL) {
|
||||
print_usage(argv[ARG_NAME], "bad device style");
|
||||
exit(EINVAL);
|
||||
}
|
||||
req_dev_style = dev_style_values[j];
|
||||
}
|
||||
else if (strcmp(argv[i], ARG_SCRIPT)==0) {
|
||||
req_script = argv[i+1];
|
||||
}
|
||||
|
|
@ -466,7 +442,6 @@ int main(int argc, char **argv)
|
|||
config.rs_start.rss_cmd= command;
|
||||
config.rs_start.rss_cmdlen= strlen(command);
|
||||
config.rs_start.rss_major= req_major;
|
||||
config.rs_start.rss_dev_style= req_dev_style;
|
||||
config.rs_start.rss_period= req_period;
|
||||
config.rs_start.rss_script= req_script;
|
||||
config.rs_start.devman_id= devman_id;
|
||||
|
|
|
|||
|
|
@ -432,9 +432,9 @@ then
|
|||
|
||||
# Get sizes and space availability while the file systems are still
|
||||
# mounted. Otherwise we have to mount them again just for this.
|
||||
required_root_space=`df -k /dev/$root | awk '{print $4}' | tail -n 1`
|
||||
free_root_space=`df -k /dev/$root | awk '{print $3}' | tail -n 1`
|
||||
free_usr_space=`df -k /dev/$usr | awk '{print $3}' | tail -n 1`
|
||||
required_root_space=`df -kP /dev/$root | awk '{print $3}' | tail -n 1`
|
||||
free_root_space=`df -kP /dev/$root | awk '{print $4}' | tail -n 1`
|
||||
free_usr_space=`df -kP /dev/$usr | awk '{print $4}' | tail -n 1`
|
||||
|
||||
umount /mnt/usr && umount /mnt || exit
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ char *argv[];
|
|||
|
||||
found = find_mtab_entry(name);
|
||||
|
||||
if (umount2(name, umount_flags) < 0) {
|
||||
if (umount(name, umount_flags) < 0) {
|
||||
if (errno == EINVAL)
|
||||
std_err("umount: Device not mounted\n");
|
||||
else if (errno == ENOTBLK)
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
PROG= uname
|
||||
MAN=
|
||||
|
||||
LINKS+= ${BINDIR}/uname ${BINDIR}/arch
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
/* uname - print system name Author: Earl Chew */
|
||||
|
||||
/* Print the following system information as returned by the uname()
|
||||
* function:
|
||||
*
|
||||
* system name Minix
|
||||
* node name waddles
|
||||
* release name 1.5
|
||||
* version 10
|
||||
* machine name i86
|
||||
* arch i86 (Minix specific)
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Define the uname components. */
|
||||
#define ALL ((unsigned) 0x1F)
|
||||
#define SYSNAME ((unsigned) 0x01)
|
||||
#define NODENAME ((unsigned) 0x02)
|
||||
#define RELEASE ((unsigned) 0x04)
|
||||
#define U_MACHINE ((unsigned) 0x10)
|
||||
#define ARCH ((unsigned) 0x20)
|
||||
|
||||
int main(int argc, char **argv );
|
||||
void print(int fd, ... );
|
||||
void usage(void );
|
||||
|
||||
#ifdef __STDC__
|
||||
void print(int fd, ...)
|
||||
#else
|
||||
void print(fd)
|
||||
int fd;
|
||||
#endif
|
||||
{
|
||||
/* Print a sequence of strings onto the named channel. */
|
||||
va_list argp;
|
||||
char *p;
|
||||
|
||||
va_start(argp, fd);
|
||||
while (1) {
|
||||
p = va_arg(argp, char *);
|
||||
if (p == (char *) NULL) break;
|
||||
write(fd, p, strlen(p));
|
||||
}
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
char *name;
|
||||
|
||||
void usage()
|
||||
{
|
||||
print(STDERR_FILENO, "Usage: ", name, " -snrvmpa\n", (char *) NULL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int info;
|
||||
char *p;
|
||||
struct utsname un;
|
||||
|
||||
name = strrchr(argv[0], '/');
|
||||
if (name == NULL) name = argv[0]; else name++;
|
||||
|
||||
for (info = 0; argc > 1; argc--, argv++) {
|
||||
if (argv[1][0] == '-') {
|
||||
for (p = &argv[1][1]; *p; p++) {
|
||||
switch (*p) {
|
||||
case 'a': info |= ALL; break;
|
||||
case 'm': info |= U_MACHINE; break;
|
||||
case 'n': info |= NODENAME; break;
|
||||
case 'r': info |= RELEASE; break;
|
||||
case 's': info |= SYSNAME; break;
|
||||
case 'v': info |= RELEASE; break;
|
||||
case 'p': info |= ARCH; break;
|
||||
default: usage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (info == 0) info = strcmp(name, "arch") == 0 ? ARCH : SYSNAME;
|
||||
|
||||
if (uname(&un) != 0) {
|
||||
print(STDERR_FILENO, "unable to determine uname values\n", (char *) NULL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if ((info & SYSNAME) != 0)
|
||||
print(STDOUT_FILENO, un.sysname, (char *) NULL);
|
||||
if ((info & NODENAME) != 0) {
|
||||
if ((info & (SYSNAME)) != 0)
|
||||
print(STDOUT_FILENO, " ", (char *) NULL);
|
||||
print(STDOUT_FILENO, un.nodename, (char *) NULL);
|
||||
}
|
||||
if ((info & RELEASE) != 0) {
|
||||
if ((info & (SYSNAME|NODENAME)) != 0)
|
||||
print(STDOUT_FILENO, " ", (char *) NULL);
|
||||
print(STDOUT_FILENO, un.release, (char *) NULL);
|
||||
print(STDOUT_FILENO, ".", (char *) NULL);
|
||||
print(STDOUT_FILENO, un.version, (char *) NULL);
|
||||
}
|
||||
if ((info & U_MACHINE) != 0) {
|
||||
if ((info & (SYSNAME|NODENAME|RELEASE)) != 0)
|
||||
print(STDOUT_FILENO, " ", (char *) NULL);
|
||||
print(STDOUT_FILENO, un.machine, (char *) NULL);
|
||||
}
|
||||
if ((info & ARCH) != 0) {
|
||||
if ((info & (SYSNAME|NODENAME|RELEASE|U_MACHINE)) != 0)
|
||||
print(STDOUT_FILENO, " ", (char *) NULL);
|
||||
print(STDOUT_FILENO, un.arch, (char *) NULL);
|
||||
}
|
||||
print(STDOUT_FILENO, "\n", (char *) NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,18 +1,16 @@
|
|||
./boot/minix/.temp/mod07_log minix-sys
|
||||
./boot/minix/.temp/mod08_tty minix-sys
|
||||
./boot/minix/.temp/mod09_mfs minix-sys
|
||||
./boot/minix/.temp/mod10_vm minix-sys
|
||||
./boot/minix/.temp/mod11_pfs minix-sys
|
||||
./boot/minix/.temp/mod12_init minix-sys
|
||||
./boot/minix/.temp/mod07_tty minix-sys
|
||||
./boot/minix/.temp/mod08_mfs minix-sys
|
||||
./boot/minix/.temp/mod09_vm minix-sys
|
||||
./boot/minix/.temp/mod10_pfs minix-sys
|
||||
./boot/minix/.temp/mod11_init minix-sys
|
||||
./etc/rc.capes minix-sys
|
||||
./etc/rc.capes/BB-BONE-WTHR-01 minix-sys
|
||||
./etc/system.conf.d/lan8710a minix-sys
|
||||
./multiboot/mod07_log minix-sys
|
||||
./multiboot/mod08_tty minix-sys
|
||||
./multiboot/mod09_mfs minix-sys
|
||||
./multiboot/mod10_vm minix-sys
|
||||
./multiboot/mod11_pfs minix-sys
|
||||
./multiboot/mod12_init minix-sys
|
||||
./multiboot/mod07_tty minix-sys
|
||||
./multiboot/mod08_mfs minix-sys
|
||||
./multiboot/mod09_vm minix-sys
|
||||
./multiboot/mod10_pfs minix-sys
|
||||
./multiboot/mod11_init minix-sys
|
||||
./sbin/gpio minix-sys
|
||||
./usr/bin/eepromread minix-sys
|
||||
./usr/include/arm minix-sys
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
./boot/minix/.temp/mod07_log minix-sys
|
||||
./boot/minix/.temp/mod08_tty minix-sys
|
||||
./boot/minix/.temp/mod09_mfs minix-sys
|
||||
./boot/minix/.temp/mod10_vm minix-sys
|
||||
./boot/minix/.temp/mod11_pfs minix-sys
|
||||
./boot/minix/.temp/mod12_init minix-sys
|
||||
./boot/minix/.temp/mod07_tty minix-sys
|
||||
./boot/minix/.temp/mod08_mfs minix-sys
|
||||
./boot/minix/.temp/mod09_vm minix-sys
|
||||
./boot/minix/.temp/mod10_pfs minix-sys
|
||||
./boot/minix/.temp/mod11_init minix-sys
|
||||
./etc/system.conf.d/atl2 minix-sys
|
||||
./etc/system.conf.d/dec21140A minix-sys
|
||||
./etc/system.conf.d/e1000 minix-sys
|
||||
|
|
@ -13,16 +12,16 @@
|
|||
./etc/system.conf.d/rtl8139 minix-sys
|
||||
./etc/system.conf.d/rtl8169 minix-sys
|
||||
./etc/system.conf.d/virtio_net minix-sys
|
||||
./multiboot/mod07_log minix-sys
|
||||
./multiboot/mod08_tty minix-sys
|
||||
./multiboot/mod09_mfs minix-sys
|
||||
./multiboot/mod10_vm minix-sys
|
||||
./multiboot/mod11_pfs minix-sys
|
||||
./multiboot/mod12_init minix-sys
|
||||
./multiboot/mod07_tty minix-sys
|
||||
./multiboot/mod08_mfs minix-sys
|
||||
./multiboot/mod09_vm minix-sys
|
||||
./multiboot/mod10_pfs minix-sys
|
||||
./multiboot/mod11_init minix-sys
|
||||
./sbin/ahci minix-sys
|
||||
./sbin/at_wini minix-sys
|
||||
./sbin/floppy minix-sys
|
||||
./sbin/hgfs minix-sys
|
||||
./sbin/pckbd minix-sys
|
||||
./sbin/vbfs minix-sys
|
||||
./sbin/virtio_blk minix-sys
|
||||
./usr/include/gcc-4.5/abmintrin.h minix-sys gcccmds
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -6,25 +6,25 @@
|
|||
.if ${MKIMAGEONLY} == "yes"
|
||||
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
SUBDIR= at_wini floppy log tty pci
|
||||
SUBDIR= at_wini floppy tty pci pckbd
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_ARCH} == "earm"
|
||||
SUBDIR= log tty
|
||||
SUBDIR= tty
|
||||
.endif
|
||||
|
||||
.else # ${MKIMAGEONLY} != "yes"
|
||||
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
SUBDIR= ahci amddev atl2 at_wini audio dec21140A dp8390 dpeth \
|
||||
e1000 fbd filter floppy fxp hello lance log mmc orinoco pci printer \
|
||||
random readclock rtl8139 rtl8169 ti1225 tty vbox acpi \
|
||||
virtio_blk virtio_net
|
||||
e1000 fbd filter floppy fxp hello lance log mmc orinoco pci pckbd \
|
||||
printer random readclock rtl8139 rtl8169 ti1225 tty uds vbox acpi \
|
||||
virtio_blk virtio_net vnd
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_ARCH} == "earm"
|
||||
SUBDIR= bmp085 cat24c256 fb gpio i2c mmc lan8710a log readclock \
|
||||
sht21 tda19988 tps65217 tps65950 tsl2550 tty random
|
||||
sht21 tda19988 tps65217 tps65950 tsl2550 tty random uds vnd
|
||||
.endif
|
||||
|
||||
.endif # ${MKIMAGEONLY} != "yes"
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ static struct port_state {
|
|||
struct device part[DEV_PER_DRIVE]; /* partition bases and sizes */
|
||||
struct device subpart[SUB_PER_DRIVE]; /* same for subpartitions */
|
||||
|
||||
timer_t timer; /* port-specific timeout timer */
|
||||
minix_timer_t timer; /* port-specific timeout timer */
|
||||
int left; /* number of tries left before giving up */
|
||||
/* (only used for signature probing) */
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ static struct port_state {
|
|||
u32_t pend_mask; /* commands not yet complete */
|
||||
struct {
|
||||
thread_id_t tid;/* ID of the worker thread */
|
||||
timer_t timer; /* timer associated with each request */
|
||||
minix_timer_t timer; /* timer associated with each request */
|
||||
int result; /* success/failure result of the commands */
|
||||
} cmd_info[NR_CMDS];
|
||||
} port_state[NR_PORTS];
|
||||
|
|
@ -232,36 +232,33 @@ static void port_set_cmd(struct port_state *ps, int cmd, cmd_fis_t *fis,
|
|||
u8_t packet[ATAPI_PACKET_SIZE], prd_t *prdt, int nr_prds, int write);
|
||||
static void port_issue(struct port_state *ps, int cmd, clock_t timeout);
|
||||
static int port_exec(struct port_state *ps, int cmd, clock_t timeout);
|
||||
static void port_timeout(struct timer *tp);
|
||||
static void port_timeout(minix_timer_t *tp);
|
||||
static void port_disconnect(struct port_state *ps);
|
||||
|
||||
static char *ahci_portname(struct port_state *ps);
|
||||
static int ahci_open(dev_t minor, int access);
|
||||
static int ahci_close(dev_t minor);
|
||||
static ssize_t ahci_transfer(dev_t minor, int do_write, u64_t position,
|
||||
static int ahci_open(devminor_t minor, int access);
|
||||
static int ahci_close(devminor_t minor);
|
||||
static ssize_t ahci_transfer(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, iovec_t *iovec, unsigned int count, int flags);
|
||||
static struct device *ahci_part(dev_t minor);
|
||||
static struct device *ahci_part(devminor_t minor);
|
||||
static void ahci_alarm(clock_t stamp);
|
||||
static int ahci_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant);
|
||||
static int ahci_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
static void ahci_intr(unsigned int mask);
|
||||
static int ahci_device(dev_t minor, device_id_t *id);
|
||||
static struct port_state *ahci_get_port(dev_t minor);
|
||||
static int ahci_device(devminor_t minor, device_id_t *id);
|
||||
static struct port_state *ahci_get_port(devminor_t minor);
|
||||
|
||||
/* AHCI driver table. */
|
||||
static struct blockdriver ahci_dtab = {
|
||||
BLOCKDRIVER_TYPE_DISK,
|
||||
ahci_open,
|
||||
ahci_close,
|
||||
ahci_transfer,
|
||||
ahci_ioctl,
|
||||
NULL, /* bdr_cleanup */
|
||||
ahci_part,
|
||||
NULL, /* bdr_geometry */
|
||||
ahci_intr,
|
||||
ahci_alarm,
|
||||
NULL, /* bdr_other */
|
||||
ahci_device
|
||||
.bdr_type = BLOCKDRIVER_TYPE_DISK,
|
||||
.bdr_open = ahci_open,
|
||||
.bdr_close = ahci_close,
|
||||
.bdr_transfer = ahci_transfer,
|
||||
.bdr_ioctl = ahci_ioctl,
|
||||
.bdr_part = ahci_part,
|
||||
.bdr_intr = ahci_intr,
|
||||
.bdr_alarm = ahci_alarm,
|
||||
.bdr_device = ahci_device
|
||||
};
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -1715,7 +1712,7 @@ static void port_intr(struct port_state *ps)
|
|||
/*===========================================================================*
|
||||
* port_timeout *
|
||||
*===========================================================================*/
|
||||
static void port_timeout(struct timer *tp)
|
||||
static void port_timeout(minix_timer_t *tp)
|
||||
{
|
||||
/* A timeout has occurred on this port. Figure out what the timeout is
|
||||
* for, and take appropriate action.
|
||||
|
|
@ -2422,7 +2419,7 @@ static char *ahci_portname(struct port_state *ps)
|
|||
/*===========================================================================*
|
||||
* ahci_map_minor *
|
||||
*===========================================================================*/
|
||||
static struct port_state *ahci_map_minor(dev_t minor, struct device **dvp)
|
||||
static struct port_state *ahci_map_minor(devminor_t minor, struct device **dvp)
|
||||
{
|
||||
/* Map a minor device number to a port and a pointer to the partition's
|
||||
* device structure. Return NULL if this minor device number does not
|
||||
|
|
@ -2433,7 +2430,7 @@ static struct port_state *ahci_map_minor(dev_t minor, struct device **dvp)
|
|||
|
||||
ps = NULL;
|
||||
|
||||
if (minor < NR_MINORS) {
|
||||
if (minor >= 0 && minor < NR_MINORS) {
|
||||
port = ahci_map[minor / DEV_PER_DRIVE];
|
||||
|
||||
if (port == NO_PORT)
|
||||
|
|
@ -2458,7 +2455,7 @@ static struct port_state *ahci_map_minor(dev_t minor, struct device **dvp)
|
|||
/*===========================================================================*
|
||||
* ahci_part *
|
||||
*===========================================================================*/
|
||||
static struct device *ahci_part(dev_t minor)
|
||||
static struct device *ahci_part(devminor_t minor)
|
||||
{
|
||||
/* Return a pointer to the partition information structure of the given
|
||||
* minor device.
|
||||
|
|
@ -2474,7 +2471,7 @@ static struct device *ahci_part(dev_t minor)
|
|||
/*===========================================================================*
|
||||
* ahci_open *
|
||||
*===========================================================================*/
|
||||
static int ahci_open(dev_t minor, int access)
|
||||
static int ahci_open(devminor_t minor, int access)
|
||||
{
|
||||
/* Open a device.
|
||||
*/
|
||||
|
|
@ -2500,7 +2497,7 @@ static int ahci_open(dev_t minor, int access)
|
|||
return ENXIO;
|
||||
|
||||
/* Some devices may only be opened in read-only mode. */
|
||||
if ((ps->flags & FLAG_READONLY) && (access & W_BIT))
|
||||
if ((ps->flags & FLAG_READONLY) && (access & BDEV_W_BIT))
|
||||
return EACCES;
|
||||
|
||||
if (ps->open_count == 0) {
|
||||
|
|
@ -2543,7 +2540,7 @@ static int ahci_open(dev_t minor, int access)
|
|||
/*===========================================================================*
|
||||
* ahci_close *
|
||||
*===========================================================================*/
|
||||
static int ahci_close(dev_t minor)
|
||||
static int ahci_close(devminor_t minor)
|
||||
{
|
||||
/* Close a device.
|
||||
*/
|
||||
|
|
@ -2599,7 +2596,7 @@ static int ahci_close(dev_t minor)
|
|||
/*===========================================================================*
|
||||
* ahci_transfer *
|
||||
*===========================================================================*/
|
||||
static ssize_t ahci_transfer(dev_t minor, int do_write, u64_t position,
|
||||
static ssize_t ahci_transfer(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, iovec_t *iovec, unsigned int count, int flags)
|
||||
{
|
||||
/* Perform data transfer on the selected device.
|
||||
|
|
@ -2634,8 +2631,8 @@ static ssize_t ahci_transfer(dev_t minor, int do_write, u64_t position,
|
|||
/*===========================================================================*
|
||||
* ahci_ioctl *
|
||||
*===========================================================================*/
|
||||
static int ahci_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant)
|
||||
static int ahci_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* Process I/O control requests.
|
||||
*/
|
||||
|
|
@ -2685,13 +2682,13 @@ static int ahci_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
|||
sizeof(val));
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* ahci_device *
|
||||
*===========================================================================*/
|
||||
static int ahci_device(dev_t minor, device_id_t *id)
|
||||
static int ahci_device(devminor_t minor, device_id_t *id)
|
||||
{
|
||||
/* Map a minor device number to a device ID.
|
||||
*/
|
||||
|
|
@ -2709,7 +2706,7 @@ static int ahci_device(dev_t minor, device_id_t *id)
|
|||
/*===========================================================================*
|
||||
* ahci_get_port *
|
||||
*===========================================================================*/
|
||||
static struct port_state *ahci_get_port(dev_t minor)
|
||||
static struct port_state *ahci_get_port(devminor_t minor)
|
||||
{
|
||||
/* Get the port structure associated with the given minor device.
|
||||
* Called only from worker threads, so the minor device is already
|
||||
|
|
|
|||
|
|
@ -264,7 +264,6 @@ typedef struct vumap_phys prd_t;
|
|||
*/
|
||||
#define MAX_DRIVES 8
|
||||
#define NR_MINORS (MAX_DRIVES * DEV_PER_DRIVE)
|
||||
#define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS)
|
||||
#define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE)
|
||||
|
||||
/* Port states. */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#define VERBOSE 0 /* display identify messages during boot */
|
||||
#define VERBOSE_DMA 0 /* display DMA debugging information */
|
||||
#define ENABLE_ATAPI 1 /* add ATAPI cd-rom support to driver */
|
||||
|
||||
#define ATAPI_DEBUG 0 /* To debug ATAPI code. */
|
||||
|
||||
|
|
@ -129,7 +128,6 @@
|
|||
* regular LBA.
|
||||
*/
|
||||
|
||||
#if ENABLE_ATAPI
|
||||
#define ERROR_SENSE 0xF0 /* sense key mask */
|
||||
#define SENSE_NONE 0x00 /* no sense key */
|
||||
#define SENSE_RECERR 0x10 /* recovered error */
|
||||
|
|
@ -156,7 +154,6 @@
|
|||
#define REG_CNT_LO 4 /* low byte of cylinder number */
|
||||
#define REG_CNT_HI 5 /* high byte of cylinder number */
|
||||
#define REG_DRIVE 6 /* drive select */
|
||||
#endif
|
||||
|
||||
#define REG_STATUS 7 /* status */
|
||||
#define STATUS_BSY 0x80 /* controller busy */
|
||||
|
|
@ -167,15 +164,10 @@
|
|||
#define STATUS_CORR 0x04 /* correctable error occurred */
|
||||
#define STATUS_CHECK 0x01 /* check error */
|
||||
|
||||
#if ENABLE_ATAPI
|
||||
#define ATAPI_PACKETCMD 0xA0 /* packet command */
|
||||
#define ATAPI_IDENTIFY 0xA1 /* identify drive */
|
||||
#define SCSI_READ10 0x28 /* read from disk */
|
||||
#define SCSI_SENSE 0x03 /* sense request */
|
||||
#endif /* ATAPI */
|
||||
|
||||
/* Interrupt request lines. */
|
||||
#define NO_IRQ 0 /* no IRQ set yet */
|
||||
|
||||
#define ATAPI_PACKETSIZE 12
|
||||
#define SENSE_PACKETSIZE 18
|
||||
|
|
@ -185,17 +177,16 @@
|
|||
#define ERR_BAD_SECTOR (-2) /* block marked bad detected */
|
||||
|
||||
/* Some controllers don't interrupt, the clock will wake us up. */
|
||||
#define WAKEUP_SECS 32 /* drive may be out for 31 seconds max */
|
||||
#define WAKEUP_SECS 32 /* drive may be out for 31 seconds max */
|
||||
#define WAKEUP_TICKS (WAKEUP_SECS*system_hz)
|
||||
|
||||
/* Miscellaneous. */
|
||||
#define MAX_DRIVES 8
|
||||
#define COMPAT_DRIVES 4
|
||||
#define MAX_DRIVES 4 /* max number of actual drives per instance */
|
||||
#define MAX_DRIVENODES 8 /* number of drive nodes, for node numbering */
|
||||
#define MAX_SECS 256 /* controller can transfer this many sectors */
|
||||
#define MAX_ERRORS 4 /* how often to try rd/wt before quitting */
|
||||
#define NR_MINORS (MAX_DRIVES * DEV_PER_DRIVE)
|
||||
#define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS)
|
||||
#define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE)
|
||||
#define NR_MINORS (MAX_DRIVENODES * DEV_PER_DRIVE)
|
||||
#define NR_SUBDEVS (MAX_DRIVENODES * SUB_PER_DRIVE)
|
||||
#define DELAY_USECS 1000 /* controller timeout in microseconds */
|
||||
#define DELAY_TICKS 1 /* controller timeout in ticks */
|
||||
#define DEF_TIMEOUT_USECS 5000000L /* controller timeout in microseconds */
|
||||
|
|
@ -204,18 +195,15 @@
|
|||
#define INITIALIZED 0x01 /* drive is initialized */
|
||||
#define DEAF 0x02 /* controller must be reset */
|
||||
#define SMART 0x04 /* drive supports ATA commands */
|
||||
#if ENABLE_ATAPI
|
||||
#define ATAPI 0x08 /* it is an ATAPI device */
|
||||
#else
|
||||
#define ATAPI 0 /* don't bother with ATAPI; optimise out */
|
||||
#endif
|
||||
#define IDENTIFIED 0x10 /* w_identify done successfully */
|
||||
#define IGNORING 0x20 /* w_identify failed once */
|
||||
|
||||
#define NO_DMA_VAR "ata_no_dma"
|
||||
|
||||
/* BIOS parameter table layout. */
|
||||
#define bp_cylinders(t) (t[0] | (t[1] << 8))
|
||||
#define bp_heads(t) (t[2])
|
||||
#define bp_precomp(t) (t[5] | (t[6] << 8))
|
||||
#define bp_sectors(t) (t[14])
|
||||
#define ATA_IF_NATIVE0 (1L << 0) /* first channel is in native mode */
|
||||
#define ATA_IF_NATIVE1 (1L << 2) /* second channel is in native mode */
|
||||
|
||||
extern int sef_cb_lu_prepare(int state);
|
||||
extern int sef_cb_lu_state_isvalid(int state);
|
||||
extern void sef_cb_lu_state_dump(int state);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ service atl2
|
|||
UMAP # 14
|
||||
IRQCTL # 19
|
||||
;
|
||||
pci device 1969/2048;
|
||||
pci device 1969:2048;
|
||||
ipc
|
||||
SYSTEM pm rs tty ds vm
|
||||
pci inet lwip
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ int drv_stop(int sub_dev)
|
|||
|
||||
|
||||
/* all IO-ctl's sent to the upper driver are passed to this function */
|
||||
int drv_io_ctl(int request, void * val, int * len, int sub_dev) {
|
||||
int drv_io_ctl(unsigned long request, void * val, int * len, int sub_dev) {
|
||||
|
||||
int status;
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ int drv_stop(int sub_dev)
|
|||
|
||||
|
||||
/* all IO-ctl's sent to the upper driver are passed to this function */
|
||||
int drv_io_ctl(int request, void * val, int * len, int sub_dev) {
|
||||
int drv_io_ctl(unsigned long request, void * val, int * len, int sub_dev) {
|
||||
|
||||
int status;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ static int get_set_output(struct inout_ctrl *output, int flag);
|
|||
/*=========================================================================*
|
||||
* mixer_ioctl
|
||||
*=========================================================================*/
|
||||
int mixer_ioctl(int request, void *val, int *UNUSED(len)) {
|
||||
int mixer_ioctl(unsigned long request, void *val, int *UNUSED(len)) {
|
||||
int status;
|
||||
|
||||
switch(request) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define SB16_MIXER_H
|
||||
|
||||
int mixer_init(void);
|
||||
int mixer_ioctl(int request, void *val, int *len);
|
||||
int mixer_ioctl(unsigned long request, void *val, int *len);
|
||||
|
||||
int mixer_set(int reg, int data);
|
||||
int mixer_get(int reg);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
static void dsp_dma_setup(phys_bytes address, int count, int sub_dev);
|
||||
|
||||
static int dsp_ioctl(int request, void *val, int *len);
|
||||
static int dsp_ioctl(unsigned long request, void *val, int *len);
|
||||
static int dsp_set_size(unsigned int size);
|
||||
static int dsp_set_speed(unsigned int speed);
|
||||
static int dsp_set_stereo(unsigned int stereo);
|
||||
|
|
@ -141,7 +141,7 @@ int drv_start(int channel, int DmaMode) {
|
|||
dsp_set_speed(DspSpeed);
|
||||
|
||||
/* Put the speaker on */
|
||||
if(DmaMode == DEV_WRITE_S) {
|
||||
if(DmaMode == WRITE_DMA) {
|
||||
dsp_command (DSP_CMD_SPKON); /* put speaker on */
|
||||
|
||||
/* Program DSP with dma mode */
|
||||
|
|
@ -232,8 +232,9 @@ int drv_resume(int UNUSED(chan)) {
|
|||
|
||||
|
||||
|
||||
int drv_io_ctl(int request, void *val, int *len, int sub_dev) {
|
||||
Dprint(("dsp_ioctl: got ioctl %d, argument: %d sub_dev: %d\n", request, val, sub_dev));
|
||||
int drv_io_ctl(unsigned long request, void *val, int *len, int sub_dev) {
|
||||
Dprint(("dsp_ioctl: got ioctl %lu, argument: %d sub_dev: %d\n",
|
||||
request, val, sub_dev));
|
||||
|
||||
if(sub_dev == AUDIO) {
|
||||
return dsp_ioctl(request, val, len);
|
||||
|
|
@ -262,7 +263,7 @@ int drv_get_frag_size(u32_t *frag_size, int UNUSED(sub_dev)) {
|
|||
|
||||
|
||||
|
||||
static int dsp_ioctl(int request, void *val, int *len) {
|
||||
static int dsp_ioctl(unsigned long request, void *val, int *len) {
|
||||
int status;
|
||||
|
||||
switch(request) {
|
||||
|
|
@ -293,7 +294,7 @@ static void dsp_dma_setup(phys_bytes address, int count, int DmaMode) {
|
|||
pv_set(pvb[1], DMA8_CLEAR, 0x00); /* Clear flip flop */
|
||||
|
||||
/* set DMA mode */
|
||||
pv_set(pvb[2], DMA8_MODE, (DmaMode == DEV_WRITE_S ? DMA8_AUTO_PLAY : DMA8_AUTO_REC));
|
||||
pv_set(pvb[2], DMA8_MODE, (DmaMode == WRITE_DMA ? DMA8_AUTO_PLAY : DMA8_AUTO_REC));
|
||||
|
||||
pv_set(pvb[3], DMA8_ADDR, (u8_t)(address >> 0)); /* Low_byte of address */
|
||||
pv_set(pvb[4], DMA8_ADDR, (u8_t)(address >> 8)); /* High byte of address */
|
||||
|
|
@ -311,7 +312,7 @@ static void dsp_dma_setup(phys_bytes address, int count, int DmaMode) {
|
|||
pv_set(pvb[1], DMA16_CLEAR, 0x00); /* Clear flip flop */
|
||||
|
||||
/* Set dma mode */
|
||||
pv_set(pvb[2], DMA16_MODE, (DmaMode == DEV_WRITE_S ? DMA16_AUTO_PLAY : DMA16_AUTO_REC));
|
||||
pv_set(pvb[2], DMA16_MODE, (DmaMode == WRITE_DMA ? DMA16_AUTO_PLAY : DMA16_AUTO_REC));
|
||||
|
||||
pv_set(pvb[3], DMA16_ADDR, (address >> 1) & 0xFF); /* Low_byte of address */
|
||||
pv_set(pvb[4], DMA16_ADDR, (address >> 9) & 0xFF); /* High byte of address */
|
||||
|
|
|
|||
|
|
@ -151,11 +151,9 @@ static int read_cal_coef(void);
|
|||
static int measure(int32_t * temperature, int32_t * pressure);
|
||||
|
||||
/* libchardriver callbacks */
|
||||
static struct device *bmp085_prepare(dev_t UNUSED(dev));
|
||||
static int bmp085_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags));
|
||||
static int bmp085_other(message * m);
|
||||
static ssize_t bmp085_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static void bmp085_other(message * m, int ipc_status);
|
||||
|
||||
/* SEF Function */
|
||||
static int sef_cb_lu_state_save(int);
|
||||
|
|
@ -165,21 +163,8 @@ static void sef_local_startup(void);
|
|||
|
||||
/* Entry points to this driver from libchardriver. */
|
||||
static struct chardriver bmp085_tab = {
|
||||
.cdr_open = do_nop,
|
||||
.cdr_close = do_nop,
|
||||
.cdr_ioctl = nop_ioctl,
|
||||
.cdr_prepare = bmp085_prepare,
|
||||
.cdr_transfer = bmp085_transfer,
|
||||
.cdr_cleanup = nop_cleanup,
|
||||
.cdr_alarm = nop_alarm,
|
||||
.cdr_cancel = nop_cancel,
|
||||
.cdr_select = nop_select,
|
||||
.cdr_other = bmp085_other
|
||||
};
|
||||
|
||||
static struct device bmp085_device = {
|
||||
.dv_base = 0,
|
||||
.dv_size = 0
|
||||
.cdr_read = bmp085_read,
|
||||
.cdr_other = bmp085_other
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -438,18 +423,12 @@ measure(int32_t * temperature, int32_t * pressure)
|
|||
return OK;
|
||||
}
|
||||
|
||||
static struct device *
|
||||
bmp085_prepare(dev_t UNUSED(dev))
|
||||
static ssize_t
|
||||
bmp085_read(devminor_t UNUSED(minor), u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int UNUSED(flags), cdev_id_t UNUSED(id))
|
||||
{
|
||||
return &bmp085_device;
|
||||
}
|
||||
|
||||
static int
|
||||
bmp085_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags))
|
||||
{
|
||||
int bytes, r;
|
||||
u64_t dev_size;
|
||||
int r;
|
||||
uint32_t temperature, pressure;
|
||||
|
||||
r = measure(&temperature, &pressure);
|
||||
|
|
@ -464,48 +443,33 @@ bmp085_transfer(endpoint_t endpt, int opcode, u64_t position,
|
|||
|
||||
log_trace(&log, "%s", buffer);
|
||||
|
||||
bytes = strlen(buffer) - position < iov->iov_size ?
|
||||
strlen(buffer) - position : iov->iov_size;
|
||||
dev_size = (u64_t)strlen(buffer);
|
||||
if (position >= dev_size) return 0;
|
||||
if (position + size > dev_size)
|
||||
size = (size_t)(dev_size - position);
|
||||
|
||||
if (bytes <= 0) {
|
||||
return OK;
|
||||
}
|
||||
r = sys_safecopyto(endpt, grant, 0,
|
||||
(vir_bytes)(buffer + (size_t)position), size);
|
||||
|
||||
switch (opcode) {
|
||||
case DEV_GATHER_S:
|
||||
r = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (buffer + position), bytes);
|
||||
iov->iov_size -= bytes;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return r;
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
static int
|
||||
bmp085_other(message * m)
|
||||
static void
|
||||
bmp085_other(message * m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
switch (m->m_type) {
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
log_debug(&log,
|
||||
"bus driver changed state, update endpoint\n");
|
||||
i2cdriver_handle_bus_update(&bus_endpoint, bus,
|
||||
address);
|
||||
}
|
||||
r = OK;
|
||||
break;
|
||||
default:
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
r = EINVAL;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
return r;
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -624,7 +588,7 @@ main(int argc, char *argv[])
|
|||
|
||||
sef_local_startup();
|
||||
|
||||
chardriver_task(&bmp085_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&bmp085_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ static int sef_cb_lu_state_save(int);
|
|||
static int lu_state_restore(void);
|
||||
|
||||
/* libblockdriver callbacks */
|
||||
static int cat24c256_blk_open(dev_t minor, int access);
|
||||
static int cat24c256_blk_close(dev_t minor);
|
||||
static ssize_t cat24c256_blk_transfer(dev_t minor, int do_write, u64_t pos,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned count, int flags);
|
||||
static int cat24c256_blk_ioctl(dev_t minor, unsigned int request,
|
||||
endpoint_t endpt, cp_grant_id_t grant);
|
||||
static struct device *cat24c256_blk_part(dev_t minor);
|
||||
static int cat24c256_blk_other(message * m);
|
||||
static int cat24c256_blk_open(devminor_t minor, int access);
|
||||
static int cat24c256_blk_close(devminor_t minor);
|
||||
static ssize_t cat24c256_blk_transfer(devminor_t minor, int do_write,
|
||||
u64_t pos, endpoint_t endpt, iovec_t * iov, unsigned int count, int flags);
|
||||
static int cat24c256_blk_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
static struct device *cat24c256_blk_part(devminor_t minor);
|
||||
static void cat24c256_blk_other(message * m, int ipc_status);
|
||||
|
||||
/* Entry points into the device dependent code of block drivers. */
|
||||
struct blockdriver cat24c256_tab = {
|
||||
|
|
@ -44,14 +44,9 @@ struct blockdriver cat24c256_tab = {
|
|||
.bdr_open = cat24c256_blk_open,
|
||||
.bdr_close = cat24c256_blk_close,
|
||||
.bdr_transfer = cat24c256_blk_transfer,
|
||||
.bdr_ioctl = cat24c256_blk_ioctl, /* nop -- always returns EINVAL */
|
||||
.bdr_cleanup = NULL, /* nothing allocated -- nothing to clean up */
|
||||
.bdr_ioctl = cat24c256_blk_ioctl, /* always returns ENOTTY */
|
||||
.bdr_part = cat24c256_blk_part,
|
||||
.bdr_geometry = NULL, /* no geometry (cylinders, heads, sectors, etc) */
|
||||
.bdr_intr = NULL, /* i2c devices don't generate interrupts */
|
||||
.bdr_alarm = NULL, /* alarm not needed */
|
||||
.bdr_other = cat24c256_blk_other, /* to recv notify events from DS */
|
||||
.bdr_device = NULL /* 1 insance per bus, threads not needed */
|
||||
.bdr_other = cat24c256_blk_other /* for notify events from DS */
|
||||
};
|
||||
|
||||
static int cat24c256_read128(uint16_t memaddr, void *buf, size_t buflen, int flags);
|
||||
|
|
@ -84,7 +79,7 @@ static struct log log = {
|
|||
};
|
||||
|
||||
static int
|
||||
cat24c256_blk_open(dev_t minor, int access)
|
||||
cat24c256_blk_open(devminor_t minor, int access)
|
||||
{
|
||||
log_trace(&log, "cat24c256_blk_open(%d,%d)\n", minor, access);
|
||||
if (cat24c256_blk_part(minor) == NULL) {
|
||||
|
|
@ -97,7 +92,7 @@ cat24c256_blk_open(dev_t minor, int access)
|
|||
}
|
||||
|
||||
static int
|
||||
cat24c256_blk_close(dev_t minor)
|
||||
cat24c256_blk_close(devminor_t minor)
|
||||
{
|
||||
log_trace(&log, "cat24c256_blk_close(%d)\n", minor);
|
||||
if (cat24c256_blk_part(minor) == NULL) {
|
||||
|
|
@ -114,11 +109,11 @@ cat24c256_blk_close(dev_t minor)
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
cat24c256_blk_transfer(dev_t minor, int do_write, u64_t pos64,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned nr_req, int flags)
|
||||
cat24c256_blk_transfer(devminor_t minor, int do_write, u64_t pos64,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned int nr_req, int flags)
|
||||
{
|
||||
/* Read or write one the driver's block devices. */
|
||||
unsigned count;
|
||||
unsigned int count;
|
||||
struct device *dv;
|
||||
u64_t dv_size;
|
||||
int r;
|
||||
|
|
@ -214,50 +209,40 @@ cat24c256_blk_transfer(dev_t minor, int do_write, u64_t pos64,
|
|||
}
|
||||
|
||||
static int
|
||||
cat24c256_blk_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant)
|
||||
cat24c256_blk_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
log_trace(&log, "cat24c256_blk_ioctl(%d)\n", minor);
|
||||
/* no supported ioctls for this device */
|
||||
return EINVAL;
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
static struct device *
|
||||
cat24c256_blk_part(dev_t minor)
|
||||
cat24c256_blk_part(devminor_t minor)
|
||||
{
|
||||
log_trace(&log, "cat24c256_blk_part(%d)\n", minor);
|
||||
|
||||
if (minor >= NR_DEVS) {
|
||||
if (minor < 0 || minor >= NR_DEVS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &geom[minor];
|
||||
}
|
||||
|
||||
static int
|
||||
cat24c256_blk_other(message * m)
|
||||
static void
|
||||
cat24c256_blk_other(message * m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
log_trace(&log, "cat24c256_blk_other(0x%x)\n", m->m_type);
|
||||
|
||||
switch (m->m_type) {
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
log_debug(&log,
|
||||
"bus driver changed state, update endpoint\n");
|
||||
i2cdriver_handle_bus_update(&bus_endpoint, bus,
|
||||
address);
|
||||
}
|
||||
r = OK;
|
||||
break;
|
||||
default:
|
||||
} else
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
r = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* The lower level i2c interface can only read/write 128 bytes at a time.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ service dec21140A
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 1011/0009;
|
||||
pci device 1011:0009;
|
||||
ipc
|
||||
SYSTEM pm rs log tty ds vm
|
||||
pci inet lwip
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <machine/pci.h>
|
||||
#include <minix/ds.h>
|
||||
#include <minix/vm.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <sys/mman.h>
|
||||
#include "assert.h"
|
||||
#include "e1000.h"
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ service e1000
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 8086/100e;
|
||||
pci device 8086/100f;
|
||||
pci device 8086/107c;
|
||||
pci device 8086/10cd;
|
||||
pci device 8086/10d3;
|
||||
pci device 8086/10de;
|
||||
pci device 8086/105e;
|
||||
pci device 8086:100e;
|
||||
pci device 8086:100f;
|
||||
pci device 8086:107c;
|
||||
pci device 8086:10cd;
|
||||
pci device 8086:10d3;
|
||||
pci device 8086:10de;
|
||||
pci device 8086:105e;
|
||||
ipc
|
||||
SYSTEM pm rs log tty ds vm
|
||||
pci inet lwip ;
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ arch_pan_display(int minor, struct fb_var_screeninfo *fbvsp)
|
|||
}
|
||||
|
||||
int
|
||||
arch_fb_init(int minor, struct device *dev, struct edid_info *info)
|
||||
arch_fb_init(int minor, struct edid_info *info)
|
||||
{
|
||||
int r;
|
||||
u32_t rdispc;
|
||||
|
|
@ -320,13 +320,9 @@ arch_fb_init(int minor, struct device *dev, struct edid_info *info)
|
|||
|
||||
const struct panel_config *panel_cfg = &omap_cfg[minor];
|
||||
|
||||
assert(dev != NULL);
|
||||
if (minor != 0) return ENXIO; /* We support only one minor */
|
||||
|
||||
|
||||
if (initialized) {
|
||||
dev->dv_base = fb_vir;
|
||||
dev->dv_size = fb_size;
|
||||
return OK;
|
||||
} else if (info != NULL) {
|
||||
log_debug(&log, "Configuring Settings based on EDID...\n");
|
||||
|
|
@ -403,8 +399,6 @@ arch_fb_init(int minor, struct device *dev, struct edid_info *info)
|
|||
if (fb_vir == (vir_bytes) MAP_FAILED) {
|
||||
panic("Unable to allocate contiguous memory\n");
|
||||
}
|
||||
dev->dv_base = fb_vir;
|
||||
dev->dv_size = fb_size;
|
||||
|
||||
/* Configure buffer settings and turn on LCD/Digital */
|
||||
arch_configure_display(minor);
|
||||
|
|
|
|||
183
drivers/fb/fb.c
183
drivers/fb/fb.c
|
|
@ -23,17 +23,14 @@
|
|||
/*
|
||||
* Function prototypes for the fb driver.
|
||||
*/
|
||||
static int fb_open(message *m);
|
||||
static int fb_close(message *m);
|
||||
static struct device * fb_prepare(dev_t device);
|
||||
static int fb_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
|
||||
flags);
|
||||
static int fb_do_read(endpoint_t ep, iovec_t *iov, int minor, u64_t pos,
|
||||
size_t *io_bytes);
|
||||
static int fb_do_write(endpoint_t ep, iovec_t *iov, int minor, u64_t pos,
|
||||
size_t *io_bytes);
|
||||
static int fb_ioctl(message *m);
|
||||
static int fb_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int fb_close(devminor_t minor);
|
||||
static ssize_t fb_read(devminor_t minor, u64_t pos, endpoint_t ep,
|
||||
cp_grant_id_t gid, size_t size, int flags, cdev_id_t id);
|
||||
static ssize_t fb_write(devminor_t minor, u64_t pos, endpoint_t ep,
|
||||
cp_grant_id_t gid, size_t size, int flags, cdev_id_t id);
|
||||
static int fb_ioctl(devminor_t minor, unsigned long request, endpoint_t ep,
|
||||
cp_grant_id_t gid, int flags, endpoint_t user_ep, cdev_id_t id);
|
||||
static void paint_bootlogo(int minor);
|
||||
static void paint_restartlogo(int minor);
|
||||
static void paint_centered(int minor, char *data, int width, int height);
|
||||
|
|
@ -52,143 +49,90 @@ static int lu_state_restore(void);
|
|||
/* Entry points to the fb driver. */
|
||||
static struct chardriver fb_tab =
|
||||
{
|
||||
fb_open,
|
||||
fb_close,
|
||||
fb_ioctl,
|
||||
fb_prepare,
|
||||
fb_transfer,
|
||||
nop_cleanup,
|
||||
nop_alarm,
|
||||
nop_cancel,
|
||||
nop_select,
|
||||
NULL
|
||||
.cdr_open = fb_open,
|
||||
.cdr_close = fb_close,
|
||||
.cdr_read = fb_read,
|
||||
.cdr_write = fb_write,
|
||||
.cdr_ioctl = fb_ioctl
|
||||
};
|
||||
|
||||
/** Represents the /dev/fb device. */
|
||||
static struct device fb_device[FB_DEV_NR];
|
||||
static int fb_minor, has_restarted = 0;
|
||||
static int has_restarted = 0;
|
||||
static u64_t has_restarted_t1, has_restarted_t2;
|
||||
|
||||
static int open_counter[FB_DEV_NR]; /* Open count */
|
||||
|
||||
static int
|
||||
fb_open(message *m)
|
||||
fb_open(devminor_t minor, int UNUSED(access), endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
int r;
|
||||
static int initialized = 0;
|
||||
static struct edid_info info;
|
||||
static struct edid_info *infop = NULL;
|
||||
|
||||
if (m->DEVICE < 0 || m->DEVICE >= FB_DEV_NR) return ENXIO;
|
||||
if (minor < 0 || minor >= FB_DEV_NR) return ENXIO;
|
||||
|
||||
if (!initialized) {
|
||||
r = fb_edid_read(m->DEVICE, &info);
|
||||
r = fb_edid_read(minor, &info);
|
||||
infop = (r == 0) ? &info : NULL;
|
||||
}
|
||||
|
||||
if (arch_fb_init(m->DEVICE, &fb_device[m->DEVICE], infop) == OK) {
|
||||
open_counter[m->DEVICE]++;
|
||||
if (arch_fb_init(minor, infop) == OK) {
|
||||
open_counter[minor]++;
|
||||
if (!initialized) {
|
||||
if (has_restarted) {
|
||||
read_frclock_64(&has_restarted_t1);
|
||||
paint_restartlogo(m->DEVICE);
|
||||
paint_restartlogo(minor);
|
||||
} else {
|
||||
paint_bootlogo(m->DEVICE);
|
||||
paint_bootlogo(minor);
|
||||
}
|
||||
initialized = 1;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
return ENXIO ;
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
static int
|
||||
fb_close(message *m)
|
||||
fb_close(devminor_t minor)
|
||||
{
|
||||
if (m->DEVICE < 0 || m->DEVICE >= FB_DEV_NR) return ENXIO;
|
||||
assert(open_counter[m->DEVICE] > 0);
|
||||
open_counter[m->DEVICE]--;
|
||||
if (minor < 0 || minor >= FB_DEV_NR) return ENXIO;
|
||||
assert(open_counter[minor] > 0);
|
||||
open_counter[minor]--;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static struct device *
|
||||
fb_prepare(dev_t dev)
|
||||
{
|
||||
if (dev < 0 || dev >= FB_DEV_NR) return NULL;
|
||||
assert(open_counter[dev] > 0);
|
||||
fb_minor = dev;
|
||||
return &fb_device[dev];
|
||||
}
|
||||
|
||||
static int
|
||||
fb_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags))
|
||||
{
|
||||
size_t io_bytes = 0, ret;
|
||||
|
||||
if (nr_req != 1) {
|
||||
/* This should never trigger for char drivers at the moment. */
|
||||
printf("fb: vectored transfer, using first element only\n");
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case DEV_GATHER_S:
|
||||
/* Userland read operation */
|
||||
ret = fb_do_read(endpt, iov, fb_minor, position, &io_bytes);
|
||||
iov->iov_size -= io_bytes;
|
||||
break;
|
||||
case DEV_SCATTER_S:
|
||||
/* Userland write operation */
|
||||
ret = fb_do_write(endpt, iov, fb_minor, position, &io_bytes);
|
||||
iov->iov_size -= io_bytes;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
fb_do_read(endpoint_t ep, iovec_t *iov, int minor, u64_t pos, size_t *io_bytes)
|
||||
static ssize_t
|
||||
fb_read(devminor_t minor, u64_t pos, endpoint_t ep, cp_grant_id_t gid,
|
||||
size_t size, int UNUSED(flags), cdev_id_t UNUSED(id))
|
||||
{
|
||||
struct device dev;
|
||||
int r;
|
||||
|
||||
if (minor < 0 || minor >= FB_DEV_NR) return ENXIO;
|
||||
assert(open_counter[minor] > 0);
|
||||
|
||||
arch_get_device(minor, &dev);
|
||||
|
||||
if (pos >= dev.dv_size) return EINVAL;
|
||||
if (size == 0 || pos >= dev.dv_size) return 0;
|
||||
if (pos + size > dev.dv_size)
|
||||
size = (size_t)(dev.dv_size - pos);
|
||||
|
||||
if (dev.dv_size - pos < iov->iov_size) {
|
||||
*io_bytes = dev.dv_size - pos;
|
||||
} else {
|
||||
*io_bytes = iov->iov_size;
|
||||
}
|
||||
r = sys_safecopyto(ep, gid, 0, (vir_bytes)(dev.dv_base + (size_t)pos),
|
||||
size);
|
||||
|
||||
if (*io_bytes <= 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
return sys_safecopyto(ep, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (dev.dv_base + ex64lo(pos)),
|
||||
*io_bytes);
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
static int
|
||||
fb_ioctl(message *m)
|
||||
fb_ioctl(devminor_t minor, unsigned long request, endpoint_t ep,
|
||||
cp_grant_id_t gid, int UNUSED(flags), endpoint_t UNUSED(user_ep),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Process I/O control requests */
|
||||
endpoint_t ep;
|
||||
cp_grant_id_t gid;
|
||||
int minor;
|
||||
unsigned int request;
|
||||
int r;
|
||||
|
||||
minor = m->DEVICE;
|
||||
request = m->COUNT;
|
||||
ep = (endpoint_t) m->USER_ENDPT;
|
||||
gid = (cp_grant_id_t) m->IO_GRANT;
|
||||
|
||||
if (minor != 0) return EINVAL;
|
||||
if (minor < 0 || minor >= FB_DEV_NR) return ENXIO;
|
||||
|
||||
switch(request) {
|
||||
case FBIOGET_VSCREENINFO:
|
||||
|
|
@ -205,7 +149,7 @@ fb_ioctl(message *m)
|
|||
return r;
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -270,34 +214,29 @@ do_get_fixscreeninfo(int minor, endpoint_t ep, cp_grant_id_t gid)
|
|||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
fb_do_write(endpoint_t ep, iovec_t *iov, int minor, u64_t pos, size_t *io_bytes)
|
||||
static ssize_t
|
||||
fb_write(devminor_t minor, u64_t pos, endpoint_t ep, cp_grant_id_t gid,
|
||||
size_t size, int UNUSED(flags), cdev_id_t UNUSED(id))
|
||||
{
|
||||
struct device dev;
|
||||
int r;
|
||||
|
||||
if (minor < 0 || minor >= FB_DEV_NR) return ENXIO;
|
||||
assert(open_counter[minor] > 0);
|
||||
|
||||
if (has_restarted && keep_displaying_restarted())
|
||||
return EAGAIN;
|
||||
|
||||
arch_get_device(minor, &dev);
|
||||
|
||||
if (pos >= dev.dv_size) {
|
||||
return EINVAL;
|
||||
}
|
||||
if (size == 0 || pos >= dev.dv_size) return 0;
|
||||
if (pos + size > dev.dv_size)
|
||||
size = (size_t)(dev.dv_size - pos);
|
||||
|
||||
if (dev.dv_size - pos < iov->iov_size) {
|
||||
*io_bytes = dev.dv_size - pos;
|
||||
} else {
|
||||
*io_bytes = iov->iov_size;
|
||||
}
|
||||
r = sys_safecopyfrom(ep, gid, 0,
|
||||
(vir_bytes)(dev.dv_base + (size_t)pos), size);
|
||||
|
||||
if (*io_bytes <= 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (has_restarted && keep_displaying_restarted()) {
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
return sys_safecopyfrom(ep, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (dev.dv_base + ex64lo(pos)),
|
||||
*io_bytes);
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -382,7 +321,7 @@ main(int argc, char *argv[])
|
|||
fb_edid_args_parse();
|
||||
|
||||
sef_local_startup();
|
||||
chardriver_task(&fb_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&fb_tab);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <minix/fb.h>
|
||||
|
||||
int arch_fb_init(int minor, struct device *dev, struct edid_info *info);
|
||||
int arch_fb_init(int minor, struct edid_info *info);
|
||||
int arch_get_device(int minor, struct device *dev);
|
||||
int arch_get_varscreeninfo(int minor, struct fb_var_screeninfo *fbvsp);
|
||||
int arch_put_varscreeninfo(int minor, struct fb_var_screeninfo *fbvs_copy);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize)
|
|||
/* Open Device - required for drivers using libblockdriver */
|
||||
memset(&m, '\0', sizeof(message));
|
||||
m.m_type = BDEV_OPEN;
|
||||
m.BDEV_ACCESS = R_BIT;
|
||||
m.BDEV_ACCESS = BDEV_R_BIT;
|
||||
m.BDEV_ID = 0;
|
||||
m.BDEV_MINOR = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,34 +15,27 @@
|
|||
#define BUF_SIZE (NR_IOREQS * CLICK_SIZE) /* 256k */
|
||||
|
||||
/* Function declarations. */
|
||||
static int fbd_open(dev_t minor, int access);
|
||||
static int fbd_close(dev_t minor);
|
||||
static int fbd_transfer(dev_t minor, int do_write, u64_t position,
|
||||
static int fbd_open(devminor_t minor, int access);
|
||||
static int fbd_close(devminor_t minor);
|
||||
static int fbd_transfer(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, iovec_t *iov, unsigned int nr_req, int flags);
|
||||
static int fbd_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant);
|
||||
static int fbd_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
|
||||
/* Variables. */
|
||||
static char *fbd_buf; /* scratch buffer */
|
||||
|
||||
static char driver_label[32] = ""; /* driver DS label */
|
||||
static dev_t driver_minor = -1; /* driver's partition minor to use */
|
||||
static endpoint_t driver_endpt; /* driver endpoint */
|
||||
static devminor_t driver_minor = -1; /* driver's partition minor to use */
|
||||
static endpoint_t driver_endpt; /* driver endpoint */
|
||||
|
||||
/* Entry points to this driver. */
|
||||
static struct blockdriver fbd_dtab = {
|
||||
BLOCKDRIVER_TYPE_OTHER, /* do not handle partition requests */
|
||||
fbd_open, /* open or mount request, initialize device */
|
||||
fbd_close, /* release device */
|
||||
fbd_transfer, /* do the I/O */
|
||||
fbd_ioctl, /* perform I/O control request */
|
||||
NULL, /* nothing to clean up */
|
||||
NULL, /* we will not be asked about partitions */
|
||||
NULL, /* we will not be asked for geometry */
|
||||
NULL, /* ignore leftover hardware interrupts */
|
||||
NULL, /* ignore alarms */
|
||||
NULL, /* ignore other messages */
|
||||
NULL /* no multithreading support */
|
||||
.bdr_type = BLOCKDRIVER_TYPE_OTHER,/* do not handle part. reqs */
|
||||
.bdr_open = fbd_open, /* open request, initialize device */
|
||||
.bdr_close = fbd_close, /* release device */
|
||||
.bdr_transfer = fbd_transfer, /* do the I/O */
|
||||
.bdr_ioctl = fbd_ioctl /* perform I/O control request */
|
||||
};
|
||||
|
||||
/* Options supported by this driver. */
|
||||
|
|
@ -147,7 +140,7 @@ int main(int argc, char **argv)
|
|||
/*===========================================================================*
|
||||
* fbd_open *
|
||||
*===========================================================================*/
|
||||
static int fbd_open(dev_t UNUSED(minor), int access)
|
||||
static int fbd_open(devminor_t UNUSED(minor), int access)
|
||||
{
|
||||
/* Open a device. */
|
||||
message m;
|
||||
|
|
@ -172,7 +165,7 @@ static int fbd_open(dev_t UNUSED(minor), int access)
|
|||
/*===========================================================================*
|
||||
* fbd_close *
|
||||
*===========================================================================*/
|
||||
static int fbd_close(dev_t UNUSED(minor))
|
||||
static int fbd_close(devminor_t UNUSED(minor))
|
||||
{
|
||||
/* Close a device. */
|
||||
message m;
|
||||
|
|
@ -196,8 +189,8 @@ static int fbd_close(dev_t UNUSED(minor))
|
|||
/*===========================================================================*
|
||||
* fbd_ioctl *
|
||||
*===========================================================================*/
|
||||
static int fbd_ioctl(dev_t UNUSED(minor), unsigned int request,
|
||||
endpoint_t endpt, cp_grant_id_t grant)
|
||||
static int fbd_ioctl(devminor_t UNUSED(minor), unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* Handle an I/O control request. */
|
||||
cp_grant_id_t gid;
|
||||
|
|
@ -222,6 +215,7 @@ static int fbd_ioctl(dev_t UNUSED(minor), unsigned int request,
|
|||
m.BDEV_MINOR = driver_minor;
|
||||
m.BDEV_REQUEST = request;
|
||||
m.BDEV_GRANT = gid;
|
||||
m.BDEV_USER = NONE;
|
||||
m.BDEV_ID = 0;
|
||||
|
||||
if ((r = sendrec(driver_endpt, &m)) != OK)
|
||||
|
|
@ -406,11 +400,11 @@ static ssize_t fbd_transfer_copy(int do_write, u64_t position,
|
|||
/*===========================================================================*
|
||||
* fbd_transfer *
|
||||
*===========================================================================*/
|
||||
static int fbd_transfer(dev_t UNUSED(minor), int do_write, u64_t position,
|
||||
static int fbd_transfer(devminor_t UNUSED(minor), int do_write, u64_t position,
|
||||
endpoint_t endpt, iovec_t *iov, unsigned int nr_req, int flags)
|
||||
{
|
||||
/* Transfer data from or to the device. */
|
||||
unsigned count;
|
||||
unsigned int count;
|
||||
size_t size, osize;
|
||||
int i, hooks;
|
||||
ssize_t r;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ static int driver_open(int which)
|
|||
memset(&msg, 0, sizeof(msg));
|
||||
msg.m_type = BDEV_OPEN;
|
||||
msg.BDEV_MINOR = driver[which].minor;
|
||||
msg.BDEV_ACCESS = R_BIT | W_BIT;
|
||||
msg.BDEV_ACCESS = BDEV_R_BIT | BDEV_W_BIT;
|
||||
msg.BDEV_ID = 0;
|
||||
r = sendrec(driver[which].endpt, &msg);
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ static int driver_open(int which)
|
|||
msg.BDEV_MINOR = driver[which].minor;
|
||||
msg.BDEV_REQUEST = DIOCGETP;
|
||||
msg.BDEV_GRANT = gid;
|
||||
msg.BDEV_USER = NONE;
|
||||
msg.BDEV_ID = 0;
|
||||
|
||||
r = sendrec(driver[which].endpt, &msg);
|
||||
|
|
@ -582,7 +583,7 @@ static int flt_receive(message *mess, int which)
|
|||
}
|
||||
|
||||
if(mess->m_source == CLOCK && is_ipc_notify(ipc_status)) {
|
||||
if (mess->NOTIFY_TIMESTAMP < flt_alarm(-1)) {
|
||||
if (mess->NOTIFY_TIMESTAMP < flt_alarm((clock_t) -1)) {
|
||||
#if DEBUG
|
||||
printf("Filter: SKIPPING old alarm "
|
||||
"notification\n");
|
||||
|
|
|
|||
|
|
@ -63,12 +63,6 @@ static struct optset optset_table[] = {
|
|||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
/* Request message. */
|
||||
static message m_in;
|
||||
static endpoint_t who_e; /* m_source */
|
||||
static long req_id; /* BDEV_ID */
|
||||
static cp_grant_id_t grant_id; /* BDEV_GRANT */
|
||||
|
||||
/* Data buffers. */
|
||||
static char *buf_array, *buffer; /* contiguous buffer */
|
||||
|
||||
|
|
@ -77,26 +71,46 @@ static void sef_local_startup(void);
|
|||
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
|
||||
static void sef_cb_signal_handler(int signo);
|
||||
|
||||
/*===========================================================================*
|
||||
* carry *
|
||||
*===========================================================================*/
|
||||
static int carry(size_t size, int flag_rw)
|
||||
{
|
||||
/* Carry data between caller proc and filter.
|
||||
*/
|
||||
static int filter_open(devminor_t minor, int access);
|
||||
static int filter_close(devminor_t minor);
|
||||
static ssize_t filter_transfer(devminor_t minor, int do_write, u64_t pos,
|
||||
endpoint_t endpt, iovec_t *iov, unsigned int count, int flags);
|
||||
static int filter_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
static void filter_other(message *m, int ipc_status);
|
||||
|
||||
if (flag_rw == FLT_WRITE)
|
||||
return sys_safecopyfrom(who_e, grant_id, 0,
|
||||
(vir_bytes) buffer, size);
|
||||
else
|
||||
return sys_safecopyto(who_e, grant_id, 0,
|
||||
(vir_bytes) buffer, size);
|
||||
static struct blockdriver filter_tab = {
|
||||
.bdr_type = BLOCKDRIVER_TYPE_OTHER,
|
||||
.bdr_open = filter_open,
|
||||
.bdr_close = filter_close,
|
||||
.bdr_transfer = filter_transfer,
|
||||
.bdr_ioctl = filter_ioctl,
|
||||
.bdr_other = filter_other
|
||||
};
|
||||
|
||||
/*===========================================================================*
|
||||
* filter_open *
|
||||
*===========================================================================*/
|
||||
static int filter_open(devminor_t UNUSED(minor), int UNUSED(access))
|
||||
{
|
||||
/* Open is a noop for filter. */
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* filter_close *
|
||||
*===========================================================================*/
|
||||
static int filter_close(devminor_t UNUSED(minor))
|
||||
{
|
||||
/* Close is a noop for filter. */
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* vcarry *
|
||||
*===========================================================================*/
|
||||
static int vcarry(int grants, iovec_t *iov, int flag_rw, size_t size)
|
||||
static int vcarry(endpoint_t endpt, unsigned int grants, iovec_t *iov,
|
||||
int do_write, size_t size)
|
||||
{
|
||||
/* Carry data between caller proc and filter, through grant-vector.
|
||||
*/
|
||||
|
|
@ -108,12 +122,12 @@ static int vcarry(int grants, iovec_t *iov, int flag_rw, size_t size)
|
|||
for(i = 0; i < grants && size > 0; i++) {
|
||||
bytes = MIN(size, iov[i].iov_size);
|
||||
|
||||
if (flag_rw == FLT_WRITE)
|
||||
r = sys_safecopyfrom(who_e,
|
||||
if (do_write)
|
||||
r = sys_safecopyfrom(endpt,
|
||||
(vir_bytes) iov[i].iov_addr, 0,
|
||||
(vir_bytes) bufp, bytes);
|
||||
else
|
||||
r = sys_safecopyto(who_e,
|
||||
r = sys_safecopyto(endpt,
|
||||
(vir_bytes) iov[i].iov_addr, 0,
|
||||
(vir_bytes) bufp, bytes);
|
||||
|
||||
|
|
@ -127,76 +141,19 @@ static int vcarry(int grants, iovec_t *iov, int flag_rw, size_t size)
|
|||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_rdwt *
|
||||
*===========================================================================*/
|
||||
static int do_rdwt(int flag_rw)
|
||||
{
|
||||
size_t size, size_ret;
|
||||
u64_t pos;
|
||||
int r;
|
||||
|
||||
pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI);
|
||||
size = m_in.BDEV_COUNT;
|
||||
|
||||
if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) {
|
||||
printf("Filter: unaligned request from caller!\n");
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
buffer = flt_malloc(size, buf_array, BUF_SIZE);
|
||||
|
||||
if(flag_rw == FLT_WRITE)
|
||||
carry(size, flag_rw);
|
||||
|
||||
reset_kills();
|
||||
|
||||
for (;;) {
|
||||
size_ret = size;
|
||||
r = transfer(pos, buffer, &size_ret, flag_rw);
|
||||
if(r != RET_REDO)
|
||||
break;
|
||||
|
||||
#if DEBUG
|
||||
printf("Filter: transfer yielded RET_REDO, checking drivers\n");
|
||||
#endif
|
||||
if((r = check_driver(DRIVER_MAIN)) != OK) break;
|
||||
if((r = check_driver(DRIVER_BACKUP)) != OK) break;
|
||||
}
|
||||
|
||||
if(r == OK && flag_rw == FLT_READ)
|
||||
carry(size_ret, flag_rw);
|
||||
|
||||
flt_free(buffer, size, buf_array);
|
||||
|
||||
if (r != OK)
|
||||
return r;
|
||||
|
||||
return size_ret;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_vrdwt *
|
||||
* filter_transfer *
|
||||
*===========================================================================*/
|
||||
static int do_vrdwt(int flag_rw)
|
||||
static ssize_t filter_transfer(devminor_t UNUSED(minor), int do_write,
|
||||
u64_t pos, endpoint_t endpt, iovec_t *iov, unsigned int count,
|
||||
int UNUSED(flags))
|
||||
{
|
||||
size_t size, size_ret;
|
||||
int grants;
|
||||
int r, i;
|
||||
u64_t pos;
|
||||
iovec_t iov_proc[NR_IOREQS];
|
||||
|
||||
/* Extract informations. */
|
||||
grants = m_in.BDEV_COUNT;
|
||||
if((r = sys_safecopyfrom(who_e, grant_id, 0, (vir_bytes) iov_proc,
|
||||
grants * sizeof(iovec_t))) != OK) {
|
||||
panic("copying in grant vector failed: %d", r);
|
||||
}
|
||||
|
||||
pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI);
|
||||
for(size = 0, i = 0; i < grants; i++)
|
||||
size += iov_proc[i].iov_size;
|
||||
for(size = 0, i = 0; i < count; i++)
|
||||
size += iov[i].iov_size;
|
||||
|
||||
if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) {
|
||||
printf("Filter: unaligned request from caller!\n");
|
||||
|
|
@ -205,14 +162,15 @@ static int do_vrdwt(int flag_rw)
|
|||
|
||||
buffer = flt_malloc(size, buf_array, BUF_SIZE);
|
||||
|
||||
if(flag_rw == FLT_WRITE)
|
||||
vcarry(grants, iov_proc, flag_rw, size);
|
||||
if (do_write)
|
||||
vcarry(endpt, count, iov, do_write, size);
|
||||
|
||||
reset_kills();
|
||||
|
||||
for (;;) {
|
||||
size_ret = size;
|
||||
r = transfer(pos, buffer, &size_ret, flag_rw);
|
||||
r = transfer(pos, buffer, &size_ret,
|
||||
do_write ? FLT_WRITE : FLT_READ);
|
||||
if(r != RET_REDO)
|
||||
break;
|
||||
|
||||
|
|
@ -228,8 +186,8 @@ static int do_vrdwt(int flag_rw)
|
|||
return r;
|
||||
}
|
||||
|
||||
if(flag_rw == FLT_READ)
|
||||
vcarry(grants, iov_proc, flag_rw, size_ret);
|
||||
if (!do_write)
|
||||
vcarry(endpt, count, iov, do_write, size_ret);
|
||||
|
||||
flt_free(buffer, size, buf_array);
|
||||
|
||||
|
|
@ -237,13 +195,14 @@ static int do_vrdwt(int flag_rw)
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_ioctl *
|
||||
* filter_ioctl *
|
||||
*===========================================================================*/
|
||||
static int do_ioctl(message *m)
|
||||
static int filter_ioctl(devminor_t UNUSED(minor), unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
struct part_geom sizepart;
|
||||
|
||||
switch(m->BDEV_REQUEST) {
|
||||
switch (request) {
|
||||
case DIOCSETP:
|
||||
case DIOCTIMEOUT:
|
||||
case DIOCOPENCT:
|
||||
|
|
@ -258,8 +217,7 @@ static int do_ioctl(message *m)
|
|||
*/
|
||||
sizepart.size = convert(get_raw_size());
|
||||
|
||||
if(sys_safecopyto(who_e, (vir_bytes) grant_id, 0,
|
||||
(vir_bytes) &sizepart,
|
||||
if (sys_safecopyto(endpt, grant, 0, (vir_bytes) &sizepart,
|
||||
sizeof(struct part_geom)) != OK) {
|
||||
printf("Filter: DIOCGETP safecopyto failed\n");
|
||||
return EIO;
|
||||
|
|
@ -267,14 +225,24 @@ static int do_ioctl(message *m)
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("Filter: unknown ioctl request: %d!\n",
|
||||
m->BDEV_REQUEST);
|
||||
return EINVAL;
|
||||
printf("Filter: unknown ioctl request: %ld!\n", request);
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* filter_other *
|
||||
*===========================================================================*/
|
||||
static void filter_other(message *m, int ipc_status)
|
||||
{
|
||||
/* Process other messages. */
|
||||
if (m->m_source == DS_PROC_NR && is_ipc_notify(ipc_status)) {
|
||||
ds_event();
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* parse_arguments *
|
||||
*===========================================================================*/
|
||||
|
|
@ -371,53 +339,7 @@ int main(int argc, char *argv[])
|
|||
env_setargs(argc, argv);
|
||||
sef_local_startup();
|
||||
|
||||
for (;;) {
|
||||
/* Wait for request. */
|
||||
if(driver_receive(ANY, &m_in, &ipc_status) != OK) {
|
||||
panic("driver_receive failed");
|
||||
}
|
||||
|
||||
#if DEBUG2
|
||||
printf("Filter: got request %d from %d\n",
|
||||
m_in.m_type, m_in.m_source);
|
||||
#endif
|
||||
|
||||
if(m_in.m_source == DS_PROC_NR && is_ipc_notify(ipc_status)) {
|
||||
ds_event();
|
||||
continue;
|
||||
}
|
||||
|
||||
who_e = m_in.m_source;
|
||||
req_id = m_in.BDEV_ID;
|
||||
grant_id = m_in.BDEV_GRANT;
|
||||
size = 0;
|
||||
|
||||
/* Forword the request message to the drivers. */
|
||||
switch(m_in.m_type) {
|
||||
case BDEV_OPEN: /* open/close is a noop for filter. */
|
||||
case BDEV_CLOSE: r = OK; break;
|
||||
case BDEV_READ: r = do_rdwt(FLT_READ); break;
|
||||
case BDEV_WRITE: r = do_rdwt(FLT_WRITE); break;
|
||||
case BDEV_GATHER: r = do_vrdwt(FLT_READ); break;
|
||||
case BDEV_SCATTER: r = do_vrdwt(FLT_WRITE); break;
|
||||
case BDEV_IOCTL: r = do_ioctl(&m_in); break;
|
||||
|
||||
default:
|
||||
printf("Filter: ignoring unknown request %d from %d\n",
|
||||
m_in.m_type, m_in.m_source);
|
||||
continue;
|
||||
}
|
||||
|
||||
#if DEBUG2
|
||||
printf("Filter: replying with code %d\n", r);
|
||||
#endif
|
||||
|
||||
/* Send back reply message. */
|
||||
m_out.m_type = BDEV_REPLY;
|
||||
m_out.BDEV_ID = req_id;
|
||||
m_out.BDEV_STATUS = r;
|
||||
send(who_e, &m_out);
|
||||
}
|
||||
blockdriver_task(&filter_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -490,4 +412,3 @@ static void sef_cb_signal_handler(int signo)
|
|||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ clock_t flt_alarm(clock_t dt)
|
|||
{
|
||||
int r;
|
||||
|
||||
if(dt < 0)
|
||||
if((int) dt < 0)
|
||||
return next_alarm;
|
||||
|
||||
r = sys_setalarm(dt, 0);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "floppy.h"
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <machine/diskparm.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/syslib.h>
|
||||
|
|
@ -212,7 +212,7 @@ static struct floppy { /* main drive struct, one entry per drive */
|
|||
char fl_calibration; /* CALIBRATED or UNCALIBRATED */
|
||||
u8_t fl_density; /* NO_DENS = ?, 0 = 360K; 1 = 360K/1.2M; etc.*/
|
||||
u8_t fl_class; /* bitmap for possible densities */
|
||||
timer_t fl_tmr_stop; /* timer to stop motor */
|
||||
minix_timer_t fl_tmr_stop; /* timer to stop motor */
|
||||
struct device fl_geom; /* Geometry of the drive */
|
||||
struct device fl_part[NR_PARTITIONS]; /* partition's base & size */
|
||||
} floppy[NR_DRIVES];
|
||||
|
|
@ -236,16 +236,16 @@ static u8_t f_results[MAX_RESULTS];/* the controller can give lots of output */
|
|||
* Besides the 'f_tmr_timeout' timer below, the floppy structure for each
|
||||
* floppy disk drive contains a 'fl_tmr_stop' timer.
|
||||
*/
|
||||
static timer_t f_tmr_timeout; /* timer for various timeouts */
|
||||
static minix_timer_t f_tmr_timeout; /* timer for various timeouts */
|
||||
static u32_t system_hz; /* system clock frequency */
|
||||
static void f_expire_tmrs(clock_t stamp);
|
||||
static void stop_motor(timer_t *tp);
|
||||
static void f_timeout(timer_t *tp);
|
||||
static void stop_motor(minix_timer_t *tp);
|
||||
static void f_timeout(minix_timer_t *tp);
|
||||
|
||||
static struct device *f_prepare(dev_t device);
|
||||
static struct device *f_part(dev_t minor);
|
||||
static struct device *f_prepare(devminor_t device);
|
||||
static struct device *f_part(devminor_t minor);
|
||||
static void f_cleanup(void);
|
||||
static ssize_t f_transfer(dev_t minor, int do_write, u64_t position,
|
||||
static ssize_t f_transfer(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t proc_nr, iovec_t *iov, unsigned int nr_req, int flags);
|
||||
static int dma_setup(int do_write);
|
||||
static void start_motor(void);
|
||||
|
|
@ -258,25 +258,21 @@ static int recalibrate(void);
|
|||
static void f_reset(void);
|
||||
static int f_intr_wait(void);
|
||||
static int read_id(void);
|
||||
static int f_do_open(dev_t minor, int access);
|
||||
static int f_do_close(dev_t minor);
|
||||
static int f_do_open(devminor_t minor, int access);
|
||||
static int f_do_close(devminor_t minor);
|
||||
static int test_read(int density);
|
||||
static void f_geometry(dev_t minor, struct part_geom *entry);
|
||||
static void f_geometry(devminor_t minor, struct part_geom *entry);
|
||||
|
||||
/* Entry points to this driver. */
|
||||
static struct blockdriver f_dtab = {
|
||||
BLOCKDRIVER_TYPE_DISK, /* handle partition requests */
|
||||
f_do_open, /* open or mount request, sense type of diskette */
|
||||
f_do_close, /* nothing on a close */
|
||||
f_transfer, /* do the I/O */
|
||||
NULL, /* no other I/O control requests are supported */
|
||||
f_cleanup, /* cleanup before sending reply to user process */
|
||||
f_part, /* return partition information structure */
|
||||
f_geometry, /* tell the geometry of the diskette */
|
||||
NULL, /* no processing of hardware interrupts */
|
||||
f_expire_tmrs,/* expire all alarm timers */
|
||||
NULL, /* no processing of other messages */
|
||||
NULL /* no threading support */
|
||||
.bdr_type = BLOCKDRIVER_TYPE_DISK, /* handle partition requests */
|
||||
.bdr_open = f_do_open, /* open request, sense type of diskette */
|
||||
.bdr_close = f_do_close, /* nothing on a close */
|
||||
.bdr_transfer = f_transfer, /* do the I/O */
|
||||
.bdr_cleanup = f_cleanup, /* cleanup before sending reply to caller */
|
||||
.bdr_part = f_part, /* return partition information structure */
|
||||
.bdr_geometry = f_geometry, /* tell the geometry of the diskette */
|
||||
.bdr_alarm = f_expire_tmrs /* expire all alarm timers */
|
||||
};
|
||||
|
||||
static char *floppy_buf;
|
||||
|
|
@ -397,13 +393,13 @@ static void f_expire_tmrs(clock_t stamp)
|
|||
/*===========================================================================*
|
||||
* f_prepare *
|
||||
*===========================================================================*/
|
||||
static struct device *f_prepare(dev_t device)
|
||||
static struct device *f_prepare(devminor_t device)
|
||||
{
|
||||
/* Prepare for I/O on a device. */
|
||||
|
||||
f_device = device;
|
||||
f_drive = device & ~(DEV_TYPE_BITS | FORMAT_DEV_BIT);
|
||||
if (f_drive >= NR_DRIVES) return(NULL);
|
||||
if (device < 0 || f_drive >= NR_DRIVES) return(NULL);
|
||||
|
||||
f_fp = &floppy[f_drive];
|
||||
f_dv = &f_fp->fl_geom;
|
||||
|
|
@ -424,7 +420,7 @@ static struct device *f_prepare(dev_t device)
|
|||
/*===========================================================================*
|
||||
* f_part *
|
||||
*===========================================================================*/
|
||||
static struct device *f_part(dev_t minor)
|
||||
static struct device *f_part(devminor_t minor)
|
||||
{
|
||||
/* Return a pointer to the partition information of the given minor device. */
|
||||
|
||||
|
|
@ -447,7 +443,7 @@ static void f_cleanup(void)
|
|||
* f_transfer *
|
||||
*===========================================================================*/
|
||||
static ssize_t f_transfer(
|
||||
dev_t minor, /* minor device number */
|
||||
devminor_t minor, /* minor device number */
|
||||
int do_write, /* read or write? */
|
||||
u64_t pos64, /* offset on device to read or write */
|
||||
endpoint_t proc_nr, /* process doing the request */
|
||||
|
|
@ -789,7 +785,7 @@ static void start_motor(void)
|
|||
/*===========================================================================*
|
||||
* stop_motor *
|
||||
*===========================================================================*/
|
||||
static void stop_motor(timer_t *tp)
|
||||
static void stop_motor(minix_timer_t *tp)
|
||||
{
|
||||
/* This routine is called from an alarm timer after several seconds have
|
||||
* elapsed with no floppy disk activity. It turns the drive motor off.
|
||||
|
|
@ -1203,7 +1199,7 @@ static int f_intr_wait(void)
|
|||
/*===========================================================================*
|
||||
* f_timeout *
|
||||
*===========================================================================*/
|
||||
static void f_timeout(timer_t *UNUSED(tp))
|
||||
static void f_timeout(minix_timer_t *UNUSED(tp))
|
||||
{
|
||||
/* This routine is called when a timer expires. Usually to tell that a
|
||||
* motor has spun up, but also to forge an interrupt when it takes too long
|
||||
|
|
@ -1251,7 +1247,7 @@ static int read_id(void)
|
|||
/*===========================================================================*
|
||||
* f_do_open *
|
||||
*===========================================================================*/
|
||||
static int f_do_open(dev_t minor, int UNUSED(access))
|
||||
static int f_do_open(devminor_t minor, int UNUSED(access))
|
||||
{
|
||||
/* Handle an open on a floppy. Determine diskette type if need be. */
|
||||
|
||||
|
|
@ -1310,7 +1306,7 @@ static int f_do_open(dev_t minor, int UNUSED(access))
|
|||
/*===========================================================================*
|
||||
* f_do_close *
|
||||
*===========================================================================*/
|
||||
static int f_do_close(dev_t UNUSED(minor))
|
||||
static int f_do_close(devminor_t UNUSED(minor))
|
||||
{
|
||||
/* Handle a close on a floppy. Nothing to do here. */
|
||||
|
||||
|
|
@ -1350,7 +1346,7 @@ static int test_read(int density)
|
|||
/*===========================================================================*
|
||||
* f_geometry *
|
||||
*===========================================================================*/
|
||||
static void f_geometry(dev_t minor, struct part_geom *entry)
|
||||
static void f_geometry(devminor_t minor, struct part_geom *entry)
|
||||
{
|
||||
if (f_prepare(minor) == NULL) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <minix/ds.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
|
||||
#define debug 0
|
||||
#define RAND_UPDATE /**/
|
||||
|
|
@ -141,7 +141,7 @@ static int fxp_instance;
|
|||
|
||||
static fxp_t *fxp_state;
|
||||
|
||||
static timer_t fxp_watchdog;
|
||||
static minix_timer_t fxp_watchdog;
|
||||
|
||||
static u32_t system_hz;
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ static void fxp_restart_ru(fxp_t *fp);
|
|||
static void fxp_getstat_s(message *mp);
|
||||
static void fxp_handler(fxp_t *fp);
|
||||
static void fxp_check_ints(fxp_t *fp);
|
||||
static void fxp_watchdog_f(timer_t *tp);
|
||||
static void fxp_watchdog_f(minix_timer_t *tp);
|
||||
static int fxp_link_changed(fxp_t *fp);
|
||||
static void fxp_report_link(fxp_t *fp);
|
||||
static void reply(fxp_t *fp);
|
||||
|
|
@ -1627,7 +1627,7 @@ static void fxp_check_ints(fxp_t *fp)
|
|||
* fxp_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void fxp_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
fxp_t *fp;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ service fxp
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 8086/1031;
|
||||
pci device 8086/1032;
|
||||
pci device 8086/103d;
|
||||
pci device 8086/1064;
|
||||
pci device 8086/1229;
|
||||
pci device 8086/2449;
|
||||
pci device 8086/1209;
|
||||
pci device 8086:1031;
|
||||
pci device 8086:1032;
|
||||
pci device 8086:103d;
|
||||
pci device 8086:1064;
|
||||
pci device 8086:1229;
|
||||
pci device 8086:2449;
|
||||
pci device 8086:1209;
|
||||
ipc
|
||||
SYSTEM pm rs log tty ds vm
|
||||
pci inet lwip amddev
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@
|
|||
/*
|
||||
* Function prototypes for the hello driver.
|
||||
*/
|
||||
static int hello_open(message *m);
|
||||
static int hello_close(message *m);
|
||||
static struct device * hello_prepare(dev_t device);
|
||||
static int hello_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
|
||||
flags);
|
||||
static int hello_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int hello_close(devminor_t minor);
|
||||
static ssize_t hello_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
|
@ -24,77 +22,54 @@ static int lu_state_restore(void);
|
|||
/* Entry points to the hello driver. */
|
||||
static struct chardriver hello_tab =
|
||||
{
|
||||
hello_open,
|
||||
hello_close,
|
||||
nop_ioctl,
|
||||
hello_prepare,
|
||||
hello_transfer,
|
||||
nop_cleanup,
|
||||
nop_alarm,
|
||||
nop_cancel,
|
||||
nop_select,
|
||||
NULL
|
||||
.cdr_open = hello_open,
|
||||
.cdr_close = hello_close,
|
||||
.cdr_read = hello_read,
|
||||
};
|
||||
|
||||
/** Represents the /dev/hello device. */
|
||||
static struct device hello_device;
|
||||
|
||||
/** State variable to count the number of times the device has been opened. */
|
||||
/** State variable to count the number of times the device has been opened.
|
||||
* Note that this is not the regular type of open counter: it never decreases.
|
||||
*/
|
||||
static int open_counter;
|
||||
|
||||
static int hello_open(message *UNUSED(m))
|
||||
static int hello_open(devminor_t UNUSED(minor), int UNUSED(access),
|
||||
endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
printf("hello_open(). Called %d time(s).\n", ++open_counter);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int hello_close(message *UNUSED(m))
|
||||
static int hello_close(devminor_t UNUSED(minor))
|
||||
{
|
||||
printf("hello_close()\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
static struct device * hello_prepare(dev_t UNUSED(dev))
|
||||
static ssize_t hello_read(devminor_t UNUSED(minor), u64_t position,
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
hello_device.dv_base = make64(0, 0);
|
||||
hello_device.dv_size = make64(strlen(HELLO_MESSAGE), 0);
|
||||
return &hello_device;
|
||||
}
|
||||
u64_t dev_size;
|
||||
char *ptr;
|
||||
int ret;
|
||||
|
||||
static int hello_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags))
|
||||
{
|
||||
int bytes, ret;
|
||||
printf("hello_read()\n");
|
||||
|
||||
printf("hello_transfer()\n");
|
||||
/* This is the total size of our device. */
|
||||
dev_size = (u64_t) strlen(HELLO_MESSAGE);
|
||||
|
||||
if (nr_req != 1)
|
||||
{
|
||||
/* This should never trigger for character drivers at the moment. */
|
||||
printf("HELLO: vectored transfer request, using first element only\n");
|
||||
}
|
||||
/* Check for EOF, and possibly limit the read size. */
|
||||
if (position >= dev_size) return 0; /* EOF */
|
||||
if (position + size > dev_size)
|
||||
size = (size_t)(dev_size - position); /* limit size */
|
||||
|
||||
bytes = strlen(HELLO_MESSAGE) - ex64lo(position) < iov->iov_size ?
|
||||
strlen(HELLO_MESSAGE) - ex64lo(position) : iov->iov_size;
|
||||
/* Copy the requested part to the caller. */
|
||||
ptr = HELLO_MESSAGE + (size_t)position;
|
||||
if ((ret = sys_safecopyto(endpt, grant, 0, (vir_bytes) ptr, size)) != OK)
|
||||
return ret;
|
||||
|
||||
if (bytes <= 0)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
switch (opcode)
|
||||
{
|
||||
case DEV_GATHER_S:
|
||||
ret = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (HELLO_MESSAGE + ex64lo(position)),
|
||||
bytes);
|
||||
iov->iov_size -= bytes;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return ret;
|
||||
/* Return the number of bytes read. */
|
||||
return size;
|
||||
}
|
||||
|
||||
static int sef_cb_lu_state_save(int UNUSED(state)) {
|
||||
|
|
@ -181,7 +156,7 @@ int main(void)
|
|||
/*
|
||||
* Run the main loop.
|
||||
*/
|
||||
chardriver_task(&hello_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&hello_tab);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,16 +33,14 @@ static void update_reservation(endpoint_t endpt, char *key);
|
|||
static void ds_event(void);
|
||||
|
||||
static int validate_ioctl_exec(minix_i2c_ioctl_exec_t * ioctl_exec);
|
||||
static int do_i2c_ioctl_exec(message * m);
|
||||
static int do_i2c_ioctl_exec(endpoint_t caller, cp_grant_id_t grant_nr);
|
||||
|
||||
static int env_parse_instance(void);
|
||||
|
||||
/* libchardriver callbacks */
|
||||
int i2c_ioctl(message * m);
|
||||
struct device *i2c_prepare(dev_t dev);
|
||||
int i2c_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t user_endpt, unsigned int flags);
|
||||
int i2c_other(message * m);
|
||||
static int i2c_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, int flags, endpoint_t user_endpt, cdev_id_t id);
|
||||
static void i2c_other(message * m, int ipc_status);
|
||||
|
||||
/* SEF callbacks and driver state management */
|
||||
static int sef_cb_lu_state_save(int);
|
||||
|
|
@ -68,8 +66,6 @@ static struct i2cdev
|
|||
*/
|
||||
int (*process) (minix_i2c_ioctl_exec_t * ioctl_exec);
|
||||
|
||||
struct device i2c_device;
|
||||
|
||||
/* logging - use with log_warn(), log_info(), log_debug(), log_trace() */
|
||||
static struct log log = {
|
||||
.name = "i2c",
|
||||
|
|
@ -81,16 +77,8 @@ static struct log log = {
|
|||
* Only i2c_ioctl() and i2c_other() are implemented. The rest are no-op.
|
||||
*/
|
||||
static struct chardriver i2c_tab = {
|
||||
.cdr_open = do_nop,
|
||||
.cdr_close = do_nop,
|
||||
.cdr_ioctl = i2c_ioctl,
|
||||
.cdr_prepare = i2c_prepare,
|
||||
.cdr_transfer = i2c_transfer,
|
||||
.cdr_cleanup = nop_cleanup,
|
||||
.cdr_alarm = nop_alarm,
|
||||
.cdr_cancel = nop_cancel,
|
||||
.cdr_select = nop_select,
|
||||
.cdr_other = i2c_other
|
||||
.cdr_ioctl = i2c_ioctl,
|
||||
.cdr_other = i2c_other
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -232,14 +220,14 @@ validate_ioctl_exec(minix_i2c_ioctl_exec_t * ioctl_exec)
|
|||
}
|
||||
|
||||
len = ioctl_exec->iie_cmdlen;
|
||||
if (len < 0 || len > I2C_EXEC_MAX_CMDLEN) {
|
||||
if (len > I2C_EXEC_MAX_CMDLEN) {
|
||||
log_warn(&log,
|
||||
"iie_cmdlen out of range 0-I2C_EXEC_MAX_CMDLEN\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
len = ioctl_exec->iie_buflen;
|
||||
if (len < 0 || len > I2C_EXEC_MAX_BUFLEN) {
|
||||
if (len > I2C_EXEC_MAX_BUFLEN) {
|
||||
log_warn(&log,
|
||||
"iie_buflen out of range 0-I2C_EXEC_MAX_BUFLEN\n");
|
||||
return EINVAL;
|
||||
|
|
@ -252,16 +240,11 @@ validate_ioctl_exec(minix_i2c_ioctl_exec_t * ioctl_exec)
|
|||
* Performs the action in minix_i2c_ioctl_exec_t.
|
||||
*/
|
||||
static int
|
||||
do_i2c_ioctl_exec(message * m)
|
||||
do_i2c_ioctl_exec(endpoint_t caller, cp_grant_id_t grant_nr)
|
||||
{
|
||||
int r;
|
||||
endpoint_t caller;
|
||||
cp_grant_id_t grant_nr;
|
||||
minix_i2c_ioctl_exec_t ioctl_exec;
|
||||
|
||||
caller = (endpoint_t) m->m_source;
|
||||
grant_nr = (cp_grant_id_t) m->IO_GRANT;
|
||||
|
||||
/* Copy the requested exection into the driver */
|
||||
r = sys_safecopyfrom(caller, grant_nr, (vir_bytes) 0,
|
||||
(vir_bytes) & ioctl_exec, sizeof(ioctl_exec));
|
||||
|
|
@ -302,45 +285,48 @@ do_i2c_ioctl_exec(message * m)
|
|||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
i2c_ioctl(message * m)
|
||||
static int
|
||||
i2c_ioctl(devminor_t UNUSED(minor), unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, int UNUSED(flags), endpoint_t UNUSED(user_endpt),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
int r;
|
||||
|
||||
switch (m->COUNT) {
|
||||
switch (request) {
|
||||
case MINIX_I2C_IOCTL_EXEC:
|
||||
r = do_i2c_ioctl_exec(m);
|
||||
r = do_i2c_ioctl_exec(endpt, grant);
|
||||
break;
|
||||
default:
|
||||
log_warn(&log, "Invalid ioctl() 0x%x\n", m->COUNT);
|
||||
r = EINVAL;
|
||||
log_warn(&log, "Invalid ioctl() 0x%x\n", request);
|
||||
r = ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
i2c_other(message * m)
|
||||
static void
|
||||
i2c_other(message * m, int ipc_status)
|
||||
{
|
||||
message m_reply;
|
||||
int r;
|
||||
|
||||
switch (m->m_type) {
|
||||
case BUSC_I2C_RESERVE:
|
||||
/* reserve a device on the bus for exclusive access */
|
||||
r = do_reserve((endpoint_t) m->m_source, m->DEVICE);
|
||||
break;
|
||||
case BUSC_I2C_EXEC:
|
||||
/* handle request from another driver */
|
||||
m->COUNT = MINIX_I2C_IOCTL_EXEC;
|
||||
r = do_i2c_ioctl_exec(m);
|
||||
break;
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
/* handle notifications about drivers changing state */
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
ds_event();
|
||||
}
|
||||
r = OK;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m->m_type) {
|
||||
case BUSC_I2C_RESERVE:
|
||||
/* reserve a device on the bus for exclusive access */
|
||||
r = do_reserve(m->m_source, m->BUSC_I2C_ADDR);
|
||||
break;
|
||||
case BUSC_I2C_EXEC:
|
||||
/* handle request from another driver */
|
||||
r = do_i2c_ioctl_exec(m->m_source, m->BUSC_I2C_GRANT);
|
||||
break;
|
||||
default:
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
|
|
@ -350,25 +336,12 @@ i2c_other(message * m)
|
|||
|
||||
log_trace(&log, "i2c_other() returning r=%d\n", r);
|
||||
|
||||
return r;
|
||||
}
|
||||
/* Send a reply. */
|
||||
memset(&m_reply, 0, sizeof(m_reply));
|
||||
m_reply.m_type = r;
|
||||
|
||||
struct device *
|
||||
i2c_prepare(dev_t dev)
|
||||
{
|
||||
/* NOP */
|
||||
i2c_device.dv_base = make64(0, 0);
|
||||
i2c_device.dv_size = make64(0, 0);
|
||||
|
||||
return &i2c_device;
|
||||
}
|
||||
|
||||
int
|
||||
i2c_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t user_endpt, unsigned int flags)
|
||||
{
|
||||
/* NOP */
|
||||
return OK;
|
||||
if ((r = send(m->m_source, &m_reply)) != OK)
|
||||
log_warn(&log, "send() to %d failed: %d\n", m->m_source, r);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -549,7 +522,7 @@ main(int argc, char *argv[])
|
|||
|
||||
memset(i2cdev, '\0', sizeof(i2cdev));
|
||||
sef_local_startup();
|
||||
chardriver_task(&i2c_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&i2c_tab);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ service lance
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 1022/2000;
|
||||
pci device 1022:2000;
|
||||
uid 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,32 +19,24 @@
|
|||
#define LOGINC(n, i) do { (n) = (((n) + (i)) % LOG_SIZE); } while(0)
|
||||
|
||||
struct logdevice logdevices[NR_DEVS];
|
||||
static struct device log_geom[NR_DEVS]; /* base and size of devices */
|
||||
static int log_device = -1; /* current device */
|
||||
|
||||
static struct device *log_prepare(dev_t device);
|
||||
static int log_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
|
||||
flags);
|
||||
static int log_do_open(message *m_ptr);
|
||||
static int log_cancel(message *m_ptr);
|
||||
static int log_select(message *m_ptr);
|
||||
static int log_other(message *m_ptr);
|
||||
static int subread(struct logdevice *log, int count, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t);
|
||||
static ssize_t log_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static ssize_t log_write(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static int log_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int log_cancel(devminor_t minor, endpoint_t endpt, cdev_id_t id);
|
||||
static int log_select(devminor_t minor, unsigned int ops, endpoint_t endpt);
|
||||
static int subread(struct logdevice *log, size_t size, endpoint_t endpt,
|
||||
cp_grant_id_t grant);
|
||||
|
||||
/* Entry points to this driver. */
|
||||
static struct chardriver log_dtab = {
|
||||
log_do_open, /* open or mount */
|
||||
do_nop, /* nothing on a close */
|
||||
nop_ioctl, /* ioctl nop */
|
||||
log_prepare, /* prepare for I/O on a given minor device */
|
||||
log_transfer, /* do the I/O */
|
||||
nop_cleanup, /* no need to clean up */
|
||||
nop_alarm, /* no alarm */
|
||||
log_cancel, /* CANCEL request */
|
||||
log_select, /* DEV_SELECT request */
|
||||
log_other /* Unrecognized messages */
|
||||
.cdr_open = log_open,
|
||||
.cdr_read = log_read,
|
||||
.cdr_write = log_write,
|
||||
.cdr_cancel = log_cancel,
|
||||
.cdr_select = log_select
|
||||
};
|
||||
|
||||
/* SEF functions and variables. */
|
||||
|
|
@ -64,7 +56,7 @@ int main(void)
|
|||
sef_local_startup();
|
||||
|
||||
/* Call the generic receive loop. */
|
||||
chardriver_task(&log_dtab, CHARDRIVER_ASYNC);
|
||||
chardriver_task(&log_dtab);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -101,17 +93,15 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
|
||||
/* Initialize log devices. */
|
||||
for(i = 0; i < NR_DEVS; i++) {
|
||||
log_geom[i].dv_size = ((u64_t)(LOG_SIZE));
|
||||
log_geom[i].dv_base = ((u64_t)((long)logdevices[i].log_buffer));
|
||||
logdevices[i].log_size = logdevices[i].log_read =
|
||||
logdevices[i].log_write =
|
||||
logdevices[i].log_select_alerted =
|
||||
logdevices[i].log_selected =
|
||||
logdevices[i].log_select_ready_ops = 0;
|
||||
logdevices[i].log_selected = 0;
|
||||
logdevices[i].log_source = NONE;
|
||||
logdevices[i].log_revive_alerted = 0;
|
||||
}
|
||||
|
||||
/* Register for diagnostics notifications. */
|
||||
sys_diagctl_register();
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
|
@ -126,29 +116,24 @@ static void sef_cb_signal_handler(int signo)
|
|||
do_new_kmess();
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* log_prepare *
|
||||
*===========================================================================*/
|
||||
static struct device *log_prepare(dev_t device)
|
||||
{
|
||||
/* Prepare for I/O on a device: check if the minor device number is ok. */
|
||||
|
||||
if (device >= NR_DEVS) return(NULL);
|
||||
log_device = (int) device;
|
||||
|
||||
return(&log_geom[device]);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* subwrite *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
subwrite(struct logdevice *log, int count, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t offset, char *localbuf)
|
||||
subwrite(struct logdevice *log, size_t size, endpoint_t endpt,
|
||||
cp_grant_id_t grant, char *localbuf)
|
||||
{
|
||||
int d, r;
|
||||
char *buf;
|
||||
message m;
|
||||
size_t count, offset;
|
||||
int overflow, r;
|
||||
devminor_t minor;
|
||||
char *buf;
|
||||
message m;
|
||||
|
||||
/* With a sufficiently large input size, we might wrap around the ring buffer
|
||||
* multiple times.
|
||||
*/
|
||||
for (offset = 0; offset < size; offset += count) {
|
||||
count = size - offset;
|
||||
|
||||
if (log->log_write + count > LOG_SIZE)
|
||||
count = LOG_SIZE - log->log_write;
|
||||
|
|
@ -156,75 +141,49 @@ subwrite(struct logdevice *log, int count, endpoint_t endpt,
|
|||
|
||||
if(localbuf != NULL) {
|
||||
memcpy(buf, localbuf, count);
|
||||
localbuf += count;
|
||||
}
|
||||
else {
|
||||
if((r=sys_safecopyfrom(endpt, grant, offset,
|
||||
(vir_bytes)buf, count)) != OK)
|
||||
return r;
|
||||
break; /* do process partial write upon error */
|
||||
}
|
||||
|
||||
LOGINC(log->log_write, count);
|
||||
log->log_size += count;
|
||||
|
||||
if(log->log_size > LOG_SIZE) {
|
||||
int overflow;
|
||||
overflow = log->log_size - LOG_SIZE;
|
||||
log->log_size -= overflow;
|
||||
LOGINC(log->log_read, overflow);
|
||||
}
|
||||
|
||||
if(log->log_size > 0 && log->log_source != NONE &&
|
||||
!log->log_revive_alerted) {
|
||||
/* Someone who was suspended on read can now
|
||||
* be revived.
|
||||
*/
|
||||
log->log_status = subread(log, log->log_iosize,
|
||||
log->log_source, log->log_user_grant,
|
||||
log->log_user_offset);
|
||||
r = offset; /* this will be the return value upon success */
|
||||
}
|
||||
|
||||
m.m_type = DEV_REVIVE;
|
||||
m.REP_ENDPT = log->log_proc_nr;
|
||||
m.REP_STATUS = log->log_status;
|
||||
m.REP_IO_GRANT = log->log_user_grant;
|
||||
r= send(log->log_source, &m);
|
||||
if (r != OK)
|
||||
{
|
||||
printf("log`subwrite: send to %d failed: %d\n",
|
||||
log->log_source, r);
|
||||
}
|
||||
log->log_source = NONE;
|
||||
}
|
||||
if (log->log_size > 0 && log->log_source != NONE) {
|
||||
/* Someone who was suspended on read can now be revived. */
|
||||
r = subread(log, log->log_iosize, log->log_source, log->log_grant);
|
||||
|
||||
if(log->log_size > 0)
|
||||
log->log_select_ready_ops |= SEL_RD;
|
||||
chardriver_reply_task(log->log_source, log->log_id, r);
|
||||
|
||||
if(log->log_size > 0 && log->log_selected &&
|
||||
!(log->log_select_alerted)) {
|
||||
/* Someone(s) who was/were select()ing can now
|
||||
* be awoken. If there was a blocking read (above),
|
||||
* this can only happen if the blocking read didn't
|
||||
* swallow all the data (log_size > 0).
|
||||
*/
|
||||
if(log->log_selected & SEL_RD) {
|
||||
d= log-logdevices;
|
||||
m.m_type = DEV_SEL_REPL2;
|
||||
m.DEV_SEL_OPS = log->log_select_ready_ops;
|
||||
m.DEV_MINOR = d;
|
||||
log->log_source = NONE;
|
||||
}
|
||||
|
||||
if (log->log_size > 0 && (log->log_selected & CDEV_OP_RD)) {
|
||||
/* Someone(s) who was/were select()ing can now be awoken. If there was
|
||||
* a blocking read (above), this can only happen if the blocking read
|
||||
* didn't swallow all the data (log_size > 0).
|
||||
*/
|
||||
minor = log-logdevices;
|
||||
#if LOG_DEBUG
|
||||
printf("select sending DEV_SEL_REPL2\n");
|
||||
printf("select sending CDEV_SEL2_REPLY\n");
|
||||
#endif
|
||||
r= send(log->log_select_proc, &m);
|
||||
if (r != OK)
|
||||
{
|
||||
printf(
|
||||
"log`subwrite: send to %d failed: %d\n",
|
||||
log->log_select_proc, r);
|
||||
}
|
||||
log->log_selected &= ~log->log_select_ready_ops;
|
||||
}
|
||||
}
|
||||
chardriver_reply_select(log->log_select_proc, minor, CDEV_OP_RD);
|
||||
log->log_selected &= ~CDEV_OP_RD;
|
||||
}
|
||||
|
||||
return count;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -233,210 +192,156 @@ subwrite(struct logdevice *log, int count, endpoint_t endpt,
|
|||
void
|
||||
log_append(char *buf, int count)
|
||||
{
|
||||
int w = 0, skip = 0;
|
||||
int skip = 0;
|
||||
|
||||
if(count < 1) return;
|
||||
if(count > LOG_SIZE) skip = count - LOG_SIZE;
|
||||
count -= skip;
|
||||
buf += skip;
|
||||
w = subwrite(&logdevices[0], count, SELF, GRANT_INVALID, 0, buf);
|
||||
if(count < 1) return;
|
||||
if(count > LOG_SIZE) skip = count - LOG_SIZE;
|
||||
count -= skip;
|
||||
buf += skip;
|
||||
|
||||
if(w > 0 && w < count)
|
||||
subwrite(&logdevices[0], count-w, SELF, GRANT_INVALID, 0,
|
||||
buf + w);
|
||||
return;
|
||||
subwrite(&logdevices[0], count, SELF, GRANT_INVALID, buf);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* subread *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
subread(struct logdevice *log, int count, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t offset)
|
||||
subread(struct logdevice *log, size_t size, endpoint_t endpt,
|
||||
cp_grant_id_t grant)
|
||||
{
|
||||
char *buf;
|
||||
int r;
|
||||
size_t offset, count;
|
||||
char *buf;
|
||||
int r;
|
||||
|
||||
for (offset = 0; log->log_size > 0 && offset < size; offset += count) {
|
||||
count = size - offset;
|
||||
|
||||
if (count > log->log_size)
|
||||
count = log->log_size;
|
||||
if (log->log_read + count > LOG_SIZE)
|
||||
count = LOG_SIZE - log->log_read;
|
||||
|
||||
buf = log->log_buffer + log->log_read;
|
||||
if((r=sys_safecopyto(endpt, grant, offset,
|
||||
(vir_bytes)buf, count)) != OK)
|
||||
if((r=sys_safecopyto(endpt, grant, offset, (vir_bytes)buf,
|
||||
count)) != OK)
|
||||
return r;
|
||||
|
||||
LOGINC(log->log_read, count);
|
||||
log->log_size -= count;
|
||||
}
|
||||
|
||||
return count;
|
||||
return offset;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* log_transfer *
|
||||
* log_read *
|
||||
*===========================================================================*/
|
||||
static int log_transfer(
|
||||
endpoint_t endpt, /* endpoint of grant owner */
|
||||
int opcode, /* DEV_GATHER_S or DEV_SCATTER_S */
|
||||
u64_t UNUSED(position), /* offset on device to read or write */
|
||||
iovec_t *iov, /* pointer to read or write request vector */
|
||||
unsigned int nr_req, /* length of request vector */
|
||||
endpoint_t user_endpt, /* endpoint of user process */
|
||||
unsigned int UNUSED(flags)
|
||||
)
|
||||
static ssize_t log_read(devminor_t minor, u64_t UNUSED(position),
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int flags,
|
||||
cdev_id_t id)
|
||||
{
|
||||
/* Read or write one the driver's minor devices. */
|
||||
int count;
|
||||
cp_grant_id_t grant;
|
||||
int accumulated_read = 0;
|
||||
/* Read from one of the driver's minor devices. */
|
||||
struct logdevice *log;
|
||||
size_t vir_offset = 0;
|
||||
int r;
|
||||
|
||||
if(log_device < 0 || log_device >= NR_DEVS)
|
||||
return EIO;
|
||||
if (minor < 0 || minor >= NR_DEVS) return EIO;
|
||||
log = &logdevices[minor];
|
||||
|
||||
/* Get minor device number and check for /dev/null. */
|
||||
log = &logdevices[log_device];
|
||||
/* If there's already someone hanging to read, don't accept new work. */
|
||||
if (log->log_source != NONE) return OK;
|
||||
|
||||
while (nr_req > 0) {
|
||||
/* How much to transfer and where to / from. */
|
||||
count = iov->iov_size;
|
||||
grant = iov->iov_addr;
|
||||
if (!log->log_size && size > 0) {
|
||||
if (flags & CDEV_NONBLOCK) return EAGAIN;
|
||||
|
||||
switch (log_device) {
|
||||
|
||||
case MINOR_KLOG:
|
||||
if (opcode == DEV_GATHER_S) {
|
||||
if (log->log_source != NONE || count < 1) {
|
||||
/* There's already someone hanging to read, or
|
||||
* no real I/O requested.
|
||||
*/
|
||||
return(OK);
|
||||
}
|
||||
|
||||
if (!log->log_size) {
|
||||
if(accumulated_read)
|
||||
return OK;
|
||||
/* No data available; let caller block. */
|
||||
log->log_source = endpt;
|
||||
log->log_iosize = count;
|
||||
log->log_user_grant = grant;
|
||||
log->log_user_offset = 0;
|
||||
log->log_revive_alerted = 0;
|
||||
log->log_proc_nr = user_endpt;
|
||||
/* No data available; let caller block. */
|
||||
log->log_source = endpt;
|
||||
log->log_iosize = size;
|
||||
log->log_grant = grant;
|
||||
log->log_id = id;
|
||||
#if LOG_DEBUG
|
||||
printf("blocked %d (%d)\n",
|
||||
log->log_source, log->log_proc_nr);
|
||||
printf("blocked %d (%d)\n", log->log_source, id);
|
||||
#endif
|
||||
return(EDONTREPLY);
|
||||
}
|
||||
count = subread(log, count, endpt, grant, vir_offset);
|
||||
if(count < 0) {
|
||||
return count;
|
||||
}
|
||||
accumulated_read += count;
|
||||
} else {
|
||||
count = subwrite(log, count, endpt, grant, vir_offset, NULL);
|
||||
if(count < 0)
|
||||
return count;
|
||||
}
|
||||
break;
|
||||
/* Unknown (illegal) minor device. */
|
||||
default:
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
/* Book the number of bytes transferred. */
|
||||
vir_offset += count;
|
||||
if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; }
|
||||
return EDONTREPLY;
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return subread(log, size, endpt, grant);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* log_write *
|
||||
*===========================================================================*/
|
||||
static ssize_t log_write(devminor_t minor, u64_t UNUSED(position),
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Write to one of the driver's minor devices. */
|
||||
struct logdevice *log;
|
||||
int r;
|
||||
|
||||
if (minor < 0 || minor >= NR_DEVS) return EIO;
|
||||
log = &logdevices[minor];
|
||||
|
||||
return subwrite(log, size, endpt, grant, NULL);
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* log_do_open *
|
||||
* log_open *
|
||||
*============================================================================*/
|
||||
static int log_do_open(message *m_ptr)
|
||||
static int log_open(devminor_t minor, int UNUSED(access),
|
||||
endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
if (log_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
|
||||
if (minor < 0 || minor >= NR_DEVS) return(ENXIO);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* log_cancel *
|
||||
*============================================================================*/
|
||||
static int log_cancel(message *m_ptr)
|
||||
static int log_cancel(devminor_t minor, endpoint_t endpt, cdev_id_t id)
|
||||
{
|
||||
int d;
|
||||
d = m_ptr->TTY_LINE;
|
||||
if(d < 0 || d >= NR_DEVS)
|
||||
if (minor < 0 || minor >= NR_DEVS)
|
||||
return EINVAL;
|
||||
logdevices[d].log_proc_nr = NONE;
|
||||
logdevices[d].log_revive_alerted = 0;
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* log_other *
|
||||
*============================================================================*/
|
||||
static int log_other(message *m_ptr)
|
||||
{
|
||||
int r;
|
||||
/* Not for the suspended request? Must be a stale cancel request. Ignore. */
|
||||
if (logdevices[minor].log_source != endpt || logdevices[minor].log_id != id)
|
||||
return EDONTREPLY;
|
||||
|
||||
/* This function gets messages that the generic driver doesn't
|
||||
* understand.
|
||||
*/
|
||||
if (is_notify(m_ptr->m_type)) {
|
||||
return EINVAL;
|
||||
}
|
||||
logdevices[minor].log_source = NONE;
|
||||
|
||||
switch(m_ptr->m_type) {
|
||||
case DEV_STATUS: {
|
||||
printf("log_other: unexpected DEV_STATUS request\n");
|
||||
r = EDONTREPLY;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
r = EINVAL;
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
return EINTR; /* this is the reply to the original, interrupted request */
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* log_select *
|
||||
*============================================================================*/
|
||||
static int log_select(message *m_ptr)
|
||||
static int log_select(devminor_t minor, unsigned int ops, endpoint_t endpt)
|
||||
{
|
||||
int d, ready_ops = 0, ops = 0;
|
||||
d = m_ptr->TTY_LINE;
|
||||
if(d < 0 || d >= NR_DEVS) {
|
||||
#if LOG_DEBUG
|
||||
printf("line %d? EINVAL\n", d);
|
||||
#endif
|
||||
return EINVAL;
|
||||
}
|
||||
int want_ops, ready_ops = 0;
|
||||
|
||||
ops = m_ptr->USER_ENDPT & (SEL_RD|SEL_WR|SEL_ERR);
|
||||
if (minor < 0 || minor >= NR_DEVS)
|
||||
return ENXIO;
|
||||
|
||||
want_ops = ops & (CDEV_OP_RD | CDEV_OP_WR | CDEV_OP_ERR);
|
||||
|
||||
/* Read blocks when there is no log. */
|
||||
if((m_ptr->USER_ENDPT & SEL_RD) && logdevices[d].log_size > 0) {
|
||||
if ((want_ops & CDEV_OP_RD) && logdevices[minor].log_size > 0) {
|
||||
#if LOG_DEBUG
|
||||
printf("log can read; size %d\n", logdevices[d].log_size);
|
||||
printf("log can read; size %d\n", logdevices[minor].log_size);
|
||||
#endif
|
||||
ready_ops |= SEL_RD; /* writes never block */
|
||||
ready_ops |= CDEV_OP_RD;
|
||||
}
|
||||
|
||||
/* Write never blocks. */
|
||||
if(m_ptr->USER_ENDPT & SEL_WR) ready_ops |= SEL_WR;
|
||||
if (want_ops & CDEV_OP_WR) ready_ops |= CDEV_OP_WR;
|
||||
|
||||
/* Enable select calback if no operations were
|
||||
* ready to go, but operations were requested,
|
||||
* and notify was enabled.
|
||||
*/
|
||||
if((m_ptr->USER_ENDPT & SEL_NOTIFY) && ops && !ready_ops) {
|
||||
logdevices[d].log_selected |= ops;
|
||||
logdevices[d].log_select_proc = m_ptr->m_source;
|
||||
/* Enable select calback if not all requested operations were ready to go,
|
||||
* and notify was enabled.
|
||||
*/
|
||||
want_ops &= ~ready_ops;
|
||||
if ((ops & CDEV_NOTIFY) && want_ops) {
|
||||
logdevices[minor].log_selected |= want_ops;
|
||||
logdevices[minor].log_select_proc = endpt;
|
||||
#if LOG_DEBUG
|
||||
printf("log setting selector.\n");
|
||||
#endif
|
||||
|
|
@ -448,4 +353,3 @@ static int log_select(message *m_ptr)
|
|||
|
||||
return(ready_ops);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,24 +10,18 @@
|
|||
/* Constants and types. */
|
||||
|
||||
#define LOG_SIZE (50*1024)
|
||||
#define SUSPENDABLE 1
|
||||
|
||||
struct logdevice {
|
||||
char log_buffer[LOG_SIZE];
|
||||
int log_size, /* no. of bytes in log buffer */
|
||||
log_read, /* read mark */
|
||||
log_write; /* write mark */
|
||||
#if SUSPENDABLE
|
||||
endpoint_t log_proc_nr,
|
||||
log_source;
|
||||
endpoint_t log_source;
|
||||
cdev_id_t log_id;
|
||||
int log_iosize,
|
||||
log_revive_alerted,
|
||||
log_status;
|
||||
cp_grant_id_t log_user_grant;
|
||||
vir_bytes log_user_offset;
|
||||
#endif
|
||||
int log_selected, log_select_proc,
|
||||
log_select_alerted, log_select_ready_ops;
|
||||
cp_grant_id_t log_grant;
|
||||
int log_selected, log_select_proc;
|
||||
};
|
||||
|
||||
/* Function prototypes. */
|
||||
|
|
|
|||
|
|
@ -41,63 +41,46 @@
|
|||
|
||||
static struct device m_geom[NR_DEVS]; /* base and size of each device */
|
||||
static vir_bytes m_vaddrs[NR_DEVS];
|
||||
static dev_t m_device; /* current minor character device */
|
||||
|
||||
static int openct[NR_DEVS];
|
||||
|
||||
static struct device *m_prepare(dev_t device);
|
||||
static int m_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
|
||||
flags);
|
||||
static int m_do_open(message *m_ptr);
|
||||
static int m_do_close(message *m_ptr);
|
||||
static ssize_t m_char_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static ssize_t m_char_write(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static int m_char_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int m_char_close(devminor_t minor);
|
||||
|
||||
static struct device *m_block_part(dev_t minor);
|
||||
static int m_block_transfer(dev_t minor, int do_write, u64_t position,
|
||||
static struct device *m_block_part(devminor_t minor);
|
||||
static ssize_t m_block_transfer(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, iovec_t *iov, unsigned int nr_req, int flags);
|
||||
static int m_block_open(dev_t minor, int access);
|
||||
static int m_block_close(dev_t minor);
|
||||
static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t
|
||||
endpt, cp_grant_id_t grant);
|
||||
static int m_block_open(devminor_t minor, int access);
|
||||
static int m_block_close(devminor_t minor);
|
||||
static int m_block_ioctl(devminor_t minor, unsigned long request, endpoint_t
|
||||
endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
|
||||
/* Entry points to the CHARACTER part of this driver. */
|
||||
static struct chardriver m_cdtab = {
|
||||
m_do_open, /* open or mount */
|
||||
m_do_close, /* nothing on a close */
|
||||
nop_ioctl, /* no I/O control */
|
||||
m_prepare, /* prepare for I/O on a given minor device */
|
||||
m_transfer, /* do the I/O */
|
||||
nop_cleanup, /* no need to clean up */
|
||||
nop_alarm, /* no alarms */
|
||||
nop_cancel, /* no blocking operations */
|
||||
nop_select, /* select not supported */
|
||||
NULL /* other messages not supported */
|
||||
.cdr_open = m_char_open, /* open device */
|
||||
.cdr_close = m_char_close, /* close device */
|
||||
.cdr_read = m_char_read, /* read from device */
|
||||
.cdr_write = m_char_write /* write to device */
|
||||
};
|
||||
|
||||
/* Entry points to the BLOCK part of this driver. */
|
||||
static struct blockdriver m_bdtab = {
|
||||
BLOCKDRIVER_TYPE_DISK,/* handle partition requests */
|
||||
m_block_open, /* open or mount */
|
||||
m_block_close, /* nothing on a close */
|
||||
m_block_transfer, /* do the I/O */
|
||||
m_block_ioctl, /* ram disk I/O control */
|
||||
NULL, /* no need to clean up */
|
||||
m_block_part, /* return partition information */
|
||||
NULL, /* no geometry */
|
||||
NULL, /* no interrupt processing */
|
||||
NULL, /* no alarm processing */
|
||||
NULL, /* no processing of other messages */
|
||||
NULL /* no threading support */
|
||||
.bdr_type = BLOCKDRIVER_TYPE_DISK,/* handle partition requests */
|
||||
.bdr_open = m_block_open, /* open device */
|
||||
.bdr_close = m_block_close, /* nothing on a close */
|
||||
.bdr_transfer = m_block_transfer, /* do the I/O */
|
||||
.bdr_ioctl = m_block_ioctl, /* ram disk I/O control */
|
||||
.bdr_part = m_block_part /* return partition information */
|
||||
};
|
||||
|
||||
#define click_to_round_k(n) \
|
||||
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* main *
|
||||
*===========================================================================*/
|
||||
|
|
@ -117,8 +100,7 @@ int main(void)
|
|||
if (IS_BDEV_RQ(msg.m_type))
|
||||
blockdriver_process(&m_bdtab, &msg, ipc_status);
|
||||
else
|
||||
chardriver_process(&m_cdtab, CHARDRIVER_SYNC, &msg,
|
||||
ipc_status);
|
||||
chardriver_process(&m_cdtab, &msg, ipc_status);
|
||||
}
|
||||
|
||||
return(OK);
|
||||
|
|
@ -158,8 +140,8 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
}
|
||||
|
||||
/* Map in kernel memory for /dev/kmem. */
|
||||
m_geom[KMEM_DEV].dv_base = cvul64(kinfo.kmem_base);
|
||||
m_geom[KMEM_DEV].dv_size = cvul64(kinfo.kmem_size);
|
||||
m_geom[KMEM_DEV].dv_base = kinfo.kmem_base;
|
||||
m_geom[KMEM_DEV].dv_size = kinfo.kmem_size;
|
||||
if((m_vaddrs[KMEM_DEV] = vm_map_phys(SELF, (void *) kinfo.kmem_base,
|
||||
kinfo.kmem_size)) == MAP_FAILED) {
|
||||
printf("MEM: Couldn't map in /dev/kmem.");
|
||||
|
|
@ -167,16 +149,16 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
#endif
|
||||
|
||||
/* Ramdisk image built into the memory driver */
|
||||
m_geom[IMGRD_DEV].dv_base= ((u64_t)(0));
|
||||
m_geom[IMGRD_DEV].dv_size= ((u64_t)(imgrd_size));
|
||||
m_geom[IMGRD_DEV].dv_base= 0;
|
||||
m_geom[IMGRD_DEV].dv_size= imgrd_size;
|
||||
m_vaddrs[IMGRD_DEV] = (vir_bytes) imgrd;
|
||||
|
||||
for(i = 0; i < NR_DEVS; i++)
|
||||
openct[i] = 0;
|
||||
|
||||
/* Set up memory range for /dev/mem. */
|
||||
m_geom[MEM_DEV].dv_base = ((u64_t)(0));
|
||||
m_geom[MEM_DEV].dv_size = ((u64_t)(0xffffffff));
|
||||
m_geom[MEM_DEV].dv_base = 0;
|
||||
m_geom[MEM_DEV].dv_size = 0xffffffffULL;
|
||||
|
||||
m_vaddrs[MEM_DEV] = (vir_bytes) MAP_FAILED; /* we are not mapping this in. */
|
||||
|
||||
|
|
@ -186,7 +168,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
/*===========================================================================*
|
||||
* m_is_block *
|
||||
*===========================================================================*/
|
||||
static int m_is_block(dev_t minor)
|
||||
static int m_is_block(devminor_t minor)
|
||||
{
|
||||
/* Return TRUE iff the given minor device number is for a block device. */
|
||||
|
||||
|
|
@ -203,206 +185,218 @@ static int m_is_block(dev_t minor)
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_prepare *
|
||||
* m_transfer_kmem *
|
||||
*===========================================================================*/
|
||||
static struct device *m_prepare(dev_t device)
|
||||
static ssize_t m_transfer_kmem(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size)
|
||||
{
|
||||
/* Prepare for I/O on a device: check if the minor device number is ok. */
|
||||
if (device >= NR_DEVS || m_is_block(device)) return(NULL);
|
||||
m_device = device;
|
||||
|
||||
return(&m_geom[device]);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_transfer *
|
||||
*===========================================================================*/
|
||||
static int m_transfer(
|
||||
endpoint_t endpt, /* endpoint of grant owner */
|
||||
int opcode, /* DEV_GATHER_S or DEV_SCATTER_S */
|
||||
u64_t pos64, /* offset on device to read or write */
|
||||
iovec_t *iov, /* pointer to read or write request vector */
|
||||
unsigned int nr_req, /* length of request vector */
|
||||
endpoint_t UNUSED(user_endpt),/* endpoint of user process */
|
||||
unsigned int UNUSED(flags)
|
||||
)
|
||||
{
|
||||
/* Read or write one the driver's character devices. */
|
||||
unsigned count;
|
||||
vir_bytes vir_offset = 0;
|
||||
struct device *dv;
|
||||
u64_t dv_size;
|
||||
int s, r;
|
||||
u64_t position;
|
||||
cp_grant_id_t grant;
|
||||
vir_bytes dev_vaddr;
|
||||
|
||||
/* ZERO_DEV and NULL_DEV are infinite in size. */
|
||||
if (m_device != ZERO_DEV && m_device != NULL_DEV && ex64hi(pos64) != 0)
|
||||
return OK; /* Beyond EOF */
|
||||
position= pos64;
|
||||
|
||||
/* Get minor device number and check for /dev/null. */
|
||||
dv = &m_geom[m_device];
|
||||
dv_size = dv->dv_size;
|
||||
dev_vaddr = m_vaddrs[m_device];
|
||||
|
||||
while (nr_req > 0) {
|
||||
|
||||
/* How much to transfer and where to / from. */
|
||||
count = iov->iov_size;
|
||||
grant = (cp_grant_id_t) iov->iov_addr;
|
||||
|
||||
switch (m_device) {
|
||||
|
||||
/* No copying; ignore request. */
|
||||
case NULL_DEV:
|
||||
if (opcode == DEV_GATHER_S) return(OK); /* always at EOF */
|
||||
break;
|
||||
|
||||
/* Virtual copying. For kernel memory. */
|
||||
default:
|
||||
case KMEM_DEV:
|
||||
if(!dev_vaddr || dev_vaddr == (vir_bytes) MAP_FAILED) {
|
||||
printf("MEM: dev %d not initialized\n", m_device);
|
||||
return EIO;
|
||||
}
|
||||
if (position >= dv_size) return(OK); /* check for EOF */
|
||||
if (position + count > dv_size) count = dv_size - position;
|
||||
if (opcode == DEV_GATHER_S) { /* copy actual data */
|
||||
r=sys_safecopyto(endpt, grant, vir_offset,
|
||||
dev_vaddr + position, count);
|
||||
} else {
|
||||
r=sys_safecopyfrom(endpt, grant, vir_offset,
|
||||
dev_vaddr + position, count);
|
||||
}
|
||||
if(r != OK) {
|
||||
panic("I/O copy failed: %d", r);
|
||||
}
|
||||
break;
|
||||
|
||||
/* Physical copying. Only used to access entire memory.
|
||||
* Transfer one 'page window' at a time.
|
||||
*/
|
||||
case MEM_DEV:
|
||||
{
|
||||
u32_t pagestart, page_off;
|
||||
static u32_t pagestart_mapped;
|
||||
static int any_mapped = 0;
|
||||
static char *vaddr;
|
||||
int r;
|
||||
u32_t subcount;
|
||||
phys_bytes mem_phys;
|
||||
|
||||
if (position >= dv_size)
|
||||
return(OK); /* check for EOF */
|
||||
if (position + count > dv_size)
|
||||
count = dv_size - position;
|
||||
mem_phys = position;
|
||||
|
||||
page_off = mem_phys % PAGE_SIZE;
|
||||
pagestart = mem_phys - page_off;
|
||||
|
||||
/* All memory to the map call has to be page-aligned.
|
||||
* Don't have to map same page over and over.
|
||||
*/
|
||||
if(!any_mapped || pagestart_mapped != pagestart) {
|
||||
if(any_mapped) {
|
||||
if(vm_unmap_phys(SELF, vaddr, PAGE_SIZE) != OK)
|
||||
panic("vm_unmap_phys failed");
|
||||
any_mapped = 0;
|
||||
}
|
||||
vaddr = vm_map_phys(SELF, (void *) pagestart, PAGE_SIZE);
|
||||
if(vaddr == MAP_FAILED)
|
||||
r = ENOMEM;
|
||||
else
|
||||
r = OK;
|
||||
if(r != OK) {
|
||||
printf("memory: vm_map_phys failed\n");
|
||||
return r;
|
||||
}
|
||||
any_mapped = 1;
|
||||
pagestart_mapped = pagestart;
|
||||
}
|
||||
|
||||
/* how much to be done within this page. */
|
||||
subcount = PAGE_SIZE-page_off;
|
||||
if(subcount > count)
|
||||
subcount = count;
|
||||
|
||||
if (opcode == DEV_GATHER_S) { /* copy data */
|
||||
s=sys_safecopyto(endpt, grant,
|
||||
vir_offset, (vir_bytes) vaddr+page_off, subcount);
|
||||
} else {
|
||||
s=sys_safecopyfrom(endpt, grant,
|
||||
vir_offset, (vir_bytes) vaddr+page_off, subcount);
|
||||
}
|
||||
if(s != OK)
|
||||
return s;
|
||||
count = subcount;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Null byte stream generator. */
|
||||
case ZERO_DEV:
|
||||
if (opcode == DEV_GATHER_S)
|
||||
if ((s = sys_safememset(endpt, grant, 0, '\0', count)) != OK)
|
||||
return s;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* Book the number of bytes transferred. */
|
||||
position += count;
|
||||
vir_offset += count;
|
||||
if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; }
|
||||
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_do_open *
|
||||
*===========================================================================*/
|
||||
static int m_do_open(message *m_ptr)
|
||||
{
|
||||
/* Open a memory character device. */
|
||||
/* Transfer from or to the KMEM device. */
|
||||
u64_t dv_size, dev_vaddr;
|
||||
int r;
|
||||
|
||||
/* Check device number on open. */
|
||||
if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
|
||||
dv_size = m_geom[minor].dv_size;
|
||||
dev_vaddr = m_vaddrs[minor];
|
||||
|
||||
if (!dev_vaddr || dev_vaddr == (vir_bytes) MAP_FAILED) {
|
||||
printf("MEM: dev %d not initialized\n", minor);
|
||||
return EIO;
|
||||
}
|
||||
|
||||
if (position >= dv_size) return 0; /* check for EOF */
|
||||
if (position + size > dv_size) size = dv_size - position;
|
||||
|
||||
if (!do_write) /* copy actual data */
|
||||
r = sys_safecopyto(endpt, grant, 0, dev_vaddr + position, size);
|
||||
else
|
||||
r = sys_safecopyfrom(endpt, grant, 0, dev_vaddr + position, size);
|
||||
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_transfer_mem *
|
||||
*===========================================================================*/
|
||||
static ssize_t m_transfer_mem(devminor_t minor, int do_write, u64_t position,
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size)
|
||||
{
|
||||
/* Transfer from or to the MEM device. */
|
||||
static int any_mapped = 0;
|
||||
static phys_bytes pagestart_mapped;
|
||||
static char *vaddr;
|
||||
phys_bytes mem_phys, pagestart;
|
||||
size_t off, page_off, subcount;
|
||||
u64_t dv_size;
|
||||
int r;
|
||||
|
||||
dv_size = m_geom[minor].dv_size;
|
||||
if (position >= dv_size) return 0; /* check for EOF */
|
||||
if (position + size > dv_size) size = dv_size - position;
|
||||
|
||||
/* Physical copying. Only used to access entire memory.
|
||||
* Transfer one 'page window' at a time.
|
||||
*/
|
||||
off = 0;
|
||||
while (off < size) {
|
||||
mem_phys = (phys_bytes) position;
|
||||
|
||||
page_off = (size_t) (mem_phys % PAGE_SIZE);
|
||||
pagestart = mem_phys - page_off;
|
||||
|
||||
/* All memory to the map call has to be page-aligned.
|
||||
* Don't have to map same page over and over.
|
||||
*/
|
||||
if (!any_mapped || pagestart_mapped != pagestart) {
|
||||
if (any_mapped) {
|
||||
if (vm_unmap_phys(SELF, vaddr, PAGE_SIZE) != OK)
|
||||
panic("vm_unmap_phys failed");
|
||||
any_mapped = 0;
|
||||
}
|
||||
|
||||
vaddr = vm_map_phys(SELF, (void *) pagestart, PAGE_SIZE);
|
||||
if (vaddr == MAP_FAILED) {
|
||||
printf("memory: vm_map_phys failed\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
any_mapped = 1;
|
||||
pagestart_mapped = pagestart;
|
||||
}
|
||||
|
||||
/* how much to be done within this page. */
|
||||
subcount = PAGE_SIZE - page_off;
|
||||
if (subcount > size)
|
||||
subcount = size;
|
||||
|
||||
if (!do_write) /* copy data */
|
||||
r = sys_safecopyto(endpt, grant, off,
|
||||
(vir_bytes) vaddr + page_off, subcount);
|
||||
else
|
||||
r = sys_safecopyfrom(endpt, grant, off,
|
||||
(vir_bytes) vaddr + page_off, subcount);
|
||||
if (r != OK)
|
||||
return r;
|
||||
|
||||
position += subcount;
|
||||
off += subcount;
|
||||
}
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_char_read *
|
||||
*===========================================================================*/
|
||||
static ssize_t m_char_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Read from one of the driver's character devices. */
|
||||
ssize_t r;
|
||||
|
||||
/* Check if the minor device number is ok. */
|
||||
if (minor < 0 || minor >= NR_DEVS || m_is_block(minor)) return ENXIO;
|
||||
|
||||
switch (minor) {
|
||||
case NULL_DEV:
|
||||
r = 0; /* always at EOF */
|
||||
break;
|
||||
|
||||
case ZERO_DEV:
|
||||
/* Fill the target area with zeroes. In fact, let the kernel do it! */
|
||||
if ((r = sys_safememset(endpt, grant, 0, '\0', size)) == OK)
|
||||
r = size;
|
||||
break;
|
||||
|
||||
case KMEM_DEV:
|
||||
r = m_transfer_kmem(minor, FALSE, position, endpt, grant, size);
|
||||
break;
|
||||
|
||||
case MEM_DEV:
|
||||
r = m_transfer_mem(minor, FALSE, position, endpt, grant, size);
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("unknown character device %d", minor);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_char_write *
|
||||
*===========================================================================*/
|
||||
static ssize_t m_char_write(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Write to one of the driver's character devices. */
|
||||
ssize_t r;
|
||||
|
||||
/* Check if the minor device number is ok. */
|
||||
if (minor < 0 || minor >= NR_DEVS || m_is_block(minor)) return ENXIO;
|
||||
|
||||
switch (minor) {
|
||||
case NULL_DEV:
|
||||
case ZERO_DEV:
|
||||
r = size; /* just eat everything */
|
||||
break;
|
||||
|
||||
case KMEM_DEV:
|
||||
r = m_transfer_kmem(minor, TRUE, position, endpt, grant, size);
|
||||
break;
|
||||
|
||||
case MEM_DEV:
|
||||
r = m_transfer_mem(minor, TRUE, position, endpt, grant, size);
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("unknown character device %d", minor);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_char_open *
|
||||
*===========================================================================*/
|
||||
static int m_char_open(devminor_t minor, int access, endpoint_t user_endpt)
|
||||
{
|
||||
/* Open a memory character device. */
|
||||
|
||||
/* Check if the minor device number is ok. */
|
||||
if (minor < 0 || minor >= NR_DEVS || m_is_block(minor)) return ENXIO;
|
||||
|
||||
#if defined(__i386__)
|
||||
if (m_device == MEM_DEV)
|
||||
if (minor == MEM_DEV)
|
||||
{
|
||||
r = sys_enable_iop(m_ptr->USER_ENDPT);
|
||||
int r = sys_enable_iop(user_endpt);
|
||||
if (r != OK)
|
||||
{
|
||||
printf("m_do_open: sys_enable_iop failed for %d: %d\n",
|
||||
m_ptr->USER_ENDPT, r);
|
||||
printf("m_char_open: sys_enable_iop failed for %d: %d\n",
|
||||
user_endpt, r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
openct[m_device]++;
|
||||
openct[minor]++;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* m_do_close *
|
||||
* m_char_close *
|
||||
*===========================================================================*/
|
||||
static int m_do_close(message *m_ptr)
|
||||
static int m_char_close(devminor_t minor)
|
||||
{
|
||||
/* Close a memory character device. */
|
||||
if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
|
||||
|
||||
if(openct[m_device] < 1) {
|
||||
printf("MEMORY: closing unopened device %d\n", m_device);
|
||||
if (minor < 0 || minor >= NR_DEVS || m_is_block(minor)) return ENXIO;
|
||||
|
||||
if(openct[minor] < 1) {
|
||||
printf("MEMORY: closing unopened device %d\n", minor);
|
||||
return(EINVAL);
|
||||
}
|
||||
openct[m_device]--;
|
||||
openct[minor]--;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -410,10 +404,10 @@ static int m_do_close(message *m_ptr)
|
|||
/*===========================================================================*
|
||||
* m_block_part *
|
||||
*===========================================================================*/
|
||||
static struct device *m_block_part(dev_t minor)
|
||||
static struct device *m_block_part(devminor_t minor)
|
||||
{
|
||||
/* Prepare for I/O on a device: check if the minor device number is ok. */
|
||||
if (minor >= NR_DEVS || !m_is_block(minor)) return(NULL);
|
||||
if (minor < 0 || minor >= NR_DEVS || !m_is_block(minor)) return(NULL);
|
||||
|
||||
return(&m_geom[minor]);
|
||||
}
|
||||
|
|
@ -422,9 +416,9 @@ static struct device *m_block_part(dev_t minor)
|
|||
* m_block_transfer *
|
||||
*===========================================================================*/
|
||||
static int m_block_transfer(
|
||||
dev_t minor, /* minor device number */
|
||||
devminor_t minor, /* minor device number */
|
||||
int do_write, /* read or write? */
|
||||
u64_t pos64, /* offset on device to read or write */
|
||||
u64_t position, /* offset on device to read or write */
|
||||
endpoint_t endpt, /* process doing the request */
|
||||
iovec_t *iov, /* pointer to read or write request vector */
|
||||
unsigned int nr_req, /* length of request vector */
|
||||
|
|
@ -437,7 +431,6 @@ static int m_block_transfer(
|
|||
struct device *dv;
|
||||
u64_t dv_size;
|
||||
int r;
|
||||
u64_t position;
|
||||
vir_bytes dev_vaddr;
|
||||
cp_grant_id_t grant;
|
||||
ssize_t total = 0;
|
||||
|
|
@ -447,9 +440,8 @@ static int m_block_transfer(
|
|||
dv_size = dv->dv_size;
|
||||
dev_vaddr = m_vaddrs[minor];
|
||||
|
||||
if (ex64hi(pos64) != 0)
|
||||
if (ex64hi(position) != 0)
|
||||
return OK; /* Beyond EOF */
|
||||
position= pos64;
|
||||
|
||||
while (nr_req > 0) {
|
||||
|
||||
|
|
@ -488,7 +480,7 @@ static int m_block_transfer(
|
|||
/*===========================================================================*
|
||||
* m_block_open *
|
||||
*===========================================================================*/
|
||||
static int m_block_open(dev_t minor, int UNUSED(access))
|
||||
static int m_block_open(devminor_t minor, int UNUSED(access))
|
||||
{
|
||||
/* Open a memory block device. */
|
||||
if (m_block_part(minor) == NULL) return(ENXIO);
|
||||
|
|
@ -501,7 +493,7 @@ static int m_block_open(dev_t minor, int UNUSED(access))
|
|||
/*===========================================================================*
|
||||
* m_block_close *
|
||||
*===========================================================================*/
|
||||
static int m_block_close(dev_t minor)
|
||||
static int m_block_close(devminor_t minor)
|
||||
{
|
||||
/* Close a memory block device. */
|
||||
if (m_block_part(minor) == NULL) return(ENXIO);
|
||||
|
|
@ -518,8 +510,8 @@ static int m_block_close(dev_t minor)
|
|||
/*===========================================================================*
|
||||
* m_block_ioctl *
|
||||
*===========================================================================*/
|
||||
static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant)
|
||||
static int m_block_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* I/O controls for the block devices of the memory driver. Currently there is
|
||||
* one I/O control specific to the memory driver:
|
||||
|
|
@ -554,7 +546,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
|||
return s;
|
||||
if(is_imgrd)
|
||||
ramdev_size = 0;
|
||||
if(m_vaddrs[minor] && !cmp64(dv->dv_size, ((u64_t)(ramdev_size)))) {
|
||||
if(m_vaddrs[minor] && dv->dv_size == (u64_t) ramdev_size) {
|
||||
return(OK);
|
||||
}
|
||||
/* openct is 1 for the ioctl(). */
|
||||
|
|
@ -602,7 +594,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
|||
|
||||
m_vaddrs[minor] = (vir_bytes) mem;
|
||||
|
||||
dv->dv_size = ((u64_t)(ramdev_size));
|
||||
dv->dv_size = ramdev_size;
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ static struct log log = {
|
|||
/* holding the current host controller */
|
||||
static struct mmc_host host;
|
||||
|
||||
#define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS)
|
||||
#define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE)
|
||||
|
||||
/* When passing data over a grant one needs to pass
|
||||
|
|
@ -40,19 +39,19 @@ static struct mmc_host host;
|
|||
#define COPYBUFF_SIZE 0x1000 /* 4k buff */
|
||||
static unsigned char copybuff[COPYBUFF_SIZE];
|
||||
|
||||
static struct sd_slot *get_slot(dev_t minor);
|
||||
static struct sd_slot *get_slot(devminor_t minor);
|
||||
|
||||
/* Prototypes for the block device */
|
||||
static int block_open(dev_t minor, int access);
|
||||
static int block_close(dev_t minor);
|
||||
static int block_transfer(dev_t minor,
|
||||
static int block_open(devminor_t minor, int access);
|
||||
static int block_close(devminor_t minor);
|
||||
static int block_transfer(devminor_t minor,
|
||||
int do_write,
|
||||
u64_t position,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned int nr_req, int flags);
|
||||
|
||||
static int block_ioctl(dev_t minor,
|
||||
unsigned int request, endpoint_t endpt, cp_grant_id_t grant);
|
||||
static struct device *block_part(dev_t minor);
|
||||
static int block_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
static struct device *block_part(devminor_t minor);
|
||||
|
||||
/* System even handling */
|
||||
static void sef_local_startup();
|
||||
|
|
@ -73,18 +72,14 @@ static void set_log_level(int level);
|
|||
|
||||
/* Entry points for the BLOCK driver. */
|
||||
static struct blockdriver mmc_driver = {
|
||||
BLOCKDRIVER_TYPE_DISK, /* handle partition requests */
|
||||
block_open, /* open or mount */
|
||||
block_close, /* on a close */
|
||||
block_transfer, /* does the I/O */
|
||||
block_ioctl, /* ioclt's */
|
||||
NULL, /* no need to clean up (yet) */
|
||||
block_part, /* return partition information */
|
||||
NULL, /* no geometry */
|
||||
hw_intr, /* left over interrupts */
|
||||
bdr_alarm, /* no alarm processing */
|
||||
NULL, /* no processing of other messages */
|
||||
NULL /* no threading support */
|
||||
.bdr_type = BLOCKDRIVER_TYPE_DISK,/* handle partition requests */
|
||||
.bdr_open = block_open, /* device open */
|
||||
.bdr_close = block_close, /* on a close */
|
||||
.bdr_transfer = block_transfer, /* does the I/O */
|
||||
.bdr_ioctl = block_ioctl, /* ioctls */
|
||||
.bdr_part = block_part, /* get partition information */
|
||||
.bdr_intr = hw_intr, /* left over interrupts */
|
||||
.bdr_alarm = bdr_alarm /* no alarm processing */
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -142,7 +137,7 @@ apply_env()
|
|||
* block_open *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
block_open(dev_t minor, int access)
|
||||
block_open(devminor_t minor, int access)
|
||||
{
|
||||
struct sd_slot *slot;
|
||||
slot = get_slot(minor);
|
||||
|
|
@ -214,7 +209,7 @@ block_open(dev_t minor, int access)
|
|||
* block_close *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
block_close(dev_t minor)
|
||||
block_close(devminor_t minor)
|
||||
{
|
||||
struct sd_slot *slot;
|
||||
|
||||
|
|
@ -281,7 +276,8 @@ copyfrom(endpoint_t src_e,
|
|||
* block_transfer *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
block_transfer(dev_t minor, /* minor device number */
|
||||
block_transfer(
|
||||
devminor_t minor, /* minor device number */
|
||||
int do_write, /* read or write? */
|
||||
u64_t position, /* offset on device to read or write */
|
||||
endpoint_t endpt, /* process doing the request */
|
||||
|
|
@ -439,8 +435,8 @@ block_transfer(dev_t minor, /* minor device number */
|
|||
* block_ioctl *
|
||||
*===========================================================================*/
|
||||
static int
|
||||
block_ioctl(dev_t minor,
|
||||
unsigned int request, endpoint_t endpt, cp_grant_id_t grant)
|
||||
block_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* IOCTL handling */
|
||||
struct sd_slot *slot;
|
||||
|
|
@ -470,14 +466,14 @@ block_ioctl(dev_t minor,
|
|||
return OK;
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* block_part *
|
||||
*===========================================================================*/
|
||||
static struct device *
|
||||
block_part(dev_t minor)
|
||||
block_part(devminor_t minor)
|
||||
{
|
||||
/*
|
||||
* Reuse the existing MINIX major/minor partitioning scheme.
|
||||
|
|
@ -615,7 +611,7 @@ block_signal_handler_cb(int signo)
|
|||
#define IS_MINIX_SUB_PARTITION_MINOR(minor) (minor >= MINOR_d0p0s0 )
|
||||
|
||||
static struct sd_slot *
|
||||
get_slot(dev_t minor)
|
||||
get_slot(devminor_t minor)
|
||||
{
|
||||
/*
|
||||
* Get an sd_slot based on the minor number.
|
||||
|
|
@ -627,7 +623,7 @@ get_slot(dev_t minor)
|
|||
* number 128 till 144 for sub partitions.
|
||||
*/
|
||||
/* If this is a minor for the first disk (e.g. minor 0 till 5) */
|
||||
if (minor / DEV_PER_DRIVE == 0) {
|
||||
if (minor >= 0 && minor / DEV_PER_DRIVE == 0) {
|
||||
/* we are talking about the first disk and that is all we
|
||||
* support */
|
||||
return &host.slot[0];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include <minix/syslib.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <machine/pci.h>
|
||||
#include <minix/ds.h>
|
||||
#include <minix/endpoint.h>
|
||||
|
|
@ -149,7 +149,7 @@ static void or_getstat_s(message * mp);
|
|||
static void print_linkstatus(t_or * orp, u16_t status);
|
||||
static int or_get_recvd_packet(t_or *orp, u16_t rxfid, u8_t *databuf);
|
||||
static void or_reset(void);
|
||||
static void or_watchdog_f(timer_t *tp);
|
||||
static void or_watchdog_f(minix_timer_t *tp);
|
||||
static void setup_wepkey(t_or *orp, char *wepkey0);
|
||||
static void do_hard_int(void);
|
||||
static void check_int_events(void);
|
||||
|
|
@ -1092,7 +1092,7 @@ next:
|
|||
* Will be called regularly to see whether the driver has crashed. If that *
|
||||
* condition is detected, reset the driver and card *
|
||||
*****************************************************************************/
|
||||
static void or_watchdog_f(timer_t *tp)
|
||||
static void or_watchdog_f(minix_timer_t *tp)
|
||||
{
|
||||
t_or *orp;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ static struct pcidev
|
|||
u8_t pd_infclass;
|
||||
u16_t pd_vid;
|
||||
u16_t pd_did;
|
||||
u16_t pd_sub_vid;
|
||||
u16_t pd_sub_did;
|
||||
u8_t pd_ilr;
|
||||
|
||||
u8_t pd_inuse;
|
||||
|
|
@ -737,7 +739,7 @@ static void pci_intel_init()
|
|||
dstr= "unknown device";
|
||||
if (debug)
|
||||
{
|
||||
printf("pci_intel_init: %s (%04X/%04X)\n",
|
||||
printf("pci_intel_init: %s (%04X:%04X)\n",
|
||||
dstr, vid, did);
|
||||
}
|
||||
|
||||
|
|
@ -774,7 +776,7 @@ static void pci_intel_init()
|
|||
static void probe_bus(int busind)
|
||||
{
|
||||
u32_t dev, func, t3;
|
||||
u16_t vid, did, sts;
|
||||
u16_t vid, did, sts, sub_vid, sub_did;
|
||||
u8_t headt;
|
||||
u8_t baseclass, subclass, infclass;
|
||||
int devind, busnr;
|
||||
|
|
@ -831,12 +833,15 @@ static void probe_bus(int busind)
|
|||
}
|
||||
}
|
||||
|
||||
sub_vid= pci_attr_r16(devind, PCI_SUBVID);
|
||||
sub_did= pci_attr_r16(devind, PCI_SUBDID);
|
||||
|
||||
dstr= pci_dev_name(vid, did);
|
||||
if (debug)
|
||||
{
|
||||
if (dstr)
|
||||
{
|
||||
printf("%d.%lu.%lu: %s (%04X/%04X)\n",
|
||||
printf("%d.%lu.%lu: %s (%04X:%04X)\n",
|
||||
busnr, (unsigned long)dev,
|
||||
(unsigned long)func, dstr,
|
||||
vid, did);
|
||||
|
|
@ -851,8 +856,7 @@ static void probe_bus(int busind)
|
|||
}
|
||||
printf("Device index: %d\n", devind);
|
||||
printf("Subsystem: Vid 0x%x, did 0x%x\n",
|
||||
pci_attr_r16(devind, PCI_SUBVID),
|
||||
pci_attr_r16(devind, PCI_SUBDID));
|
||||
sub_vid, sub_did);
|
||||
}
|
||||
|
||||
baseclass= pci_attr_r8_u(devind, PCI_BCR);
|
||||
|
|
@ -886,6 +890,8 @@ static void probe_bus(int busind)
|
|||
pcidev[devind].pd_infclass= infclass;
|
||||
pcidev[devind].pd_vid= vid;
|
||||
pcidev[devind].pd_did= did;
|
||||
pcidev[devind].pd_sub_vid= sub_vid;
|
||||
pcidev[devind].pd_sub_did= sub_did;
|
||||
pcidev[devind].pd_inuse= 0;
|
||||
pcidev[devind].pd_bar_nr= 0;
|
||||
record_irq(devind);
|
||||
|
|
@ -1531,7 +1537,7 @@ static void complete_bars(void)
|
|||
if (debug)
|
||||
{
|
||||
printf(
|
||||
"pci device %d (%04x/%04x), bar %d: base 0x%x, size 0x%x\n",
|
||||
"pci device %d (%04x:%04x), bar %d: base 0x%x, size 0x%x\n",
|
||||
i, pcidev[i].pd_vid, pcidev[i].pd_did,
|
||||
j, base, size);
|
||||
}
|
||||
|
|
@ -1765,7 +1771,7 @@ int busind;
|
|||
dstr= "unknown device";
|
||||
if (debug)
|
||||
{
|
||||
printf("found ISA bridge (%04X/%04X) %s\n",
|
||||
printf("found ISA bridge (%04X:%04X) %s\n",
|
||||
vid, did, dstr);
|
||||
}
|
||||
pcibus[busind].pb_isabridge_dev= bridge_dev;
|
||||
|
|
@ -1803,7 +1809,7 @@ int busind;
|
|||
if (debug)
|
||||
{
|
||||
printf(
|
||||
"(warning) unsupported ISA bridge %04X/%04X for bus %d\n",
|
||||
"(warning) unsupported ISA bridge %04X:%04X for bus %d\n",
|
||||
pcidev[unknown_bridge].pd_vid,
|
||||
pcidev[unknown_bridge].pd_did, busind);
|
||||
}
|
||||
|
|
@ -1899,7 +1905,7 @@ int busind;
|
|||
t3 != PCI_T3_PCI2PCI_SUBTR)
|
||||
{
|
||||
printf(
|
||||
"Unknown PCI class %02x:%02x:%02x for PCI-to-PCI bridge, device %04X/%04X\n",
|
||||
"Unknown PCI class %02x/%02x/%02x for PCI-to-PCI bridge, device %04X:%04X\n",
|
||||
baseclass, subclass, infclass,
|
||||
vid, did);
|
||||
continue;
|
||||
|
|
@ -1908,7 +1914,7 @@ int busind;
|
|||
t3 != PCI_T3_CARDBUS)
|
||||
{
|
||||
printf(
|
||||
"Unknown PCI class %02x:%02x:%02x for Cardbus bridge, device %04X/%04X\n",
|
||||
"Unknown PCI class %02x/%02x/%02x for Cardbus bridge, device %04X:%04X\n",
|
||||
baseclass, subclass, infclass,
|
||||
vid, did);
|
||||
continue;
|
||||
|
|
@ -1917,7 +1923,7 @@ int busind;
|
|||
|
||||
if (debug)
|
||||
{
|
||||
printf("%u.%u.%u: PCI-to-PCI bridge: %04X/%04X\n",
|
||||
printf("%u.%u.%u: PCI-to-PCI bridge: %04X:%04X\n",
|
||||
pcidev[devind].pd_busnr,
|
||||
pcidev[devind].pd_dev,
|
||||
pcidev[devind].pd_func, vid, did);
|
||||
|
|
@ -2640,6 +2646,7 @@ static int visible(aclp, devind)
|
|||
struct rs_pci *aclp;
|
||||
int devind;
|
||||
{
|
||||
u16_t acl_sub_vid, acl_sub_did;
|
||||
int i;
|
||||
u32_t class_id;
|
||||
|
||||
|
|
@ -2651,8 +2658,14 @@ int devind;
|
|||
/* Check whether the caller is allowed to get this device. */
|
||||
for (i= 0; i<aclp->rsp_nr_device; i++)
|
||||
{
|
||||
acl_sub_vid = aclp->rsp_device[i].sub_vid;
|
||||
acl_sub_did = aclp->rsp_device[i].sub_did;
|
||||
if (aclp->rsp_device[i].vid == pcidev[devind].pd_vid &&
|
||||
aclp->rsp_device[i].did == pcidev[devind].pd_did)
|
||||
aclp->rsp_device[i].did == pcidev[devind].pd_did &&
|
||||
(acl_sub_vid == NO_SUB_VID ||
|
||||
acl_sub_vid == pcidev[devind].pd_sub_vid) &&
|
||||
(acl_sub_did == NO_SUB_DID ||
|
||||
acl_sub_did == pcidev[devind].pd_sub_did))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
12
drivers/pckbd/Makefile
Normal file
12
drivers/pckbd/Makefile
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Makefile for the PC keyboard/mouse driver (PCKBD)
|
||||
PROG= pckbd
|
||||
SRCS= pckbd.c table.c
|
||||
|
||||
DPADD+= ${LIBINPUTDRIVER} ${LIBSYS} ${LIBTIMERS}
|
||||
LDADD+= -linputdriver -lsys -ltimers
|
||||
|
||||
MAN=
|
||||
|
||||
BINDIR?= /sbin
|
||||
|
||||
.include <minix.service.mk>
|
||||
476
drivers/pckbd/pckbd.c
Normal file
476
drivers/pckbd/pckbd.c
Normal file
|
|
@ -0,0 +1,476 @@
|
|||
/* Keyboard driver for PCs and ATs. */
|
||||
#include <minix/drivers.h>
|
||||
#include <minix/input.h>
|
||||
#include <minix/inputdriver.h>
|
||||
|
||||
#include "pckbd.h"
|
||||
|
||||
/*
|
||||
* Data that is to be sent to the keyboard. Each byte is ACKed by the keyboard.
|
||||
* This is currently somewhat overpowered for its only purpose: setting LEDs.
|
||||
*/
|
||||
static struct kbdout {
|
||||
unsigned char buf[KBD_OUT_BUFSZ];
|
||||
int offset;
|
||||
int avail;
|
||||
int expect_ack;
|
||||
} kbdout;
|
||||
|
||||
static int kbd_watchdog_set = 0;
|
||||
static int kbd_alive = 1;
|
||||
static minix_timer_t tmr_kbd_wd;
|
||||
|
||||
static int irq_hook_id = -1;
|
||||
static int aux_irq_hook_id = -1;
|
||||
|
||||
static int kbd_state = 0;
|
||||
|
||||
static unsigned char aux_bytes[3];
|
||||
static unsigned char aux_state = 0;
|
||||
static int aux_counter = 0;
|
||||
|
||||
static void pckbd_leds(unsigned int);
|
||||
static void pckbd_intr(unsigned int);
|
||||
static void pckbd_alarm(clock_t);
|
||||
|
||||
static struct inputdriver pckbd_tab = {
|
||||
.idr_leds = pckbd_leds,
|
||||
.idr_intr = pckbd_intr,
|
||||
.idr_alarm = pckbd_alarm
|
||||
};
|
||||
|
||||
/*
|
||||
* The watchdog timer function, implementing all but the actual reset.
|
||||
*/
|
||||
static void
|
||||
kbd_watchdog(minix_timer_t *UNUSED(tmrp))
|
||||
{
|
||||
kbd_watchdog_set = 0;
|
||||
if (!kbdout.avail)
|
||||
return; /* Watchdog is no longer needed */
|
||||
|
||||
if (!kbd_alive)
|
||||
printf("PCKBD: watchdog should reset keyboard\n");
|
||||
kbd_alive = 0;
|
||||
|
||||
set_timer(&tmr_kbd_wd, sys_hz(), kbd_watchdog, 0);
|
||||
|
||||
kbd_watchdog_set = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send queued data to the keyboard.
|
||||
*/
|
||||
static void
|
||||
kbd_send(void)
|
||||
{
|
||||
u32_t sb;
|
||||
int r;
|
||||
|
||||
if (!kbdout.avail)
|
||||
return;
|
||||
if (kbdout.expect_ack)
|
||||
return;
|
||||
|
||||
if ((r = sys_inb(KB_STATUS, &sb)) != OK)
|
||||
printf("PCKBD: send sys_inb() failed (1): %d\n", r);
|
||||
|
||||
if (sb & (KB_OUT_FULL | KB_IN_FULL)) {
|
||||
printf("PCKBD: not sending (1): sb = 0x%x\n", sb);
|
||||
return;
|
||||
}
|
||||
micro_delay(KBC_IN_DELAY);
|
||||
if ((r = sys_inb(KB_STATUS, &sb)) != OK)
|
||||
printf("PCKBD: send sys_inb() failed (2): %d\n", r);
|
||||
if (sb & (KB_OUT_FULL | KB_IN_FULL)) {
|
||||
printf("PCKBD: not sending (2): sb = 0x%x\n", sb);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Okay, buffer is really empty */
|
||||
if ((r = sys_outb(KEYBD, kbdout.buf[kbdout.offset])) != OK)
|
||||
printf("PCKBD: send sys_outb() failed: %d\n", r);
|
||||
kbdout.offset++;
|
||||
kbdout.avail--;
|
||||
kbdout.expect_ack = 1;
|
||||
|
||||
kbd_alive = 1;
|
||||
if (kbd_watchdog_set) {
|
||||
/* Set a watchdog timer for one second. */
|
||||
set_timer(&tmr_kbd_wd, sys_hz(), kbd_watchdog, 0);
|
||||
|
||||
kbd_watchdog_set = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to obtain input from the keyboard.
|
||||
*/
|
||||
static int
|
||||
scan_keyboard(unsigned char *bp, int *isauxp)
|
||||
{
|
||||
u32_t b, sb;
|
||||
int r;
|
||||
|
||||
if ((r = sys_inb(KB_STATUS, &sb)) != OK) {
|
||||
printf("PCKBD: scan sys_inb() failed (1): %d\n", r);
|
||||
return FALSE;
|
||||
}
|
||||
if (!(sb & KB_OUT_FULL)) {
|
||||
if (kbdout.avail && !kbdout.expect_ack)
|
||||
kbd_send();
|
||||
return FALSE;
|
||||
}
|
||||
if ((r = sys_inb(KEYBD, &b)) != OK) {
|
||||
printf("PCKBD: scan sys_inb() failed (2): %d\n", r);
|
||||
return FALSE;
|
||||
}
|
||||
if (!(sb & KB_AUX_BYTE) && b == KB_ACK && kbdout.expect_ack) {
|
||||
kbdout.expect_ack = 0;
|
||||
micro_delay(KBC_IN_DELAY);
|
||||
kbd_send();
|
||||
return FALSE;
|
||||
}
|
||||
if (bp)
|
||||
*bp = b;
|
||||
if (isauxp)
|
||||
*isauxp = !!(sb & KB_AUX_BYTE);
|
||||
if (kbdout.avail && !kbdout.expect_ack) {
|
||||
micro_delay(KBC_IN_DELAY);
|
||||
kbd_send();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait until the controller is ready. Return TRUE on success, FALSE on
|
||||
* timeout. Since this may discard input, only use during initialization.
|
||||
*/
|
||||
static int
|
||||
kb_wait(void)
|
||||
{
|
||||
spin_t spin;
|
||||
u32_t status;
|
||||
int r, isaux;
|
||||
unsigned char byte;
|
||||
|
||||
SPIN_FOR(&spin, KBC_WAIT_TIME) {
|
||||
if ((r = sys_inb(KB_STATUS, &status)) != OK)
|
||||
printf("PCKBD: wait sys_inb() failed: %d\n", r);
|
||||
if (status & KB_OUT_FULL)
|
||||
(void) scan_keyboard(&byte, &isaux);
|
||||
if (!(status & (KB_IN_FULL | KB_OUT_FULL)))
|
||||
return TRUE; /* wait until ready */
|
||||
}
|
||||
|
||||
printf("PCKBD: wait timeout\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the LEDs on the caps, num, and scroll lock keys.
|
||||
*/
|
||||
static void
|
||||
set_leds(unsigned char ledmask)
|
||||
{
|
||||
if (kbdout.avail == 0)
|
||||
kbdout.offset = 0;
|
||||
if (kbdout.offset + kbdout.avail + 2 > KBD_OUT_BUFSZ) {
|
||||
/*
|
||||
* The output buffer is full. Ignore this command. Reset the
|
||||
* ACK flag.
|
||||
*/
|
||||
kbdout.expect_ack = 0;
|
||||
} else {
|
||||
kbdout.buf[kbdout.offset+kbdout.avail] = LED_CODE;
|
||||
kbdout.buf[kbdout.offset+kbdout.avail+1] = ledmask;
|
||||
kbdout.avail += 2;
|
||||
}
|
||||
if (!kbdout.expect_ack)
|
||||
kbd_send();
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a command to the keyboard.
|
||||
*/
|
||||
static void
|
||||
kbc_cmd0(int cmd)
|
||||
{
|
||||
int r;
|
||||
|
||||
kb_wait();
|
||||
if ((r = sys_outb(KB_COMMAND, cmd)) != OK)
|
||||
printf("PCKBD: cmd0 sys_outb() failed: %d\n", r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a command to the keyboard, including data.
|
||||
*/
|
||||
static void
|
||||
kbc_cmd1(int cmd, int data)
|
||||
{
|
||||
int r;
|
||||
|
||||
kb_wait();
|
||||
if ((r = sys_outb(KB_COMMAND, cmd)) != OK)
|
||||
printf("PCKBD: cmd1 sys_outb() failed (1): %d\n", r);
|
||||
kb_wait();
|
||||
if ((r = sys_outb(KEYBD, data)) != OK)
|
||||
printf("PCKBD: cmd1 sys_outb() failed (2): %d\n", r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait at most one second for a byte from the keyboard or the controller.
|
||||
*/
|
||||
static int
|
||||
kbc_read(void)
|
||||
{
|
||||
u32_t byte, status;
|
||||
spin_t spin;
|
||||
int r;
|
||||
|
||||
SPIN_FOR(&spin, KBC_READ_TIME) {
|
||||
if ((r = sys_inb(KB_STATUS, &status)) != OK)
|
||||
printf("PCKBD: read sys_inb() failed (1): %d\n", r);
|
||||
if (status & KB_OUT_FULL) {
|
||||
micro_delay(KBC_IN_DELAY);
|
||||
if ((r = sys_inb(KEYBD, &byte)) != OK)
|
||||
printf("PCKBD: read sys_inb() failed (2): "
|
||||
"%d\n", r);
|
||||
if (status & KB_AUX_BYTE)
|
||||
printf("PCKBD: read got aux 0x%x\n", byte);
|
||||
return byte;
|
||||
}
|
||||
}
|
||||
|
||||
panic("kbc_read failed to complete");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the keyboard hardware.
|
||||
*/
|
||||
static void
|
||||
kb_init(void)
|
||||
{
|
||||
int r, ccb;
|
||||
|
||||
/* Discard leftover keystroke. */
|
||||
scan_keyboard(NULL, NULL);
|
||||
|
||||
/* Set interrupt handler and enable keyboard IRQ. */
|
||||
irq_hook_id = KEYBOARD_IRQ; /* id to be returned on interrupt */
|
||||
r = sys_irqsetpolicy(KEYBOARD_IRQ, IRQ_REENABLE, &irq_hook_id);
|
||||
if (r != OK)
|
||||
panic("Couldn't set keyboard IRQ policy: %d", r);
|
||||
if ((r = sys_irqenable(&irq_hook_id)) != OK)
|
||||
panic("Couldn't enable keyboard IRQs: %d", r);
|
||||
|
||||
/* Set AUX interrupt handler and enable AUX IRQ. */
|
||||
aux_irq_hook_id = KBD_AUX_IRQ; /* id to be returned on interrupt */
|
||||
r = sys_irqsetpolicy(KBD_AUX_IRQ, IRQ_REENABLE, &aux_irq_hook_id);
|
||||
if (r != OK)
|
||||
panic("Couldn't set AUX IRQ policy: %d", r);
|
||||
if ((r = sys_irqenable(&aux_irq_hook_id)) != OK)
|
||||
panic("Couldn't enable AUX IRQs: %d", r);
|
||||
|
||||
/* Disable the keyboard and AUX. */
|
||||
kbc_cmd0(KBC_DI_KBD);
|
||||
kbc_cmd0(KBC_DI_AUX);
|
||||
|
||||
/* Get the current configuration byte. */
|
||||
kbc_cmd0(KBC_RD_RAM_CCB);
|
||||
ccb = kbc_read();
|
||||
|
||||
/* Enable both interrupts. */
|
||||
kbc_cmd1(KBC_WR_RAM_CCB, ccb | 3);
|
||||
|
||||
/* Re-enable the keyboard device. */
|
||||
kbc_cmd0(KBC_EN_KBD);
|
||||
|
||||
/* Enable the AUX device. */
|
||||
kbc_cmd0(KBC_EN_AUX);
|
||||
|
||||
/* Set the initial LED state. */
|
||||
kb_wait();
|
||||
|
||||
set_leds(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a keyboard scancode.
|
||||
*/
|
||||
static void
|
||||
kbd_process(unsigned char scode)
|
||||
{
|
||||
int press, index, page, code;
|
||||
|
||||
press = !(scode & SCAN_RELEASE) ? INPUT_PRESS : INPUT_RELEASE;
|
||||
index = scode & ~SCAN_RELEASE;
|
||||
|
||||
switch (kbd_state) {
|
||||
case 1:
|
||||
page = scanmap_escaped[index].page;
|
||||
code = scanmap_escaped[index].code;
|
||||
break;
|
||||
case 2:
|
||||
kbd_state = (index == SCAN_CTRL) ? 3 : 0;
|
||||
return;
|
||||
case 3:
|
||||
if (index == SCAN_NUMLOCK) {
|
||||
page = INPUT_PAGE_KEY;
|
||||
code = INPUT_KEY_PAUSE;
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
switch (scode) {
|
||||
case SCAN_EXT0:
|
||||
kbd_state = 1;
|
||||
return;
|
||||
case SCAN_EXT1:
|
||||
kbd_state = 2;
|
||||
return;
|
||||
}
|
||||
page = scanmap_normal[index].page;
|
||||
code = scanmap_normal[index].code;
|
||||
break;
|
||||
}
|
||||
|
||||
if (page)
|
||||
inputdriver_send_event(FALSE /*mouse*/, page, code, press, 0);
|
||||
|
||||
kbd_state = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process an auxiliary (mouse) scancode.
|
||||
*/
|
||||
static void
|
||||
kbdaux_process(unsigned char scode)
|
||||
{
|
||||
u32_t delta;
|
||||
int i;
|
||||
|
||||
if (aux_counter == 0 && !(scode & 0x08))
|
||||
return; /* resync */
|
||||
|
||||
aux_bytes[aux_counter++] = scode;
|
||||
|
||||
if (aux_counter < 3)
|
||||
return; /* need more first */
|
||||
|
||||
aux_counter = 0;
|
||||
|
||||
/* Send an event for each button state change. */
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((aux_state ^ aux_bytes[0]) & (1 << i)) {
|
||||
aux_state ^= (1 << i);
|
||||
|
||||
inputdriver_send_event(TRUE /*mouse*/,
|
||||
INPUT_PAGE_BUTTON, INPUT_BUTTON_1 + i,
|
||||
aux_state & (1 << i), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send an event for each relative mouse movement, X and/or Y. */
|
||||
for (i = 0; i < 2; i++) {
|
||||
delta = aux_bytes[1 + i];
|
||||
if (delta != 0) {
|
||||
if (aux_bytes[0] & (0x10 << i))
|
||||
delta |= 0xFFFFFF00; /* make signed */
|
||||
|
||||
inputdriver_send_event(TRUE /*mouse*/, INPUT_PAGE_GD,
|
||||
!i ? INPUT_GD_X : INPUT_GD_Y, delta,
|
||||
INPUT_FLAG_REL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set keyboard LEDs.
|
||||
*/
|
||||
static void
|
||||
pckbd_leds(unsigned int leds)
|
||||
{
|
||||
unsigned char b;
|
||||
|
||||
b = 0;
|
||||
if (leds & (1 << INPUT_LED_NUMLOCK)) b |= LED_NUM_LOCK;
|
||||
if (leds & (1 << INPUT_LED_CAPSLOCK)) b |= LED_CAPS_LOCK;
|
||||
if (leds & (1 << INPUT_LED_SCROLLLOCK)) b |= LED_SCROLL_LOCK;
|
||||
|
||||
set_leds(b);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a keyboard interrupt.
|
||||
*/
|
||||
static void
|
||||
pckbd_intr(unsigned int UNUSED(mask))
|
||||
{
|
||||
unsigned char scode;
|
||||
int isaux;
|
||||
|
||||
/* Fetch a character from the keyboard hardware and acknowledge it. */
|
||||
if (!scan_keyboard(&scode, &isaux))
|
||||
return;
|
||||
|
||||
if (!isaux) {
|
||||
/* A keyboard key press or release. */
|
||||
kbd_process(scode);
|
||||
} else {
|
||||
/* A mouse event. */
|
||||
kbdaux_process(scode);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a timer signal.
|
||||
*/
|
||||
static void
|
||||
pckbd_alarm(clock_t stamp)
|
||||
{
|
||||
expire_timers(stamp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the driver.
|
||||
*/
|
||||
static int
|
||||
pckbd_init(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
||||
{
|
||||
/* Initialize the watchdog timer. */
|
||||
init_timer(&tmr_kbd_wd);
|
||||
|
||||
/* Initialize the keyboard. */
|
||||
kb_init();
|
||||
|
||||
/* Announce the driver's presence. */
|
||||
inputdriver_announce(INPUT_DEV_KBD | INPUT_DEV_MOUSE);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set callback routines and let SEF initialize.
|
||||
*/
|
||||
static void
|
||||
pckbd_startup(void)
|
||||
{
|
||||
sef_setcb_init_fresh(pckbd_init);
|
||||
|
||||
sef_startup();
|
||||
}
|
||||
|
||||
/*
|
||||
* PC keyboard/mouse driver task.
|
||||
*/
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
pckbd_startup();
|
||||
|
||||
inputdriver_task(&pckbd_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
49
drivers/pckbd/pckbd.h
Normal file
49
drivers/pckbd/pckbd.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef _DRIVERS_PCKBD_H
|
||||
#define _DRIVERS_PCKBD_H
|
||||
|
||||
/* Standard and AT keyboard. (PS/2 MCA implies AT throughout.) */
|
||||
#define KEYBD 0x60 /* I/O port for keyboard data */
|
||||
|
||||
/* AT keyboard. */
|
||||
#define KB_COMMAND 0x64 /* I/O port for commands on AT */
|
||||
#define KB_STATUS 0x64 /* I/O port for status on AT */
|
||||
#define KB_ACK 0xFA /* keyboard ack response */
|
||||
#define KB_AUX_BYTE 0x20 /* Auxiliary Device Output Buffer Full */
|
||||
#define KB_OUT_FULL 0x01 /* status bit set when keypress char pending */
|
||||
#define KB_IN_FULL 0x02 /* status bit set when not ready to receive */
|
||||
#define KBC_RD_RAM_CCB 0x20 /* Read controller command byte */
|
||||
#define KBC_WR_RAM_CCB 0x60 /* Write controller command byte */
|
||||
#define KBC_DI_AUX 0xA7 /* Disable Auxiliary Device */
|
||||
#define KBC_EN_AUX 0xA8 /* Enable Auxiliary Device */
|
||||
#define KBC_DI_KBD 0xAD /* Disable Keybard Interface */
|
||||
#define KBC_EN_KBD 0xAE /* Enable Keybard Interface */
|
||||
#define LED_CODE 0xED /* command to keyboard to set LEDs */
|
||||
|
||||
#define KBC_WAIT_TIME 100000 /* wait this many usecs for a status update */
|
||||
#define KBC_READ_TIME 1000000 /* wait this many usecs for a result byte */
|
||||
|
||||
#define KBC_IN_DELAY 7 /* wait 7 microseconds when polling */
|
||||
|
||||
#define KBD_OUT_BUFSZ 16 /* Output buffer for data to the keyboard. */
|
||||
|
||||
#define KBD_SCAN_CODES 0x80
|
||||
|
||||
#define SCAN_RELEASE 0x80
|
||||
#define SCAN_CTRL 0x1D
|
||||
#define SCAN_NUMLOCK 0x45
|
||||
#define SCAN_EXT0 0xE0
|
||||
#define SCAN_EXT1 0xE1
|
||||
|
||||
#define LED_SCROLL_LOCK 0x01
|
||||
#define LED_NUM_LOCK 0x02
|
||||
#define LED_CAPS_LOCK 0x04
|
||||
|
||||
struct scanmap {
|
||||
unsigned short page;
|
||||
unsigned short code;
|
||||
};
|
||||
|
||||
extern const struct scanmap scanmap_normal[KBD_SCAN_CODES];
|
||||
extern const struct scanmap scanmap_escaped[KBD_SCAN_CODES];
|
||||
|
||||
#endif /* !_DRIVERS_PCKBD_H */
|
||||
169
drivers/pckbd/table.c
Normal file
169
drivers/pckbd/table.c
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/* Scancode conversion tables from PC keyboard scan codes to USB HID codes. */
|
||||
/*
|
||||
* The contents of this file are based on the Microsoft "USB HID to PS/2 Scan
|
||||
* Code Translation Table" document, of which the purpose is to provide a
|
||||
* translation the other way around. Therefore, some codes might be missing.
|
||||
*/
|
||||
#include <minix/input.h>
|
||||
|
||||
#include "pckbd.h"
|
||||
|
||||
const struct scanmap scanmap_normal[KBD_SCAN_CODES] = {
|
||||
[0x01] = { INPUT_PAGE_KEY, INPUT_KEY_ESCAPE },
|
||||
[0x02] = { INPUT_PAGE_KEY, INPUT_KEY_1 },
|
||||
[0x03] = { INPUT_PAGE_KEY, INPUT_KEY_2 },
|
||||
[0x04] = { INPUT_PAGE_KEY, INPUT_KEY_3 },
|
||||
[0x05] = { INPUT_PAGE_KEY, INPUT_KEY_4 },
|
||||
[0x06] = { INPUT_PAGE_KEY, INPUT_KEY_5 },
|
||||
[0x07] = { INPUT_PAGE_KEY, INPUT_KEY_6 },
|
||||
[0x08] = { INPUT_PAGE_KEY, INPUT_KEY_7 },
|
||||
[0x09] = { INPUT_PAGE_KEY, INPUT_KEY_8 },
|
||||
[0x0A] = { INPUT_PAGE_KEY, INPUT_KEY_9 },
|
||||
[0x0B] = { INPUT_PAGE_KEY, INPUT_KEY_0 },
|
||||
[0x0C] = { INPUT_PAGE_KEY, INPUT_KEY_DASH },
|
||||
[0x0D] = { INPUT_PAGE_KEY, INPUT_KEY_EQUAL },
|
||||
[0x0E] = { INPUT_PAGE_KEY, INPUT_KEY_BACKSPACE },
|
||||
[0x0F] = { INPUT_PAGE_KEY, INPUT_KEY_TAB },
|
||||
[0x10] = { INPUT_PAGE_KEY, INPUT_KEY_Q },
|
||||
[0x11] = { INPUT_PAGE_KEY, INPUT_KEY_W },
|
||||
[0x12] = { INPUT_PAGE_KEY, INPUT_KEY_E },
|
||||
[0x13] = { INPUT_PAGE_KEY, INPUT_KEY_R },
|
||||
[0x14] = { INPUT_PAGE_KEY, INPUT_KEY_T },
|
||||
[0x15] = { INPUT_PAGE_KEY, INPUT_KEY_Y },
|
||||
[0x16] = { INPUT_PAGE_KEY, INPUT_KEY_U },
|
||||
[0x17] = { INPUT_PAGE_KEY, INPUT_KEY_I },
|
||||
[0x18] = { INPUT_PAGE_KEY, INPUT_KEY_O },
|
||||
[0x19] = { INPUT_PAGE_KEY, INPUT_KEY_P },
|
||||
[0x1A] = { INPUT_PAGE_KEY, INPUT_KEY_OPEN_BRACKET },
|
||||
[0x1B] = { INPUT_PAGE_KEY, INPUT_KEY_CLOSE_BRACKET },
|
||||
[0x1C] = { INPUT_PAGE_KEY, INPUT_KEY_ENTER },
|
||||
[0x1D] = { INPUT_PAGE_KEY, INPUT_KEY_LEFT_CTRL },
|
||||
[0x1E] = { INPUT_PAGE_KEY, INPUT_KEY_A },
|
||||
[0x1F] = { INPUT_PAGE_KEY, INPUT_KEY_S },
|
||||
[0x20] = { INPUT_PAGE_KEY, INPUT_KEY_D },
|
||||
[0x21] = { INPUT_PAGE_KEY, INPUT_KEY_F },
|
||||
[0x22] = { INPUT_PAGE_KEY, INPUT_KEY_G },
|
||||
[0x23] = { INPUT_PAGE_KEY, INPUT_KEY_H },
|
||||
[0x24] = { INPUT_PAGE_KEY, INPUT_KEY_J },
|
||||
[0x25] = { INPUT_PAGE_KEY, INPUT_KEY_K },
|
||||
[0x26] = { INPUT_PAGE_KEY, INPUT_KEY_L },
|
||||
[0x27] = { INPUT_PAGE_KEY, INPUT_KEY_SEMICOLON },
|
||||
[0x28] = { INPUT_PAGE_KEY, INPUT_KEY_APOSTROPH },
|
||||
[0x29] = { INPUT_PAGE_KEY, INPUT_KEY_GRAVE_ACCENT },
|
||||
[0x2A] = { INPUT_PAGE_KEY, INPUT_KEY_LEFT_SHIFT },
|
||||
[0x2B] = { INPUT_PAGE_KEY, INPUT_KEY_BACKSLASH },
|
||||
[0x2C] = { INPUT_PAGE_KEY, INPUT_KEY_Z },
|
||||
[0x2D] = { INPUT_PAGE_KEY, INPUT_KEY_X },
|
||||
[0x2E] = { INPUT_PAGE_KEY, INPUT_KEY_C },
|
||||
[0x2F] = { INPUT_PAGE_KEY, INPUT_KEY_V },
|
||||
[0x30] = { INPUT_PAGE_KEY, INPUT_KEY_B },
|
||||
[0x31] = { INPUT_PAGE_KEY, INPUT_KEY_N },
|
||||
[0x32] = { INPUT_PAGE_KEY, INPUT_KEY_M },
|
||||
[0x33] = { INPUT_PAGE_KEY, INPUT_KEY_COMMA },
|
||||
[0x34] = { INPUT_PAGE_KEY, INPUT_KEY_PERIOD },
|
||||
[0x35] = { INPUT_PAGE_KEY, INPUT_KEY_SLASH },
|
||||
[0x36] = { INPUT_PAGE_KEY, INPUT_KEY_RIGHT_SHIFT },
|
||||
[0x37] = { INPUT_PAGE_KEY, INPUT_KEY_KP_STAR },
|
||||
[0x38] = { INPUT_PAGE_KEY, INPUT_KEY_LEFT_ALT },
|
||||
[0x39] = { INPUT_PAGE_KEY, INPUT_KEY_SPACEBAR },
|
||||
[0x3A] = { INPUT_PAGE_KEY, INPUT_KEY_CAPS_LOCK },
|
||||
[0x3B] = { INPUT_PAGE_KEY, INPUT_KEY_F1 },
|
||||
[0x3C] = { INPUT_PAGE_KEY, INPUT_KEY_F2 },
|
||||
[0x3D] = { INPUT_PAGE_KEY, INPUT_KEY_F3 },
|
||||
[0x3E] = { INPUT_PAGE_KEY, INPUT_KEY_F4 },
|
||||
[0x3F] = { INPUT_PAGE_KEY, INPUT_KEY_F5 },
|
||||
[0x40] = { INPUT_PAGE_KEY, INPUT_KEY_F6 },
|
||||
[0x41] = { INPUT_PAGE_KEY, INPUT_KEY_F7 },
|
||||
[0x42] = { INPUT_PAGE_KEY, INPUT_KEY_F8 },
|
||||
[0x43] = { INPUT_PAGE_KEY, INPUT_KEY_F9 },
|
||||
[0x44] = { INPUT_PAGE_KEY, INPUT_KEY_F10 },
|
||||
[0x45] = { INPUT_PAGE_KEY, INPUT_KEY_NUM_LOCK },
|
||||
[0x46] = { INPUT_PAGE_KEY, INPUT_KEY_SCROLL_LOCK },
|
||||
[0x47] = { INPUT_PAGE_KEY, INPUT_KEY_KP_7 },
|
||||
[0x48] = { INPUT_PAGE_KEY, INPUT_KEY_KP_8 },
|
||||
[0x49] = { INPUT_PAGE_KEY, INPUT_KEY_KP_9 },
|
||||
[0x4A] = { INPUT_PAGE_KEY, INPUT_KEY_KP_DASH },
|
||||
[0x4B] = { INPUT_PAGE_KEY, INPUT_KEY_KP_4 },
|
||||
[0x4C] = { INPUT_PAGE_KEY, INPUT_KEY_KP_5 },
|
||||
[0x4D] = { INPUT_PAGE_KEY, INPUT_KEY_KP_6 },
|
||||
[0x4E] = { INPUT_PAGE_KEY, INPUT_KEY_KP_PLUS },
|
||||
[0x4F] = { INPUT_PAGE_KEY, INPUT_KEY_KP_1 },
|
||||
[0x50] = { INPUT_PAGE_KEY, INPUT_KEY_KP_2 },
|
||||
[0x51] = { INPUT_PAGE_KEY, INPUT_KEY_KP_3 },
|
||||
[0x52] = { INPUT_PAGE_KEY, INPUT_KEY_KP_0 },
|
||||
[0x53] = { INPUT_PAGE_KEY, INPUT_KEY_KP_PERIOD },
|
||||
[0x54] = { INPUT_PAGE_KEY, INPUT_KEY_SYSREQ },
|
||||
[0x56] = { INPUT_PAGE_KEY, INPUT_KEY_EUROPE_2 },
|
||||
[0x57] = { INPUT_PAGE_KEY, INPUT_KEY_F11 },
|
||||
[0x58] = { INPUT_PAGE_KEY, INPUT_KEY_F12 },
|
||||
[0x59] = { INPUT_PAGE_KEY, INPUT_KEY_KP_EQUAL },
|
||||
[0x5C] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_6 },
|
||||
[0x64] = { INPUT_PAGE_KEY, INPUT_KEY_F13 },
|
||||
[0x65] = { INPUT_PAGE_KEY, INPUT_KEY_F14 },
|
||||
[0x66] = { INPUT_PAGE_KEY, INPUT_KEY_F15 },
|
||||
[0x67] = { INPUT_PAGE_KEY, INPUT_KEY_F16 },
|
||||
[0x68] = { INPUT_PAGE_KEY, INPUT_KEY_F17 },
|
||||
[0x69] = { INPUT_PAGE_KEY, INPUT_KEY_F18 },
|
||||
[0x6A] = { INPUT_PAGE_KEY, INPUT_KEY_F19 },
|
||||
[0x6B] = { INPUT_PAGE_KEY, INPUT_KEY_F20 },
|
||||
[0x6C] = { INPUT_PAGE_KEY, INPUT_KEY_F21 },
|
||||
[0x6D] = { INPUT_PAGE_KEY, INPUT_KEY_F22 },
|
||||
[0x6E] = { INPUT_PAGE_KEY, INPUT_KEY_F23 },
|
||||
[0x70] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_2 },
|
||||
/* The following two keys (0x71, 0x72) are release-only. */
|
||||
[0x71] = { INPUT_PAGE_KEY, INPUT_KEY_LANG_2 },
|
||||
[0x72] = { INPUT_PAGE_KEY, INPUT_KEY_LANG_1 },
|
||||
[0x73] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_1 },
|
||||
/* The following key (0x76) can be either F24 or LANG_5. */
|
||||
[0x76] = { INPUT_PAGE_KEY, INPUT_KEY_F24 },
|
||||
[0x77] = { INPUT_PAGE_KEY, INPUT_KEY_LANG_4 },
|
||||
[0x78] = { INPUT_PAGE_KEY, INPUT_KEY_LANG_3 },
|
||||
[0x79] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_4 },
|
||||
[0x7B] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_5 },
|
||||
[0x7D] = { INPUT_PAGE_KEY, INPUT_KEY_I10L_3 },
|
||||
[0x7E] = { INPUT_PAGE_KEY, INPUT_KEY_EQUAL_SIGN },
|
||||
};
|
||||
|
||||
const struct scanmap scanmap_escaped[KBD_SCAN_CODES] = {
|
||||
[0x10] = { INPUT_PAGE_CONS, INPUT_CONS_SCAN_PREVIOUS_TRACK },
|
||||
[0x19] = { INPUT_PAGE_CONS, INPUT_CONS_SCAN_NEXT_TRACK },
|
||||
[0x1C] = { INPUT_PAGE_KEY, INPUT_KEY_KP_ENTER },
|
||||
[0x1D] = { INPUT_PAGE_KEY, INPUT_KEY_RIGHT_CTRL },
|
||||
[0x20] = { INPUT_PAGE_CONS, INPUT_CONS_MUTE },
|
||||
[0x21] = { INPUT_PAGE_CONS, INPUT_CONS_AL_CALCULATOR },
|
||||
[0x22] = { INPUT_PAGE_CONS, INPUT_CONS_PLAY_PAUSE },
|
||||
[0x24] = { INPUT_PAGE_CONS, INPUT_CONS_STOP },
|
||||
[0x2E] = { INPUT_PAGE_CONS, INPUT_CONS_VOLUME_DOWN },
|
||||
[0x30] = { INPUT_PAGE_CONS, INPUT_CONS_VOLUME_UP },
|
||||
[0x32] = { INPUT_PAGE_CONS, INPUT_CONS_AC_HOME },
|
||||
[0x35] = { INPUT_PAGE_KEY, INPUT_KEY_KP_SLASH },
|
||||
[0x37] = { INPUT_PAGE_KEY, INPUT_KEY_PRINT_SCREEN },
|
||||
[0x38] = { INPUT_PAGE_KEY, INPUT_KEY_RIGHT_ALT },
|
||||
[0x46] = { INPUT_PAGE_KEY, INPUT_KEY_PAUSE },
|
||||
[0x47] = { INPUT_PAGE_KEY, INPUT_KEY_HOME },
|
||||
[0x48] = { INPUT_PAGE_KEY, INPUT_KEY_UP_ARROW },
|
||||
[0x49] = { INPUT_PAGE_KEY, INPUT_KEY_PAGE_UP },
|
||||
[0x4B] = { INPUT_PAGE_KEY, INPUT_KEY_LEFT_ARROW },
|
||||
[0x4D] = { INPUT_PAGE_KEY, INPUT_KEY_RIGHT_ARROW },
|
||||
[0x4F] = { INPUT_PAGE_KEY, INPUT_KEY_END },
|
||||
[0x50] = { INPUT_PAGE_KEY, INPUT_KEY_DOWN_ARROW },
|
||||
[0x51] = { INPUT_PAGE_KEY, INPUT_KEY_PAGE_DOWN },
|
||||
[0x52] = { INPUT_PAGE_KEY, INPUT_KEY_INSERT },
|
||||
[0x53] = { INPUT_PAGE_KEY, INPUT_KEY_DELETE },
|
||||
[0x5B] = { INPUT_PAGE_KEY, INPUT_KEY_LEFT_GUI },
|
||||
[0x5C] = { INPUT_PAGE_KEY, INPUT_KEY_RIGHT_GUI },
|
||||
[0x5D] = { INPUT_PAGE_KEY, INPUT_KEY_APPLICATION },
|
||||
/* The following extended key (0x5E) may also be INPUT_KEY_POWER. */
|
||||
[0x5E] = { INPUT_PAGE_GD, INPUT_GD_SYSTEM_POWER_DOWN },
|
||||
[0x5F] = { INPUT_PAGE_GD, INPUT_GD_SYSTEM_SLEEP },
|
||||
[0x63] = { INPUT_PAGE_GD, INPUT_GD_SYSTEM_WAKE_UP },
|
||||
[0x65] = { INPUT_PAGE_CONS, INPUT_CONS_AC_SEARCH },
|
||||
[0x66] = { INPUT_PAGE_CONS, INPUT_CONS_AC_BOOKMARKS },
|
||||
[0x67] = { INPUT_PAGE_CONS, INPUT_CONS_AC_REFRESH },
|
||||
[0x68] = { INPUT_PAGE_CONS, INPUT_CONS_AC_STOP },
|
||||
[0x69] = { INPUT_PAGE_CONS, INPUT_CONS_AC_FORWARD },
|
||||
[0x6A] = { INPUT_PAGE_CONS, INPUT_CONS_AC_BACK },
|
||||
[0x6B] = { INPUT_PAGE_CONS, INPUT_CONS_AL_LOCAL_BROWSER },
|
||||
[0x6C] = { INPUT_PAGE_CONS, INPUT_CONS_AL_EMAIL_READER },
|
||||
[0x6D] = { INPUT_PAGE_CONS, INPUT_CONS_AL_MEDIA_SELECT },
|
||||
};
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
/* State management variables. */
|
||||
EXTERN int writing;
|
||||
EXTERN int is_status_msg_expected;
|
||||
|
||||
/* Custom states definition. */
|
||||
#define PR_STATE_WRITE_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
|
||||
|
|
@ -24,7 +23,7 @@ int sef_cb_lu_prepare(int state)
|
|||
break;
|
||||
|
||||
case SEF_LU_STATE_PROTOCOL_FREE:
|
||||
is_ready = (!writing && !is_status_msg_expected);
|
||||
is_ready = (!writing);
|
||||
break;
|
||||
|
||||
/* Custom states. */
|
||||
|
|
@ -52,15 +51,13 @@ void sef_cb_lu_state_dump(int state)
|
|||
{
|
||||
sef_lu_dprint("printer: live update state = %d\n", state);
|
||||
sef_lu_dprint("printer: writing = %d\n", writing);
|
||||
sef_lu_dprint("printer: is_status_msg_expected = %d\n",
|
||||
is_status_msg_expected);
|
||||
|
||||
sef_lu_dprint("printer: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
|
||||
SEF_LU_STATE_WORK_FREE, TRUE);
|
||||
sef_lu_dprint("printer: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
|
||||
SEF_LU_STATE_REQUEST_FREE, TRUE);
|
||||
sef_lu_dprint("printer: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
|
||||
SEF_LU_STATE_PROTOCOL_FREE, (!writing && !is_status_msg_expected));
|
||||
SEF_LU_STATE_PROTOCOL_FREE, (!writing));
|
||||
sef_lu_dprint("printer: PR_STATE_WRITE_PROTOCOL_FREE(%d) reached = %d\n",
|
||||
PR_STATE_WRITE_PROTOCOL_FREE, (!writing));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,29 +5,6 @@
|
|||
* Changes:
|
||||
* May 07, 2004 fix: wait until printer is ready (Jorrit N. Herder)
|
||||
* May 06, 2004 printer driver moved to user-space (Jorrit N. Herder)
|
||||
*
|
||||
* The valid messages and their parameters are:
|
||||
*
|
||||
* DEV_OPEN: initializes the printer
|
||||
* DEV_CLOSE: does nothing
|
||||
* HARD_INT: interrupt handler has finished current chunk of output
|
||||
* DEV_WRITE: a process wants to write on a terminal
|
||||
* CANCEL: terminate a previous incomplete system call immediately
|
||||
*
|
||||
* m_type TTY_LINE USER_ENDPT COUNT ADDRESS
|
||||
* |-------------+---------+---------+---------+---------|
|
||||
* | DEV_OPEN | | | | |
|
||||
* |-------------+---------+---------+---------+---------|
|
||||
* | DEV_CLOSE | | proc nr | | |
|
||||
* -------------------------------------------------------
|
||||
* | HARD_INT | | | | |
|
||||
* |-------------+---------+---------+---------+---------|
|
||||
* | SYS_EVENT | | | | |
|
||||
* |-------------+---------+---------+---------+---------|
|
||||
* | DEV_WRITE |minor dev| proc nr | count | buf ptr |
|
||||
* |-------------+---------+---------+---------+---------|
|
||||
* | CANCEL |minor dev| proc nr | | |
|
||||
* -------------------------------------------------------
|
||||
*
|
||||
* Note: since only 1 printer is supported, minor dev is not used at present.
|
||||
*/
|
||||
|
|
@ -87,30 +64,29 @@
|
|||
*/
|
||||
|
||||
static endpoint_t caller; /* process to tell when printing done (FS) */
|
||||
static int revive_pending; /* set to true if revive is pending */
|
||||
static int revive_status; /* revive status */
|
||||
static int done_status; /* status of last output completion */
|
||||
static int oleft; /* bytes of output left in obuf */
|
||||
static unsigned char obuf[128]; /* output buffer */
|
||||
static unsigned const char *optr; /* ptr to next char in obuf to print */
|
||||
static int orig_count; /* original byte count */
|
||||
static int port_base; /* I/O port for printer */
|
||||
static endpoint_t proc_nr; /* user requesting the printing */
|
||||
static cp_grant_id_t grant_nr; /* grant on which print happens */
|
||||
static int user_left; /* bytes of output left in user buf */
|
||||
static vir_bytes user_vir_d; /* offset in user buf */
|
||||
int writing; /* nonzero while write is in progress */
|
||||
static cdev_id_t write_id; /* request ID of ongoing write */
|
||||
static int irq_hook_id; /* id of irq hook at kernel */
|
||||
|
||||
static void do_cancel(message *m_ptr);
|
||||
static void output_done(void);
|
||||
static void do_write(message *m_ptr);
|
||||
static void do_status(message *m_ptr);
|
||||
static void prepare_output(void);
|
||||
static int do_probe(void);
|
||||
static void do_initialize(void);
|
||||
static void reply(int code,int replyee,int proc,int status);
|
||||
static void do_printer_output(void);
|
||||
static int printer_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static ssize_t printer_write(devminor_t minor, u64_t position,
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int flags,
|
||||
cdev_id_t id);
|
||||
static int printer_cancel(devminor_t minor, endpoint_t endpt, cdev_id_t id);
|
||||
static void printer_intr(unsigned int mask);
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
|
@ -118,7 +94,14 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info);
|
|||
EXTERN int sef_cb_lu_prepare(int state);
|
||||
EXTERN int sef_cb_lu_state_isvalid(int state);
|
||||
EXTERN void sef_cb_lu_state_dump(int state);
|
||||
int is_status_msg_expected = FALSE;
|
||||
|
||||
/* Entry points to this driver. */
|
||||
static struct chardriver printer_tab = {
|
||||
.cdr_open = printer_open,
|
||||
.cdr_write = printer_write,
|
||||
.cdr_cancel = printer_cancel,
|
||||
.cdr_intr = printer_intr
|
||||
};
|
||||
|
||||
/*===========================================================================*
|
||||
* printer_task *
|
||||
|
|
@ -126,44 +109,11 @@ int is_status_msg_expected = FALSE;
|
|||
int main(void)
|
||||
{
|
||||
/* Main routine of the printer task. */
|
||||
message pr_mess; /* buffer for all incoming messages */
|
||||
int ipc_status;
|
||||
|
||||
/* SEF local startup. */
|
||||
sef_local_startup();
|
||||
|
||||
while (TRUE) {
|
||||
if(driver_receive(ANY, &pr_mess, &ipc_status) != OK) {
|
||||
panic("driver_receive failed");
|
||||
}
|
||||
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
switch (_ENDPOINT_P(pr_mess.m_source)) {
|
||||
case HARDWARE:
|
||||
do_printer_output();
|
||||
break;
|
||||
default:
|
||||
reply(TASK_REPLY, pr_mess.m_source,
|
||||
pr_mess.USER_ENDPT, EINVAL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(pr_mess.m_type) {
|
||||
case DEV_OPEN:
|
||||
do_initialize(); /* initialize */
|
||||
/* fall through */
|
||||
case DEV_CLOSE:
|
||||
reply(TASK_REPLY, pr_mess.m_source, pr_mess.USER_ENDPT, OK);
|
||||
break;
|
||||
case DEV_WRITE_S: do_write(&pr_mess); break;
|
||||
case DEV_STATUS: do_status(&pr_mess); break;
|
||||
case CANCEL: do_cancel(&pr_mess); break;
|
||||
default:
|
||||
reply(TASK_REPLY, pr_mess.m_source, pr_mess.USER_ENDPT,
|
||||
EINVAL);
|
||||
}
|
||||
}
|
||||
chardriver_task(&printer_tab);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -208,53 +158,49 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
/*===========================================================================*
|
||||
* do_write *
|
||||
*===========================================================================*/
|
||||
static void do_write(m_ptr)
|
||||
register message *m_ptr; /* pointer to the newly arrived message */
|
||||
static ssize_t printer_write(devminor_t UNUSED(minor), u64_t UNUSED(position),
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int flags,
|
||||
cdev_id_t id)
|
||||
{
|
||||
/* The printer is used by sending DEV_WRITE messages to it. Process one. */
|
||||
/* The printer is used by sending write requests to it. Process one. */
|
||||
int retries;
|
||||
u32_t status;
|
||||
|
||||
register int r = SUSPEND;
|
||||
int retries;
|
||||
u32_t status;
|
||||
/* Reject command if last write is not yet finished, the count is not
|
||||
* positive, or we're asked not to block.
|
||||
*/
|
||||
if (writing) return EIO;
|
||||
if (size <= 0) return EINVAL;
|
||||
if (flags & CDEV_NONBLOCK) return EAGAIN; /* not supported */
|
||||
|
||||
/* Reject command if last write is not yet finished, the count is not
|
||||
* positive, or the user address is bad.
|
||||
*/
|
||||
if (writing) r = EIO;
|
||||
else if (m_ptr->COUNT <= 0) r = EINVAL;
|
||||
/* If no errors occurred, continue printing with the caller.
|
||||
* First wait until the printer is online to prevent stupid errors.
|
||||
*/
|
||||
caller = endpt;
|
||||
user_left = size;
|
||||
orig_count = size;
|
||||
user_vir_d = 0; /* Offset. */
|
||||
writing = TRUE;
|
||||
grant_nr = grant;
|
||||
write_id = id;
|
||||
|
||||
/* Reply to FS, no matter what happened, possible SUSPEND caller. */
|
||||
reply(TASK_REPLY, m_ptr->m_source, m_ptr->USER_ENDPT, r);
|
||||
|
||||
/* If no errors occurred, continue printing with SUSPENDED caller.
|
||||
* First wait until the printer is online to prevent stupid errors.
|
||||
*/
|
||||
if (SUSPEND == r) {
|
||||
caller = m_ptr->m_source;
|
||||
proc_nr = m_ptr->USER_ENDPT;
|
||||
user_left = m_ptr->COUNT;
|
||||
orig_count = m_ptr->COUNT;
|
||||
user_vir_d = 0; /* Offset. */
|
||||
writing = TRUE;
|
||||
grant_nr = (cp_grant_id_t) m_ptr->IO_GRANT;
|
||||
|
||||
retries = MAX_ONLINE_RETRIES + 1;
|
||||
while (--retries > 0) {
|
||||
if(sys_inb(port_base + 1, &status) != OK) {
|
||||
retries = MAX_ONLINE_RETRIES + 1;
|
||||
while (--retries > 0) {
|
||||
if (sys_inb(port_base + 1, &status) != OK) {
|
||||
printf("printer: sys_inb of %x failed\n", port_base+1);
|
||||
panic("sys_inb failed");
|
||||
}
|
||||
if ((status & ON_LINE)) { /* printer online! */
|
||||
prepare_output();
|
||||
do_printer_output();
|
||||
return;
|
||||
}
|
||||
micro_delay(500000); /* wait before retry */
|
||||
}
|
||||
/* If we reach this point, the printer was not online in time. */
|
||||
done_status = status;
|
||||
output_done();
|
||||
}
|
||||
}
|
||||
if (status & ON_LINE) { /* printer online! */
|
||||
prepare_output();
|
||||
printer_intr(0);
|
||||
return EDONTREPLY; /* we may already have sent a reply */
|
||||
}
|
||||
micro_delay(500000); /* wait before retry */
|
||||
}
|
||||
/* If we reach this point, the printer was not online in time. */
|
||||
done_status = status;
|
||||
output_done();
|
||||
return EDONTREPLY;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -265,11 +211,11 @@ static void output_done()
|
|||
/* Previous chunk of printing is finished. Continue if OK and more.
|
||||
* Otherwise, reply to caller (FS).
|
||||
*/
|
||||
register int status;
|
||||
int status;
|
||||
|
||||
if (!writing) return; /* probably leftover interrupt */
|
||||
if (done_status != OK) { /* printer error occurred */
|
||||
status = EIO;
|
||||
if (!writing) return; /* probably leftover interrupt */
|
||||
if (done_status != OK) { /* printer error occurred */
|
||||
status = EIO;
|
||||
if ((done_status & ON_LINE) == 0) {
|
||||
printf("Printer is not on line\n");
|
||||
} else if ((done_status & NO_PAPER)) {
|
||||
|
|
@ -283,79 +229,36 @@ static void output_done()
|
|||
status = orig_count - user_left;
|
||||
}
|
||||
oleft = 0; /* cancel further output */
|
||||
}
|
||||
else if (user_left != 0) { /* not yet done, continue! */
|
||||
} else if (user_left != 0) { /* not yet done, continue! */
|
||||
prepare_output();
|
||||
return;
|
||||
}
|
||||
else { /* done! report back to FS */
|
||||
} else { /* done! report back to FS */
|
||||
status = orig_count;
|
||||
}
|
||||
is_status_msg_expected = TRUE;
|
||||
revive_pending = TRUE;
|
||||
revive_status = status;
|
||||
notify(caller);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_status *
|
||||
*===========================================================================*/
|
||||
static void do_status(m_ptr)
|
||||
register message *m_ptr; /* pointer to the newly arrived message */
|
||||
{
|
||||
if (revive_pending) {
|
||||
m_ptr->m_type = DEV_REVIVE; /* build message */
|
||||
m_ptr->REP_ENDPT = proc_nr;
|
||||
m_ptr->REP_STATUS = revive_status;
|
||||
m_ptr->REP_IO_GRANT = grant_nr;
|
||||
|
||||
writing = FALSE; /* unmark event */
|
||||
revive_pending = FALSE; /* unmark event */
|
||||
} else {
|
||||
m_ptr->m_type = DEV_NO_STATUS;
|
||||
|
||||
is_status_msg_expected = FALSE;
|
||||
}
|
||||
send(m_ptr->m_source, m_ptr); /* send the message */
|
||||
|
||||
chardriver_reply_task(caller, write_id, status);
|
||||
|
||||
writing = FALSE; /* unmark event */
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_cancel *
|
||||
* printer_cancel *
|
||||
*===========================================================================*/
|
||||
static void do_cancel(m_ptr)
|
||||
register message *m_ptr; /* pointer to the newly arrived message */
|
||||
static int printer_cancel(devminor_t UNUSED(minor), endpoint_t endpt,
|
||||
cdev_id_t id)
|
||||
{
|
||||
/* Cancel a print request that has already started. Usually this means that
|
||||
* the process doing the printing has been killed by a signal. It is not
|
||||
* clear if there are race conditions. Try not to cancel the wrong process,
|
||||
* but rely on FS to handle the EINTR reply and de-suspension properly.
|
||||
* but rely on VFS to handle the EINTR reply and de-suspension properly.
|
||||
*/
|
||||
|
||||
if (writing && m_ptr->USER_ENDPT == proc_nr) {
|
||||
if (writing && caller == endpt && write_id == id) {
|
||||
oleft = 0; /* cancel output by interrupt handler */
|
||||
writing = FALSE;
|
||||
revive_pending = FALSE;
|
||||
return EINTR;
|
||||
}
|
||||
reply(TASK_REPLY, m_ptr->m_source, m_ptr->USER_ENDPT, EINTR);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* reply *
|
||||
*===========================================================================*/
|
||||
static void reply(code, replyee, process, status)
|
||||
int code; /* TASK_REPLY or REVIVE */
|
||||
int replyee; /* destination for message (normally FS) */
|
||||
int process; /* which user requested the printing */
|
||||
int status; /* number of chars printed or error code */
|
||||
{
|
||||
/* Send a reply telling FS that printing has started or stopped. */
|
||||
|
||||
message pr_mess;
|
||||
|
||||
pr_mess.m_type = code; /* TASK_REPLY or REVIVE */
|
||||
pr_mess.REP_STATUS = status; /* count or EIO */
|
||||
pr_mess.REP_ENDPT = process; /* which user does this pertain to */
|
||||
send(replyee, &pr_mess); /* send the message */
|
||||
return EDONTREPLY;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -367,7 +270,7 @@ static int do_probe(void)
|
|||
|
||||
/* Get the base port for first printer. */
|
||||
if(sys_readbios(LPT1_IO_PORT_ADDR, &port_base, LPT1_IO_PORT_SIZE) != OK) {
|
||||
panic("do_initialize: sys_readbios failed");
|
||||
panic("do_probe: sys_readbios failed");
|
||||
}
|
||||
|
||||
/* If the port is zero, the parallel port is not available at all. */
|
||||
|
|
@ -380,10 +283,6 @@ static int do_probe(void)
|
|||
static void do_initialize()
|
||||
{
|
||||
/* Set global variables and initialize the printer. */
|
||||
static int initialized = FALSE;
|
||||
if (initialized) return;
|
||||
initialized = TRUE;
|
||||
|
||||
if(sys_outb(port_base + 2, INIT_PRINTER) != OK) {
|
||||
printf("printer: sys_outb of %x failed\n", port_base+2);
|
||||
panic("do_initialize: sys_outb init failed");
|
||||
|
|
@ -400,6 +299,24 @@ static void do_initialize()
|
|||
}
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* printer_open *
|
||||
*==========================================================================*/
|
||||
static int printer_open(devminor_t UNUSED(minor), int UNUSED(access),
|
||||
endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* Initialize on first open. */
|
||||
static int initialized = FALSE;
|
||||
|
||||
if (!initialized) {
|
||||
do_initialize();
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*==========================================================================*
|
||||
* prepare_output *
|
||||
*==========================================================================*/
|
||||
|
|
@ -424,9 +341,9 @@ static void prepare_output()
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_printer_output *
|
||||
* printer_intr *
|
||||
*===========================================================================*/
|
||||
static void do_printer_output()
|
||||
static void printer_intr(unsigned int UNUSED(mask))
|
||||
{
|
||||
/* This function does the actual output to the printer. This is called on an
|
||||
* interrupt message sent from the generic interrupt handler that 'forwards'
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ RAMDISK_DEFINES= \
|
|||
PROTO= proto
|
||||
|
||||
# Common to all architectures
|
||||
ETC= system.conf master.passwd
|
||||
ETC= system.conf master.passwd group
|
||||
EXTRA= rc
|
||||
PROTO_FILES= proto.common.etc proto.common.dynamic proto.dev
|
||||
PROTO_FILES= proto.common.etc proto.common.dynamic
|
||||
PROG_DRIVERS=
|
||||
PROG_COMMANDS= mount umount grep fsck.mfs sh service loadramdisk sysenv
|
||||
PROG_SERVERS= mfs procfs
|
||||
PROG_SERVERS= input mfs procfs
|
||||
PROG_BIN=
|
||||
PROG_SBIN=
|
||||
PROG_USR.BIN=
|
||||
|
|
@ -45,7 +45,7 @@ RAMDISK_SMALL= 1
|
|||
.if ${MACHINE_ARCH} == "i386"
|
||||
ETC+= rs.single
|
||||
EXTRA+=
|
||||
PROG_DRIVERS+= at_wini floppy pci
|
||||
PROG_DRIVERS+= at_wini floppy pci pckbd
|
||||
PROG_COMMANDS+= cdprobe
|
||||
PROG_USR.SBIN+= pwd_mkdb
|
||||
|
||||
|
|
@ -80,8 +80,8 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/servers
|
|||
|
||||
# LSC We have to take care of not erasing the source file, so never add EXTRA
|
||||
# to CLEANFILES
|
||||
CLEANFILES += ${PROGRAMS} ${SCRIPTS} ${ETC} image image.c t proto.gen
|
||||
CLEANFILES += ${LIBRARIES}
|
||||
CLEANFILES += ${PROGRAMS} ${SCRIPTS} ${ETC} image image.c t
|
||||
CLEANFILES += proto.gen proto.dev proto.dev.mtree
|
||||
CLEANFILES += ${PROG_LIBEXEC}
|
||||
CLEANFILES += ${.OBJDIR}/etc/*
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ CLEANFILES += ${.OBJDIR}/etc/*
|
|||
TOOL_PWD_MKDB?= ${NETBSDSRCDIR}/usr.sbin/pwd_mkdb/pwd_mkdb
|
||||
|
||||
# Remove "drivers/ramdisk" component from path
|
||||
PROGROOT:= ${.OBJDIR:S,drivers/ramdisk,,}
|
||||
PROGROOT:= ${.OBJDIR:S,/drivers/ramdisk,,}
|
||||
|
||||
# Generate dependencies rules for config files
|
||||
.for etc in ${ETC}
|
||||
|
|
@ -139,7 +139,7 @@ ${PROGROOT}/${srcdir}/${dir.${prog}:U${prog}}/${prog}:
|
|||
.endfor # prog
|
||||
.endfor # srcdir
|
||||
|
||||
image: proto.gen ${ETC} ${EXTRA} pwd.db spwd.db passwd
|
||||
realall image: proto.gen ${ETC} ${EXTRA} pwd.db spwd.db passwd group
|
||||
${_MKMSG_CREATE} "Generating ramdisk image"
|
||||
${TOOL_MKFSMFS} image proto.gen || { rm -f image; false; }
|
||||
# if fsck.mfs -s image | grep -q CLEAN; \
|
||||
|
|
@ -160,12 +160,30 @@ etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd
|
|||
pwd.db spwd.db passwd: etc/master.passwd
|
||||
${INSTALL} etc/${@F} ${@F}
|
||||
|
||||
proto.gen: ${PROTO} ${PROTO_FILES} ${PROGRAMS}
|
||||
proto.dev.mtree:
|
||||
@echo ". type=dir uname=root gname=operator mode=0755" \
|
||||
>${.TARGET}.tmp && \
|
||||
echo "./dev type=dir uname=root gname=operator mode=0755" \
|
||||
>>${.TARGET}.tmp && \
|
||||
${NETBSDSRCDIR}/commands/MAKEDEV/MAKEDEV.sh -m -r \
|
||||
>> ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
|
||||
|
||||
# We have to remove the two first entries of the generated proto file, as
|
||||
# well as the two last ones (closing $).
|
||||
# Do not forget to double $ so that make doesn't try to expand it.
|
||||
proto.dev: proto.dev.mtree pwd.db spwd.db master.passwd group
|
||||
test -x ${NETBSDSRCDIR}/usr.bin/toproto/toproto && (cd ${NETBSDSRCDIR}/usr.bin/toproto && make install) || :
|
||||
${TOOL_MTREE} -f ${.TARGET}.mtree -N ${.OBJDIR} -C -K device | \
|
||||
${TOOL_TOPROTO} | ${TOOL_SED} -e '1,4d' | \
|
||||
${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp && \
|
||||
mv ${.TARGET}.tmp ${.TARGET}
|
||||
|
||||
proto.gen: ${PROTO} ${PROTO_FILES} proto.dev ${PROGRAMS}
|
||||
${STRIP} ${PROGRAMS}
|
||||
# We are using the c preprocessor to generate proto.gen
|
||||
# used in the mkfs tool.
|
||||
${TOOL_CAT} ${PROTO} | ${CC} \
|
||||
${RAMDISK_DEFINES} \
|
||||
-E - | grep -v "^$$" | grep -v "#" >${.OBJDIR}/${.TARGET}
|
||||
-E - | grep -v "^$$" | grep -v "#" >${.TARGET}
|
||||
|
||||
.include <minix.service.mk>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ d--755 0 0
|
|||
ahci ---755 0 0 ahci
|
||||
virtio_blk ---755 0 0 virtio_blk
|
||||
at_wini ---755 0 0 at_wini
|
||||
pckbd ---755 0 0 pckbd
|
||||
#if RAMDISK_SMALL == 1
|
||||
ext2 ---755 0 0 ext2
|
||||
#endif
|
||||
|
|
@ -30,6 +31,7 @@ d--755 0 0
|
|||
#endif
|
||||
mfs ---755 0 0 mfs
|
||||
procfs ---755 0 0 procfs
|
||||
input ---755 0 0 input
|
||||
$
|
||||
usr d--755 0 0
|
||||
bin d--755 0 0
|
||||
|
|
|
|||
|
|
@ -1,455 +0,0 @@
|
|||
boot b--600 0 8 1 4
|
||||
c0d0 b--600 0 0 3 0
|
||||
c0d0p0 b--600 0 0 3 1
|
||||
c0d0p0s0 b--600 0 0 3 128
|
||||
c0d0p0s1 b--600 0 0 3 129
|
||||
c0d0p0s2 b--600 0 0 3 130
|
||||
c0d0p0s3 b--600 0 0 3 131
|
||||
c0d0p1 b--600 0 0 3 2
|
||||
c0d0p1s0 b--600 0 0 3 132
|
||||
c0d0p1s1 b--600 0 0 3 133
|
||||
c0d0p1s2 b--600 0 0 3 134
|
||||
c0d0p1s3 b--600 0 0 3 135
|
||||
c0d0p2 b--600 0 0 3 3
|
||||
c0d0p2s0 b--600 0 0 3 136
|
||||
c0d0p2s1 b--600 0 0 3 137
|
||||
c0d0p2s2 b--600 0 0 3 138
|
||||
c0d0p2s3 b--600 0 0 3 139
|
||||
c0d0p3 b--600 0 0 3 4
|
||||
c0d0p3s0 b--600 0 0 3 140
|
||||
c0d0p3s1 b--600 0 0 3 141
|
||||
c0d0p3s2 b--600 0 0 3 142
|
||||
c0d0p3s3 b--600 0 0 3 143
|
||||
c0d1 b--600 0 0 3 5
|
||||
c0d1p0 b--600 0 0 3 6
|
||||
c0d1p0s0 b--600 0 0 3 144
|
||||
c0d1p0s1 b--600 0 0 3 145
|
||||
c0d1p0s2 b--600 0 0 3 146
|
||||
c0d1p0s3 b--600 0 0 3 147
|
||||
c0d1p1 b--600 0 0 3 7
|
||||
c0d1p1s0 b--600 0 0 3 148
|
||||
c0d1p1s1 b--600 0 0 3 149
|
||||
c0d1p1s2 b--600 0 0 3 150
|
||||
c0d1p1s3 b--600 0 0 3 151
|
||||
c0d1p2 b--600 0 0 3 8
|
||||
c0d1p2s0 b--600 0 0 3 152
|
||||
c0d1p2s1 b--600 0 0 3 153
|
||||
c0d1p2s2 b--600 0 0 3 154
|
||||
c0d1p2s3 b--600 0 0 3 155
|
||||
c0d1p3 b--600 0 0 3 9
|
||||
c0d1p3s0 b--600 0 0 3 156
|
||||
c0d1p3s1 b--600 0 0 3 157
|
||||
c0d1p3s2 b--600 0 0 3 158
|
||||
c0d1p3s3 b--600 0 0 3 159
|
||||
c0d2 b--600 0 0 3 10
|
||||
c0d2p0 b--600 0 0 3 11
|
||||
c0d2p0s0 b--600 0 0 3 160
|
||||
c0d2p0s1 b--600 0 0 3 161
|
||||
c0d2p0s2 b--600 0 0 3 162
|
||||
c0d2p0s3 b--600 0 0 3 163
|
||||
c0d2p1 b--600 0 0 3 12
|
||||
c0d2p1s0 b--600 0 0 3 164
|
||||
c0d2p1s1 b--600 0 0 3 165
|
||||
c0d2p1s2 b--600 0 0 3 166
|
||||
c0d2p1s3 b--600 0 0 3 167
|
||||
c0d2p2 b--600 0 0 3 13
|
||||
c0d2p2s0 b--600 0 0 3 168
|
||||
c0d2p2s1 b--600 0 0 3 169
|
||||
c0d2p2s2 b--600 0 0 3 170
|
||||
c0d2p2s3 b--600 0 0 3 171
|
||||
c0d2p3 b--600 0 0 3 14
|
||||
c0d2p3s0 b--600 0 0 3 172
|
||||
c0d2p3s1 b--600 0 0 3 173
|
||||
c0d2p3s2 b--600 0 0 3 174
|
||||
c0d2p3s3 b--600 0 0 3 175
|
||||
c0d3 b--600 0 0 3 15
|
||||
c0d3p0 b--600 0 0 3 16
|
||||
c0d3p0s0 b--600 0 0 3 176
|
||||
c0d3p0s1 b--600 0 0 3 177
|
||||
c0d3p0s2 b--600 0 0 3 178
|
||||
c0d3p0s3 b--600 0 0 3 179
|
||||
c0d3p1 b--600 0 0 3 17
|
||||
c0d3p1s0 b--600 0 0 3 180
|
||||
c0d3p1s1 b--600 0 0 3 181
|
||||
c0d3p1s2 b--600 0 0 3 182
|
||||
c0d3p1s3 b--600 0 0 3 183
|
||||
c0d3p2 b--600 0 0 3 18
|
||||
c0d3p2s0 b--600 0 0 3 184
|
||||
c0d3p2s1 b--600 0 0 3 185
|
||||
c0d3p2s2 b--600 0 0 3 186
|
||||
c0d3p2s3 b--600 0 0 3 187
|
||||
c0d3p3 b--600 0 0 3 19
|
||||
c0d3p3s0 b--600 0 0 3 188
|
||||
c0d3p3s1 b--600 0 0 3 189
|
||||
c0d3p3s2 b--600 0 0 3 190
|
||||
c0d3p3s3 b--600 0 0 3 191
|
||||
c0d4 b--600 0 0 3 20
|
||||
c0d4p0 b--600 0 0 3 21
|
||||
c0d4p0s0 b--600 0 0 3 192
|
||||
c0d4p0s1 b--600 0 0 3 193
|
||||
c0d4p0s2 b--600 0 0 3 194
|
||||
c0d4p0s3 b--600 0 0 3 195
|
||||
c0d4p1 b--600 0 0 3 22
|
||||
c0d4p1s0 b--600 0 0 3 196
|
||||
c0d4p1s1 b--600 0 0 3 197
|
||||
c0d4p1s2 b--600 0 0 3 198
|
||||
c0d4p1s3 b--600 0 0 3 199
|
||||
c0d4p2 b--600 0 0 3 23
|
||||
c0d4p2s0 b--600 0 0 3 200
|
||||
c0d4p2s1 b--600 0 0 3 201
|
||||
c0d4p2s2 b--600 0 0 3 202
|
||||
c0d4p2s3 b--600 0 0 3 203
|
||||
c0d4p3 b--600 0 0 3 24
|
||||
c0d4p3s0 b--600 0 0 3 204
|
||||
c0d4p3s1 b--600 0 0 3 205
|
||||
c0d4p3s2 b--600 0 0 3 206
|
||||
c0d4p3s3 b--600 0 0 3 207
|
||||
c0d5 b--600 0 0 3 25
|
||||
c0d5p0 b--600 0 0 3 26
|
||||
c0d5p0s0 b--600 0 0 3 208
|
||||
c0d5p0s1 b--600 0 0 3 209
|
||||
c0d5p0s2 b--600 0 0 3 210
|
||||
c0d5p0s3 b--600 0 0 3 211
|
||||
c0d5p1 b--600 0 0 3 27
|
||||
c0d5p1s0 b--600 0 0 3 212
|
||||
c0d5p1s1 b--600 0 0 3 213
|
||||
c0d5p1s2 b--600 0 0 3 214
|
||||
c0d5p1s3 b--600 0 0 3 215
|
||||
c0d5p2 b--600 0 0 3 28
|
||||
c0d5p2s0 b--600 0 0 3 216
|
||||
c0d5p2s1 b--600 0 0 3 217
|
||||
c0d5p2s2 b--600 0 0 3 218
|
||||
c0d5p2s3 b--600 0 0 3 219
|
||||
c0d5p3 b--600 0 0 3 29
|
||||
c0d5p3s0 b--600 0 0 3 220
|
||||
c0d5p3s1 b--600 0 0 3 221
|
||||
c0d5p3s2 b--600 0 0 3 222
|
||||
c0d5p3s3 b--600 0 0 3 223
|
||||
c0d6 b--600 0 0 3 30
|
||||
c0d6p0 b--600 0 0 3 31
|
||||
c0d6p0s0 b--600 0 0 3 224
|
||||
c0d6p0s1 b--600 0 0 3 225
|
||||
c0d6p0s2 b--600 0 0 3 226
|
||||
c0d6p0s3 b--600 0 0 3 227
|
||||
c0d6p1 b--600 0 0 3 32
|
||||
c0d6p1s0 b--600 0 0 3 228
|
||||
c0d6p1s1 b--600 0 0 3 229
|
||||
c0d6p1s2 b--600 0 0 3 230
|
||||
c0d6p1s3 b--600 0 0 3 231
|
||||
c0d6p2 b--600 0 0 3 33
|
||||
c0d6p2s0 b--600 0 0 3 232
|
||||
c0d6p2s1 b--600 0 0 3 233
|
||||
c0d6p2s2 b--600 0 0 3 234
|
||||
c0d6p2s3 b--600 0 0 3 235
|
||||
c0d6p3 b--600 0 0 3 34
|
||||
c0d6p3s0 b--600 0 0 3 236
|
||||
c0d6p3s1 b--600 0 0 3 237
|
||||
c0d6p3s2 b--600 0 0 3 238
|
||||
c0d6p3s3 b--600 0 0 3 239
|
||||
c0d7 b--600 0 0 3 35
|
||||
c0d7p0 b--600 0 0 3 36
|
||||
c0d7p0s0 b--600 0 0 3 240
|
||||
c0d7p0s1 b--600 0 0 3 241
|
||||
c0d7p0s2 b--600 0 0 3 242
|
||||
c0d7p0s3 b--600 0 0 3 243
|
||||
c0d7p1 b--600 0 0 3 37
|
||||
c0d7p1s0 b--600 0 0 3 244
|
||||
c0d7p1s1 b--600 0 0 3 245
|
||||
c0d7p1s2 b--600 0 0 3 246
|
||||
c0d7p1s3 b--600 0 0 3 247
|
||||
c0d7p2 b--600 0 0 3 38
|
||||
c0d7p2s0 b--600 0 0 3 248
|
||||
c0d7p2s1 b--600 0 0 3 249
|
||||
c0d7p2s2 b--600 0 0 3 250
|
||||
c0d7p2s3 b--600 0 0 3 251
|
||||
c0d7p3 b--600 0 0 3 39
|
||||
c0d7p3s0 b--600 0 0 3 252
|
||||
c0d7p3s1 b--600 0 0 3 253
|
||||
c0d7p3s2 b--600 0 0 3 254
|
||||
c0d7p3s3 b--600 0 0 3 255
|
||||
c1d0 b--600 0 0 8 0
|
||||
c1d0p0 b--600 0 0 8 1
|
||||
c1d0p0s0 b--600 0 0 8 128
|
||||
c1d0p0s1 b--600 0 0 8 129
|
||||
c1d0p0s2 b--600 0 0 8 130
|
||||
c1d0p0s3 b--600 0 0 8 131
|
||||
c1d0p1 b--600 0 0 8 2
|
||||
c1d0p1s0 b--600 0 0 8 132
|
||||
c1d0p1s1 b--600 0 0 8 133
|
||||
c1d0p1s2 b--600 0 0 8 134
|
||||
c1d0p1s3 b--600 0 0 8 135
|
||||
c1d0p2 b--600 0 0 8 3
|
||||
c1d0p2s0 b--600 0 0 8 136
|
||||
c1d0p2s1 b--600 0 0 8 137
|
||||
c1d0p2s2 b--600 0 0 8 138
|
||||
c1d0p2s3 b--600 0 0 8 139
|
||||
c1d0p3 b--600 0 0 8 4
|
||||
c1d0p3s0 b--600 0 0 8 140
|
||||
c1d0p3s1 b--600 0 0 8 141
|
||||
c1d0p3s2 b--600 0 0 8 142
|
||||
c1d0p3s3 b--600 0 0 8 143
|
||||
c1d1 b--600 0 0 8 5
|
||||
c1d1p0 b--600 0 0 8 6
|
||||
c1d1p0s0 b--600 0 0 8 144
|
||||
c1d1p0s1 b--600 0 0 8 145
|
||||
c1d1p0s2 b--600 0 0 8 146
|
||||
c1d1p0s3 b--600 0 0 8 147
|
||||
c1d1p1 b--600 0 0 8 7
|
||||
c1d1p1s0 b--600 0 0 8 148
|
||||
c1d1p1s1 b--600 0 0 8 149
|
||||
c1d1p1s2 b--600 0 0 8 150
|
||||
c1d1p1s3 b--600 0 0 8 151
|
||||
c1d1p2 b--600 0 0 8 8
|
||||
c1d1p2s0 b--600 0 0 8 152
|
||||
c1d1p2s1 b--600 0 0 8 153
|
||||
c1d1p2s2 b--600 0 0 8 154
|
||||
c1d1p2s3 b--600 0 0 8 155
|
||||
c1d1p3 b--600 0 0 8 9
|
||||
c1d1p3s0 b--600 0 0 8 156
|
||||
c1d1p3s1 b--600 0 0 8 157
|
||||
c1d1p3s2 b--600 0 0 8 158
|
||||
c1d1p3s3 b--600 0 0 8 159
|
||||
c1d2 b--600 0 0 8 10
|
||||
c1d2p0 b--600 0 0 8 11
|
||||
c1d2p0s0 b--600 0 0 8 160
|
||||
c1d2p0s1 b--600 0 0 8 161
|
||||
c1d2p0s2 b--600 0 0 8 162
|
||||
c1d2p0s3 b--600 0 0 8 163
|
||||
c1d2p1 b--600 0 0 8 12
|
||||
c1d2p1s0 b--600 0 0 8 164
|
||||
c1d2p1s1 b--600 0 0 8 165
|
||||
c1d2p1s2 b--600 0 0 8 166
|
||||
c1d2p1s3 b--600 0 0 8 167
|
||||
c1d2p2 b--600 0 0 8 13
|
||||
c1d2p2s0 b--600 0 0 8 168
|
||||
c1d2p2s1 b--600 0 0 8 169
|
||||
c1d2p2s2 b--600 0 0 8 170
|
||||
c1d2p2s3 b--600 0 0 8 171
|
||||
c1d2p3 b--600 0 0 8 14
|
||||
c1d2p3s0 b--600 0 0 8 172
|
||||
c1d2p3s1 b--600 0 0 8 173
|
||||
c1d2p3s2 b--600 0 0 8 174
|
||||
c1d2p3s3 b--600 0 0 8 175
|
||||
c1d3 b--600 0 0 8 15
|
||||
c1d3p0 b--600 0 0 8 16
|
||||
c1d3p0s0 b--600 0 0 8 176
|
||||
c1d3p0s1 b--600 0 0 8 177
|
||||
c1d3p0s2 b--600 0 0 8 178
|
||||
c1d3p0s3 b--600 0 0 8 179
|
||||
c1d3p1 b--600 0 0 8 17
|
||||
c1d3p1s0 b--600 0 0 8 180
|
||||
c1d3p1s1 b--600 0 0 8 181
|
||||
c1d3p1s2 b--600 0 0 8 182
|
||||
c1d3p1s3 b--600 0 0 8 183
|
||||
c1d3p2 b--600 0 0 8 18
|
||||
c1d3p2s0 b--600 0 0 8 184
|
||||
c1d3p2s1 b--600 0 0 8 185
|
||||
c1d3p2s2 b--600 0 0 8 186
|
||||
c1d3p2s3 b--600 0 0 8 187
|
||||
c1d3p3 b--600 0 0 8 19
|
||||
c1d3p3s0 b--600 0 0 8 188
|
||||
c1d3p3s1 b--600 0 0 8 189
|
||||
c1d3p3s2 b--600 0 0 8 190
|
||||
c1d3p3s3 b--600 0 0 8 191
|
||||
c1d4 b--600 0 0 8 20
|
||||
c1d4p0 b--600 0 0 8 21
|
||||
c1d4p0s0 b--600 0 0 8 192
|
||||
c1d4p0s1 b--600 0 0 8 193
|
||||
c1d4p0s2 b--600 0 0 8 194
|
||||
c1d4p0s3 b--600 0 0 8 195
|
||||
c1d4p1 b--600 0 0 8 22
|
||||
c1d4p1s0 b--600 0 0 8 196
|
||||
c1d4p1s1 b--600 0 0 8 197
|
||||
c1d4p1s2 b--600 0 0 8 198
|
||||
c1d4p1s3 b--600 0 0 8 199
|
||||
c1d4p2 b--600 0 0 8 23
|
||||
c1d4p2s0 b--600 0 0 8 200
|
||||
c1d4p2s1 b--600 0 0 8 201
|
||||
c1d4p2s2 b--600 0 0 8 202
|
||||
c1d4p2s3 b--600 0 0 8 203
|
||||
c1d4p3 b--600 0 0 8 24
|
||||
c1d4p3s0 b--600 0 0 8 204
|
||||
c1d4p3s1 b--600 0 0 8 205
|
||||
c1d4p3s2 b--600 0 0 8 206
|
||||
c1d4p3s3 b--600 0 0 8 207
|
||||
c1d5 b--600 0 0 8 25
|
||||
c1d5p0 b--600 0 0 8 26
|
||||
c1d5p0s0 b--600 0 0 8 208
|
||||
c1d5p0s1 b--600 0 0 8 209
|
||||
c1d5p0s2 b--600 0 0 8 210
|
||||
c1d5p0s3 b--600 0 0 8 211
|
||||
c1d5p1 b--600 0 0 8 27
|
||||
c1d5p1s0 b--600 0 0 8 212
|
||||
c1d5p1s1 b--600 0 0 8 213
|
||||
c1d5p1s2 b--600 0 0 8 214
|
||||
c1d5p1s3 b--600 0 0 8 215
|
||||
c1d5p2 b--600 0 0 8 28
|
||||
c1d5p2s0 b--600 0 0 8 216
|
||||
c1d5p2s1 b--600 0 0 8 217
|
||||
c1d5p2s2 b--600 0 0 8 218
|
||||
c1d5p2s3 b--600 0 0 8 219
|
||||
c1d5p3 b--600 0 0 8 29
|
||||
c1d5p3s0 b--600 0 0 8 220
|
||||
c1d5p3s1 b--600 0 0 8 221
|
||||
c1d5p3s2 b--600 0 0 8 222
|
||||
c1d5p3s3 b--600 0 0 8 223
|
||||
c1d6 b--600 0 0 8 30
|
||||
c1d6p0 b--600 0 0 8 31
|
||||
c1d6p0s0 b--600 0 0 8 224
|
||||
c1d6p0s1 b--600 0 0 8 225
|
||||
c1d6p0s2 b--600 0 0 8 226
|
||||
c1d6p0s3 b--600 0 0 8 227
|
||||
c1d6p1 b--600 0 0 8 32
|
||||
c1d6p1s0 b--600 0 0 8 228
|
||||
c1d6p1s1 b--600 0 0 8 229
|
||||
c1d6p1s2 b--600 0 0 8 230
|
||||
c1d6p1s3 b--600 0 0 8 231
|
||||
c1d6p2 b--600 0 0 8 33
|
||||
c1d6p2s0 b--600 0 0 8 232
|
||||
c1d6p2s1 b--600 0 0 8 233
|
||||
c1d6p2s2 b--600 0 0 8 234
|
||||
c1d6p2s3 b--600 0 0 8 235
|
||||
c1d6p3 b--600 0 0 8 34
|
||||
c1d6p3s0 b--600 0 0 8 236
|
||||
c1d6p3s1 b--600 0 0 8 237
|
||||
c1d6p3s2 b--600 0 0 8 238
|
||||
c1d6p3s3 b--600 0 0 8 239
|
||||
c1d7 b--600 0 0 8 35
|
||||
c1d7p0 b--600 0 0 8 36
|
||||
c1d7p0s0 b--600 0 0 8 240
|
||||
c1d7p0s1 b--600 0 0 8 241
|
||||
c1d7p0s2 b--600 0 0 8 242
|
||||
c1d7p0s3 b--600 0 0 8 243
|
||||
c1d7p1 b--600 0 0 8 37
|
||||
c1d7p1s0 b--600 0 0 8 244
|
||||
c1d7p1s1 b--600 0 0 8 245
|
||||
c1d7p1s2 b--600 0 0 8 246
|
||||
c1d7p1s3 b--600 0 0 8 247
|
||||
c1d7p2 b--600 0 0 8 38
|
||||
c1d7p2s0 b--600 0 0 8 248
|
||||
c1d7p2s1 b--600 0 0 8 249
|
||||
c1d7p2s2 b--600 0 0 8 250
|
||||
c1d7p2s3 b--600 0 0 8 251
|
||||
c1d7p3 b--600 0 0 8 39
|
||||
c1d7p3s0 b--600 0 0 8 252
|
||||
c1d7p3s1 b--600 0 0 8 253
|
||||
c1d7p3s2 b--600 0 0 8 254
|
||||
c1d7p3s3 b--600 0 0 8 255
|
||||
console c--600 0 0 4 0
|
||||
eth c--600 0 0 7 1
|
||||
eth0 c--600 0 0 7 1
|
||||
fb0 c--644 0 0 19 0
|
||||
fbd b--600 0 0 14 0
|
||||
fd0 b--666 0 0 2 0
|
||||
fd0p0 b--666 0 0 2 112
|
||||
fd0p1 b--666 0 0 2 116
|
||||
fd0p2 b--666 0 0 2 120
|
||||
fd0p3 b--666 0 0 2 124
|
||||
fd1 b--666 0 0 2 1
|
||||
fd1p0 b--666 0 0 2 113
|
||||
fd1p1 b--666 0 0 2 117
|
||||
fd1p2 b--666 0 0 2 121
|
||||
fd1p3 b--666 0 0 2 125
|
||||
filter b--600 0 0 11 0
|
||||
hello c--644 0 0 17 0
|
||||
imgrd b--600 0 8 1 6
|
||||
ip c--600 0 0 7 2
|
||||
ip0 c--600 0 0 7 2
|
||||
kbd c--660 0 0 4 127
|
||||
kbdaux c--660 0 0 4 126
|
||||
klog c--600 0 0 15 0
|
||||
kmem c--640 0 8 1 2
|
||||
log c--222 0 0 4 15
|
||||
lp c--200 1 1 6 0
|
||||
mem c--640 0 8 1 1
|
||||
mouse s--777 0 0 /dev/kbdaux
|
||||
null c--666 0 8 1 3
|
||||
ptyp0 c--666 0 4 4 192
|
||||
ptyp1 c--666 0 4 4 193
|
||||
ptyp2 c--666 0 4 4 194
|
||||
ptyp3 c--666 0 4 4 195
|
||||
ptyp4 c--666 0 4 4 196
|
||||
ptyp5 c--666 0 4 4 197
|
||||
ptyp6 c--666 0 4 4 198
|
||||
ptyp7 c--666 0 4 4 199
|
||||
ptyp8 c--666 0 4 4 200
|
||||
ptyp9 c--666 0 4 4 201
|
||||
ptypa c--666 0 4 4 202
|
||||
ptypb c--666 0 4 4 203
|
||||
ptypc c--666 0 4 4 204
|
||||
ptypd c--666 0 4 4 205
|
||||
ptype c--666 0 4 4 206
|
||||
ptypf c--666 0 4 4 207
|
||||
ptyq0 c--666 0 4 4 208
|
||||
ptyq1 c--666 0 4 4 209
|
||||
ptyq2 c--666 0 4 4 210
|
||||
ptyq3 c--666 0 4 4 211
|
||||
ptyq4 c--666 0 4 4 212
|
||||
ptyq5 c--666 0 4 4 213
|
||||
ptyq6 c--666 0 4 4 214
|
||||
ptyq7 c--666 0 4 4 215
|
||||
ptyq8 c--666 0 4 4 216
|
||||
ptyq9 c--666 0 4 4 217
|
||||
ptyqa c--666 0 4 4 218
|
||||
ptyqb c--666 0 4 4 219
|
||||
ptyqc c--666 0 4 4 220
|
||||
ptyqd c--666 0 4 4 221
|
||||
ptyqe c--666 0 4 4 222
|
||||
ptyqf c--666 0 4 4 223
|
||||
ram b--600 0 8 1 0
|
||||
ram0 b--600 0 8 1 7
|
||||
ram1 b--600 0 8 1 8
|
||||
ram2 b--600 0 8 1 9
|
||||
ram3 b--600 0 8 1 10
|
||||
ram4 b--600 0 8 1 11
|
||||
ram5 b--600 0 8 1 12
|
||||
random c--644 0 0 16 0
|
||||
tcp c--666 0 0 7 3
|
||||
tcp0 c--666 0 0 7 3
|
||||
tty c--666 0 0 5 0
|
||||
tty00 c--666 0 4 4 16
|
||||
tty01 c--666 0 4 4 17
|
||||
tty02 c--666 0 4 4 18
|
||||
tty03 c--666 0 4 4 19
|
||||
ttyc1 c--600 0 0 4 1
|
||||
ttyc2 c--600 0 0 4 2
|
||||
ttyc3 c--600 0 0 4 3
|
||||
ttyp0 c--620 0 4 4 128
|
||||
ttyp1 c--666 0 4 4 129
|
||||
ttyp2 c--666 0 4 4 130
|
||||
ttyp3 c--666 0 4 4 131
|
||||
ttyp4 c--666 0 4 4 132
|
||||
ttyp5 c--666 0 4 4 133
|
||||
ttyp6 c--666 0 4 4 134
|
||||
ttyp7 c--666 0 4 4 135
|
||||
ttyp8 c--666 0 4 4 136
|
||||
ttyp9 c--666 0 4 4 137
|
||||
ttypa c--666 0 4 4 138
|
||||
ttypb c--666 0 4 4 139
|
||||
ttypc c--666 0 4 4 140
|
||||
ttypd c--666 0 4 4 141
|
||||
ttype c--666 0 4 4 142
|
||||
ttypf c--666 0 4 4 143
|
||||
ttyq0 c--666 0 4 4 144
|
||||
ttyq1 c--666 0 4 4 145
|
||||
ttyq2 c--666 0 4 4 146
|
||||
ttyq3 c--666 0 4 4 147
|
||||
ttyq4 c--666 0 4 4 148
|
||||
ttyq5 c--666 0 4 4 149
|
||||
ttyq6 c--666 0 4 4 150
|
||||
ttyq7 c--666 0 4 4 151
|
||||
ttyq8 c--666 0 4 4 152
|
||||
ttyq9 c--666 0 4 4 153
|
||||
ttyqa c--666 0 4 4 154
|
||||
ttyqb c--666 0 4 4 155
|
||||
ttyqc c--666 0 4 4 156
|
||||
ttyqd c--666 0 4 4 157
|
||||
ttyqe c--666 0 4 4 158
|
||||
ttyqf c--666 0 4 4 159
|
||||
udp c--666 0 0 7 4
|
||||
udp0 c--666 0 0 7 4
|
||||
uds c--666 0 0 18 0
|
||||
urandom c--644 0 0 16 0
|
||||
video c--600 0 0 4 125
|
||||
zero c--644 0 8 1 5
|
||||
ipstat c--666 0 0 7 0
|
||||
|
|
@ -15,6 +15,9 @@ then if [ -e $ACPI -a -n "`sysenv acpi`" ]
|
|||
fi
|
||||
/bin/service -c up /usr/sbin/pci
|
||||
|
||||
/bin/service -c up /sbin/input -dev /dev/kbdmux
|
||||
/bin/service -c up /sbin/pckbd
|
||||
|
||||
# Start procfs so we can access /proc/pci
|
||||
mount -t procfs none /proc >/dev/null
|
||||
|
||||
|
|
@ -37,7 +40,7 @@ then if [ -e $ACPI -a -n "`sysenv acpi`" ]
|
|||
/bin/service -c up /sbin/virtio_blk -dev /dev/c0d0 -label virtio_blk_0 -args instance=0
|
||||
else
|
||||
/bin/service -c up /sbin/at_wini -dev /dev/c0d0 -label at_wini_0
|
||||
/bin/service -cr up /sbin/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1
|
||||
/bin/service -cr up /sbin/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1 2>/dev/null || :
|
||||
fi
|
||||
/bin/umount /proc >/dev/null
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -21,25 +21,20 @@ static dev_t m_device; /* current device */
|
|||
extern int errno; /* error number for PM calls */
|
||||
|
||||
static struct device *r_prepare(dev_t device);
|
||||
static int r_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
|
||||
flags);
|
||||
static int r_do_open(message *m_ptr);
|
||||
static void r_random(message *m_ptr);
|
||||
static ssize_t r_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static ssize_t r_write(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static int r_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static void r_random(clock_t stamp);
|
||||
static void r_updatebin(int source, struct k_randomness_bin *rb);
|
||||
|
||||
/* Entry points to this driver. */
|
||||
static struct chardriver r_dtab = {
|
||||
r_do_open, /* open or mount */
|
||||
do_nop, /* nothing on a close */
|
||||
nop_ioctl, /* no I/O controls supported */
|
||||
r_prepare, /* prepare for I/O on a given minor device */
|
||||
r_transfer, /* do the I/O */
|
||||
nop_cleanup, /* no need to clean up */
|
||||
r_random, /* get randomness from kernel (alarm) */
|
||||
nop_cancel, /* cancel not supported */
|
||||
nop_select, /* select not supported */
|
||||
NULL, /* other messages not supported */
|
||||
.cdr_open = r_open, /* open device */
|
||||
.cdr_read = r_read, /* read from device */
|
||||
.cdr_write = r_write, /* write to device (seeding it) */
|
||||
.cdr_alarm = r_random /* get randomness from kernel (alarm) */
|
||||
};
|
||||
|
||||
/* Buffer for the /dev/random number generator. */
|
||||
|
|
@ -59,7 +54,7 @@ int main(void)
|
|||
sef_local_startup();
|
||||
|
||||
/* Call the generic receive loop. */
|
||||
chardriver_task(&r_dtab, CHARDRIVER_ASYNC);
|
||||
chardriver_task(&r_dtab);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -92,7 +87,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
int i, s;
|
||||
|
||||
random_init();
|
||||
r_random(NULL); /* also set periodic timer */
|
||||
r_random(0); /* also set periodic timer */
|
||||
|
||||
/* Retrieve first randomness buffer with parameters. */
|
||||
if (OK != (s=sys_getrandomness(&krandom))) {
|
||||
|
|
@ -120,103 +115,71 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* r_prepare *
|
||||
* r_read *
|
||||
*===========================================================================*/
|
||||
static struct device *r_prepare(dev_t device)
|
||||
static ssize_t r_read(devminor_t minor, u64_t UNUSED(position),
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Prepare for I/O on a device: check if the minor device number is ok. */
|
||||
|
||||
if (device >= NR_DEVS) return(NULL);
|
||||
m_device = device;
|
||||
|
||||
return(&m_geom[device]);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* r_transfer *
|
||||
*===========================================================================*/
|
||||
static int r_transfer(
|
||||
endpoint_t endpt, /* endpoint of grant owner */
|
||||
int opcode, /* DEV_GATHER or DEV_SCATTER */
|
||||
u64_t position, /* offset on device to read or write */
|
||||
iovec_t *iov, /* pointer to read or write request vector */
|
||||
unsigned int nr_req, /* length of request vector */
|
||||
endpoint_t UNUSED(user_endpt),/* endpoint of user process */
|
||||
unsigned int UNUSED(flags)
|
||||
)
|
||||
{
|
||||
/* Read or write one the driver's minor devices. */
|
||||
unsigned count, left, chunk;
|
||||
cp_grant_id_t grant;
|
||||
struct device *dv;
|
||||
/* Read from one of the driver's minor devices. */
|
||||
size_t offset, chunk;
|
||||
int r;
|
||||
size_t vir_offset = 0;
|
||||
|
||||
/* Get minor device number and check for /dev/null. */
|
||||
dv = &m_geom[m_device];
|
||||
if (minor != RANDOM_DEV) return(EIO);
|
||||
|
||||
while (nr_req > 0) {
|
||||
if (!random_isseeded()) return(EAGAIN);
|
||||
|
||||
/* How much to transfer and where to / from. */
|
||||
count = iov->iov_size;
|
||||
grant = (cp_grant_id_t) iov->iov_addr;
|
||||
|
||||
switch (m_device) {
|
||||
|
||||
/* Random number generator. Character instead of block device. */
|
||||
case RANDOM_DEV:
|
||||
if (opcode == DEV_GATHER_S && !random_isseeded())
|
||||
return(EAGAIN);
|
||||
left = count;
|
||||
while (left > 0) {
|
||||
chunk = (left > RANDOM_BUF_SIZE) ? RANDOM_BUF_SIZE : left;
|
||||
if (opcode == DEV_GATHER_S) {
|
||||
random_getbytes(random_buf, chunk);
|
||||
r= sys_safecopyto(endpt, grant, vir_offset,
|
||||
(vir_bytes) random_buf, chunk);
|
||||
if (r != OK)
|
||||
{
|
||||
printf("random: sys_safecopyto failed for proc %d, "
|
||||
"grant %d\n", endpt, grant);
|
||||
return r;
|
||||
}
|
||||
} else if (opcode == DEV_SCATTER_S) {
|
||||
r= sys_safecopyfrom(endpt, grant, vir_offset,
|
||||
(vir_bytes) random_buf, chunk);
|
||||
if (r != OK)
|
||||
{
|
||||
printf("random: sys_safecopyfrom failed for proc %d, "
|
||||
"grant %d\n", endpt, grant);
|
||||
return r;
|
||||
}
|
||||
random_putbytes(random_buf, chunk);
|
||||
}
|
||||
vir_offset += chunk;
|
||||
left -= chunk;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Unknown (illegal) minor device. */
|
||||
default:
|
||||
return(EINVAL);
|
||||
for (offset = 0; offset < size; offset += chunk) {
|
||||
chunk = MIN(size - offset, RANDOM_BUF_SIZE);
|
||||
random_getbytes(random_buf, chunk);
|
||||
r = sys_safecopyto(endpt, grant, offset, (vir_bytes)random_buf, chunk);
|
||||
if (r != OK) {
|
||||
printf("random: sys_safecopyto failed for proc %d, grant %d\n",
|
||||
endpt, grant);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Book the number of bytes transferred. */
|
||||
position= add64u(position, count);
|
||||
if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; }
|
||||
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* r_do_open *
|
||||
* r_write *
|
||||
*===========================================================================*/
|
||||
static int r_do_open(message *m_ptr)
|
||||
static ssize_t r_write(devminor_t minor, u64_t UNUSED(position),
|
||||
endpoint_t endpt, cp_grant_id_t grant, size_t size, int UNUSED(flags),
|
||||
cdev_id_t UNUSED(id))
|
||||
{
|
||||
/* Write to one of the driver's minor devices. */
|
||||
size_t offset, chunk;
|
||||
int r;
|
||||
|
||||
if (minor != RANDOM_DEV) return(EIO);
|
||||
|
||||
for (offset = 0; offset < size; offset += chunk) {
|
||||
chunk = MIN(size - offset, RANDOM_BUF_SIZE);
|
||||
r = sys_safecopyfrom(endpt, grant, offset, (vir_bytes)random_buf,
|
||||
chunk);
|
||||
if (r != OK) {
|
||||
printf("random: sys_safecopyfrom failed for proc %d,"
|
||||
" grant %d\n", endpt, grant);
|
||||
return r;
|
||||
}
|
||||
random_putbytes(random_buf, chunk);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* r_open *
|
||||
*===========================================================================*/
|
||||
static int r_open(devminor_t minor, int access, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* Check device number on open.
|
||||
*/
|
||||
if (r_prepare(m_ptr->DEVICE) == NULL) return(ENXIO);
|
||||
|
||||
if (minor < 0 || minor >= NR_DEVS) return(ENXIO);
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -265,7 +228,7 @@ static void r_updatebin(int source, struct k_randomness_bin *rb)
|
|||
/*===========================================================================*
|
||||
* r_random *
|
||||
*===========================================================================*/
|
||||
static void r_random(message *UNUSED(m_ptr))
|
||||
static void r_random(clock_t UNUSED(stamp))
|
||||
{
|
||||
/* Fetch random information from the kernel to update /dev/random. */
|
||||
int s;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <lib.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/callnr.h>
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static void rtl8139_dump(message *m);
|
|||
static void dump_phy(re_t *rep);
|
||||
#endif
|
||||
static int rl_handler(re_t *rep);
|
||||
static void rl_watchdog_f(timer_t *tp);
|
||||
static void rl_watchdog_f(minix_timer_t *tp);
|
||||
static void tell_dev(vir_bytes start, size_t size, int pci_bus, int
|
||||
pci_dev, int pci_func);
|
||||
|
||||
|
|
@ -1969,7 +1969,7 @@ static int rl_handler(re_t *rep)
|
|||
* rl_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void rl_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
re_t *rep;
|
||||
/* Use a synchronous alarm instead of a watchdog timer. */
|
||||
|
|
|
|||
|
|
@ -7,23 +7,23 @@ service rtl8139
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 10ec/8139;
|
||||
pci device 02ac/1012;
|
||||
pci device 1065/8139;
|
||||
pci device 1113/1211;
|
||||
pci device 1186/1300;
|
||||
pci device 1186/1340;
|
||||
pci device 11db/1234;
|
||||
pci device 1259/a117;
|
||||
pci device 1259/a11e;
|
||||
pci device 126c/1211;
|
||||
pci device 13d1/ab06;
|
||||
pci device 1432/9130;
|
||||
pci device 14ea/ab06;
|
||||
pci device 14ea/ab07;
|
||||
pci device 1500/1360;
|
||||
pci device 1743/8139;
|
||||
pci device 4033/1360;
|
||||
pci device 10ec:8139;
|
||||
pci device 02ac:1012;
|
||||
pci device 1065:8139;
|
||||
pci device 1113:1211;
|
||||
pci device 1186:1300;
|
||||
pci device 1186:1340;
|
||||
pci device 11db:1234;
|
||||
pci device 1259:a117;
|
||||
pci device 1259:a11e;
|
||||
pci device 126c:1211;
|
||||
pci device 13d1:ab06;
|
||||
pci device 1432:9130;
|
||||
pci device 14ea:ab06;
|
||||
pci device 14ea:ab07;
|
||||
pci device 1500:1360;
|
||||
pci device 1743:8139;
|
||||
pci device 4033:1360;
|
||||
ipc
|
||||
SYSTEM pm rs log tty ds vm
|
||||
pci inet lwip amddev
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Created: Aug 2003 by Philip Homburg <philip@cs.vu.nl>
|
|||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <net/hton.h>
|
||||
#include <net/gen/ether.h>
|
||||
#include <net/gen/eth_io.h>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <minix/type.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <timers.h>
|
||||
#include <minix/timers.h>
|
||||
#include <net/hton.h>
|
||||
#include <net/gen/ether.h>
|
||||
#include <net/gen/eth_io.h>
|
||||
|
|
@ -223,7 +223,7 @@ static void check_int_events(void);
|
|||
static void do_hard_int(void);
|
||||
static void dump_phy(const re_t *rep);
|
||||
static void rl_handler(re_t *rep);
|
||||
static void rl_watchdog_f(timer_t *tp);
|
||||
static void rl_watchdog_f(minix_timer_t *tp);
|
||||
|
||||
/*
|
||||
* The message used in the main loop is made global, so that rl_watchdog_f()
|
||||
|
|
@ -1888,7 +1888,7 @@ static void rl_handler(re_t *rep)
|
|||
* rl_watchdog_f *
|
||||
*===========================================================================*/
|
||||
static void rl_watchdog_f(tp)
|
||||
timer_t *tp;
|
||||
minix_timer_t *tp;
|
||||
{
|
||||
re_t *rep;
|
||||
/* Use a synchronous alarm instead of a watchdog timer. */
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ service rtl8169
|
|||
IRQCTL # 19
|
||||
DEVIO # 21
|
||||
;
|
||||
pci device 10ec/8129;
|
||||
pci device 10ec/8136;
|
||||
pci device 10ec/8167;
|
||||
pci device 10ec/8169;
|
||||
pci device 10ec/8168;
|
||||
pci device 1186/4300;
|
||||
pci device 1259/c107;
|
||||
pci device 1385/8169;
|
||||
pci device 16ec/0116;
|
||||
pci device 1737/1032;
|
||||
pci device 10ec:8129;
|
||||
pci device 10ec:8136;
|
||||
pci device 10ec:8167;
|
||||
pci device 10ec:8169;
|
||||
pci device 10ec:8168;
|
||||
pci device 1186:4300;
|
||||
pci device 1259:c107;
|
||||
pci device 1385:8169;
|
||||
pci device 16ec:0116;
|
||||
pci device 1737:1032;
|
||||
ipc
|
||||
SYSTEM pm rs log tty ds vm
|
||||
pci inet lwip amddev
|
||||
|
|
|
|||
|
|
@ -114,11 +114,9 @@ static uint8_t crc8(uint8_t crc, uint8_t byte);
|
|||
static int checksum(uint8_t * bytes, int nbytes, uint8_t expected_crc);
|
||||
|
||||
/* libchardriver callbacks */
|
||||
static struct device *sht21_prepare(dev_t UNUSED(dev));
|
||||
static int sht21_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags));
|
||||
static int sht21_other(message * m);
|
||||
static ssize_t sht21_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static void sht21_other(message * m, int ipc_status);
|
||||
|
||||
/* SEF functions */
|
||||
static int sef_cb_lu_state_save(int);
|
||||
|
|
@ -128,21 +126,8 @@ static void sef_local_startup(void);
|
|||
|
||||
/* Entry points to this driver from libchardriver. */
|
||||
static struct chardriver sht21_tab = {
|
||||
.cdr_open = do_nop,
|
||||
.cdr_close = do_nop,
|
||||
.cdr_ioctl = nop_ioctl,
|
||||
.cdr_prepare = sht21_prepare,
|
||||
.cdr_transfer = sht21_transfer,
|
||||
.cdr_cleanup = nop_cleanup,
|
||||
.cdr_alarm = nop_alarm,
|
||||
.cdr_cancel = nop_cancel,
|
||||
.cdr_select = nop_select,
|
||||
.cdr_other = sht21_other
|
||||
};
|
||||
|
||||
static struct device sht21_device = {
|
||||
.dv_base = 0,
|
||||
.dv_size = 0
|
||||
.cdr_read = sht21_read,
|
||||
.cdr_other = sht21_other
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -342,17 +327,11 @@ checksum(uint8_t * bytes, int nbytes, uint8_t expected_crc)
|
|||
}
|
||||
}
|
||||
|
||||
static struct device *
|
||||
sht21_prepare(dev_t UNUSED(dev))
|
||||
{
|
||||
return &sht21_device;
|
||||
}
|
||||
|
||||
static int
|
||||
sht21_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags))
|
||||
static ssize_t
|
||||
sht21_read(devminor_t UNUSED(minor), u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int UNUSED(flags), cdev_id_t UNUSED(id))
|
||||
{
|
||||
u64_t dev_size;
|
||||
int bytes, r;
|
||||
|
||||
r = measure();
|
||||
|
|
@ -367,48 +346,33 @@ sht21_transfer(endpoint_t endpt, int opcode, u64_t position,
|
|||
|
||||
log_trace(&log, "%s", buffer);
|
||||
|
||||
bytes = strlen(buffer) - position < iov->iov_size ?
|
||||
strlen(buffer) - position : iov->iov_size;
|
||||
dev_size = (u64_t)strlen(buffer);
|
||||
if (position >= dev_size) return 0;
|
||||
if (position + size > dev_size)
|
||||
size = (size_t)(dev_size - position);
|
||||
|
||||
if (bytes <= 0) {
|
||||
return OK;
|
||||
}
|
||||
r = sys_safecopyto(endpt, grant, 0,
|
||||
(vir_bytes)(buffer + (size_t)position), size);
|
||||
|
||||
switch (opcode) {
|
||||
case DEV_GATHER_S:
|
||||
r = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (buffer + position), bytes);
|
||||
iov->iov_size -= bytes;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return r;
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
static int
|
||||
sht21_other(message * m)
|
||||
static void
|
||||
sht21_other(message * m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
switch (m->m_type) {
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
log_debug(&log,
|
||||
"bus driver changed state, update endpoint\n");
|
||||
i2cdriver_handle_bus_update(&bus_endpoint, bus,
|
||||
address);
|
||||
}
|
||||
r = OK;
|
||||
break;
|
||||
default:
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
r = EINVAL;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
return r;
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -527,7 +491,7 @@ main(int argc, char *argv[])
|
|||
|
||||
sef_local_startup();
|
||||
|
||||
chardriver_task(&sht21_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&sht21_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,14 +163,14 @@ static int check_revision(void);
|
|||
static int read_edid(uint8_t * data, size_t count);
|
||||
|
||||
/* libblockdriver callbacks */
|
||||
static int tda19988_blk_open(dev_t minor, int access);
|
||||
static int tda19988_blk_close(dev_t minor);
|
||||
static ssize_t tda19988_blk_transfer(dev_t minor, int do_write, u64_t pos,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned count, int flags);
|
||||
static int tda19988_blk_ioctl(dev_t minor, unsigned int request,
|
||||
endpoint_t endpt, cp_grant_id_t grant);
|
||||
static struct device *tda19988_blk_part(dev_t minor);
|
||||
static int tda19988_blk_other(message * m);
|
||||
static int tda19988_blk_open(devminor_t minor, int access);
|
||||
static int tda19988_blk_close(devminor_t minor);
|
||||
static ssize_t tda19988_blk_transfer(devminor_t minor, int do_write, u64_t pos,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned int count, int flags);
|
||||
static int tda19988_blk_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, endpoint_t user_endpt);
|
||||
static struct device *tda19988_blk_part(devminor_t minor);
|
||||
static void tda19988_blk_other(message * m, int ipc_status);
|
||||
|
||||
/* Entry points into the device dependent code of block drivers. */
|
||||
struct blockdriver tda19988_tab = {
|
||||
|
|
@ -178,14 +178,9 @@ struct blockdriver tda19988_tab = {
|
|||
.bdr_open = tda19988_blk_open,
|
||||
.bdr_close = tda19988_blk_close,
|
||||
.bdr_transfer = tda19988_blk_transfer,
|
||||
.bdr_ioctl = tda19988_blk_ioctl, /* nop -- always returns EINVAL */
|
||||
.bdr_cleanup = NULL, /* nothing allocated -- nothing to clean up */
|
||||
.bdr_ioctl = tda19988_blk_ioctl, /* always returns ENOTTY */
|
||||
.bdr_part = tda19988_blk_part,
|
||||
.bdr_geometry = NULL, /* no geometry (cylinders, heads, sectors, etc) */
|
||||
.bdr_intr = NULL, /* i2c devices don't generate interrupts */
|
||||
.bdr_alarm = NULL, /* alarm not needed */
|
||||
.bdr_other = tda19988_blk_other, /* to recv notify events from DS */
|
||||
.bdr_device = NULL /* 1 insance per device, threads not needed */
|
||||
.bdr_other = tda19988_blk_other /* for notify events from DS */
|
||||
};
|
||||
|
||||
/* counts the number of times a device file is open */
|
||||
|
|
@ -195,7 +190,7 @@ static int openct[NR_DEVS];
|
|||
static struct device geom[NR_DEVS];
|
||||
|
||||
static int
|
||||
tda19988_blk_open(dev_t minor, int access)
|
||||
tda19988_blk_open(devminor_t minor, int access)
|
||||
{
|
||||
log_trace(&log, "tda19988_blk_open(%d,%d)\n", minor, access);
|
||||
if (tda19988_blk_part(minor) == NULL) {
|
||||
|
|
@ -208,7 +203,7 @@ tda19988_blk_open(dev_t minor, int access)
|
|||
}
|
||||
|
||||
static int
|
||||
tda19988_blk_close(dev_t minor)
|
||||
tda19988_blk_close(devminor_t minor)
|
||||
{
|
||||
log_trace(&log, "tda19988_blk_close(%d)\n", minor);
|
||||
if (tda19988_blk_part(minor) == NULL) {
|
||||
|
|
@ -225,8 +220,8 @@ tda19988_blk_close(dev_t minor)
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
tda19988_blk_transfer(dev_t minor, int do_write, u64_t pos64,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned nr_req, int flags)
|
||||
tda19988_blk_transfer(devminor_t minor, int do_write, u64_t pos64,
|
||||
endpoint_t endpt, iovec_t * iov, unsigned int nr_req, int flags)
|
||||
{
|
||||
unsigned count;
|
||||
struct device *dv;
|
||||
|
|
@ -319,35 +314,32 @@ tda19988_blk_transfer(dev_t minor, int do_write, u64_t pos64,
|
|||
}
|
||||
|
||||
static int
|
||||
tda19988_blk_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
|
||||
cp_grant_id_t grant)
|
||||
tda19988_blk_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
cp_grant_id_t grant, endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
log_trace(&log, "tda19988_blk_ioctl(%d)\n", minor);
|
||||
/* no supported ioctls for this device */
|
||||
return EINVAL;
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
static struct device *
|
||||
tda19988_blk_part(dev_t minor)
|
||||
tda19988_blk_part(devminor_t minor)
|
||||
{
|
||||
log_trace(&log, "tda19988_blk_part(%d)\n", minor);
|
||||
|
||||
if (minor >= NR_DEVS) {
|
||||
if (minor < 0 || minor >= NR_DEVS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &geom[minor];
|
||||
}
|
||||
|
||||
static int
|
||||
tda19988_blk_other(message * m)
|
||||
static void
|
||||
tda19988_blk_other(message * m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
log_trace(&log, "tda19988_blk_other(0x%x)\n", m->m_type);
|
||||
|
||||
switch (m->m_type) {
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
log_debug(&log,
|
||||
"bus driver changed state, update endpoint\n");
|
||||
|
|
@ -356,15 +348,9 @@ tda19988_blk_other(message * m)
|
|||
i2cdriver_handle_bus_update(&hdmi_bus_endpoint,
|
||||
hdmi_bus, hdmi_address);
|
||||
}
|
||||
r = OK;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
r = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -356,7 +356,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int r;
|
||||
endpoint_t user, caller;
|
||||
message m;
|
||||
int ipc_status;
|
||||
|
||||
|
|
@ -407,26 +406,8 @@ main(int argc, char *argv[])
|
|||
continue;
|
||||
}
|
||||
|
||||
caller = m.m_source;
|
||||
user = m.USER_ENDPT;
|
||||
|
||||
/*
|
||||
* Handle Message
|
||||
*
|
||||
* So far this driver only deals with notifications
|
||||
* so it always replies to non-notifications with EINVAL.
|
||||
*/
|
||||
|
||||
/* Send Reply */
|
||||
m.m_type = TASK_REPLY;
|
||||
m.REP_ENDPT = user;
|
||||
m.REP_STATUS = EINVAL;
|
||||
|
||||
r = sendnb(caller, &m);
|
||||
if (r != OK) {
|
||||
log_warn(&log, "sendnb() failed\n");
|
||||
continue;
|
||||
}
|
||||
log_warn(&log, "Ignoring message 0x%x from 0x%x\n", m.m_type,
|
||||
m.m_source);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -65,11 +65,9 @@ static int adc_read(int adc, uint8_t * val);
|
|||
static int measure_lux(uint32_t * lux);
|
||||
|
||||
/* libchardriver callbacks */
|
||||
static struct device *tsl2550_prepare(dev_t UNUSED(dev));
|
||||
static int tsl2550_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags));
|
||||
static int tsl2550_other(message * m);
|
||||
static ssize_t tsl2550_read(devminor_t minor, u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
|
||||
static void tsl2550_other(message * m, int ipc_status);
|
||||
|
||||
/* SEF functions */
|
||||
static int sef_cb_lu_state_save(int);
|
||||
|
|
@ -79,21 +77,8 @@ static void sef_local_startup(void);
|
|||
|
||||
/* Entry points to this driver from libchardriver. */
|
||||
static struct chardriver tsl2550_tab = {
|
||||
.cdr_open = do_nop,
|
||||
.cdr_close = do_nop,
|
||||
.cdr_ioctl = nop_ioctl,
|
||||
.cdr_prepare = tsl2550_prepare,
|
||||
.cdr_transfer = tsl2550_transfer,
|
||||
.cdr_cleanup = nop_cleanup,
|
||||
.cdr_alarm = nop_alarm,
|
||||
.cdr_cancel = nop_cancel,
|
||||
.cdr_select = nop_select,
|
||||
.cdr_other = tsl2550_other
|
||||
};
|
||||
|
||||
static struct device tsl2550_device = {
|
||||
.dv_base = 0,
|
||||
.dv_size = 0
|
||||
.cdr_read = tsl2550_read,
|
||||
.cdr_other = tsl2550_other
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -294,17 +279,11 @@ tsl2550_init(void)
|
|||
return OK;
|
||||
}
|
||||
|
||||
static struct device *
|
||||
tsl2550_prepare(dev_t UNUSED(dev))
|
||||
{
|
||||
return &tsl2550_device;
|
||||
}
|
||||
|
||||
static int
|
||||
tsl2550_transfer(endpoint_t endpt, int opcode, u64_t position,
|
||||
iovec_t * iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),
|
||||
unsigned int UNUSED(flags))
|
||||
static ssize_t
|
||||
tsl2550_read(devminor_t UNUSED(minor), u64_t position, endpoint_t endpt,
|
||||
cp_grant_id_t grant, size_t size, int UNUSED(flags), cdev_id_t UNUSED(id))
|
||||
{
|
||||
u64_t dev_size;
|
||||
int bytes, r;
|
||||
uint32_t lux;
|
||||
|
||||
|
|
@ -316,48 +295,33 @@ tsl2550_transfer(endpoint_t endpt, int opcode, u64_t position,
|
|||
memset(buffer, '\0', BUFFER_LEN + 1);
|
||||
snprintf(buffer, BUFFER_LEN, "%-16s: %d\n", "ILLUMINANCE", lux);
|
||||
|
||||
bytes = strlen(buffer) - position < iov->iov_size ?
|
||||
strlen(buffer) - position : iov->iov_size;
|
||||
dev_size = (u64_t)strlen(buffer);
|
||||
if (position >= dev_size) return 0;
|
||||
if (position + size > dev_size)
|
||||
size = (size_t)(dev_size - position);
|
||||
|
||||
if (bytes <= 0) {
|
||||
return OK;
|
||||
}
|
||||
r = sys_safecopyto(endpt, grant, 0,
|
||||
(vir_bytes)(buffer + (size_t)position), size);
|
||||
|
||||
switch (opcode) {
|
||||
case DEV_GATHER_S:
|
||||
r = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,
|
||||
(vir_bytes) (buffer + position), bytes);
|
||||
iov->iov_size -= bytes;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return r;
|
||||
return (r != OK) ? r : size;
|
||||
}
|
||||
|
||||
static int
|
||||
tsl2550_other(message * m)
|
||||
static void
|
||||
tsl2550_other(message * m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
switch (m->m_type) {
|
||||
case NOTIFY_MESSAGE:
|
||||
if (is_ipc_notify(ipc_status)) {
|
||||
if (m->m_source == DS_PROC_NR) {
|
||||
log_debug(&log,
|
||||
"bus driver changed state, update endpoint\n");
|
||||
i2cdriver_handle_bus_update(&bus_endpoint, bus,
|
||||
address);
|
||||
}
|
||||
r = OK;
|
||||
break;
|
||||
default:
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
r = EINVAL;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
return r;
|
||||
log_warn(&log, "Invalid message type (0x%x)\n", m->m_type);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -476,7 +440,7 @@ main(int argc, char *argv[])
|
|||
|
||||
sef_local_startup();
|
||||
|
||||
chardriver_task(&tsl2550_tab, CHARDRIVER_SYNC);
|
||||
chardriver_task(&tsl2550_tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ PROG= tty
|
|||
|
||||
SRCS += tty.c pty.c
|
||||
|
||||
DPADD+= ${LIBSYS} ${LIBTIMERS}
|
||||
LDADD+= -lsys -ltimers
|
||||
DPADD+= ${LIBCHARDRIVER} ${LIBSYS} ${LIBTIMERS}
|
||||
LDADD+= -lchardriver -lsys -ltimers
|
||||
|
||||
MAN=
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "tty.h"
|
||||
|
||||
void
|
||||
do_video(message *m)
|
||||
do_video(message *m, int ipc_status)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -18,9 +18,13 @@ cons_stop(void)
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
beep_x(unsigned int freq, clock_t dur)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
con_loadfont(message *m)
|
||||
con_loadfont(endpoint_t endpt, cp_grant_id_t grant)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,28 +3,13 @@
|
|||
#include <termios.h>
|
||||
#include "tty.h"
|
||||
|
||||
void
|
||||
kbd_interrupt(message *m)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
do_fkey_ctl(message *m)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
do_kb_inject(message *m)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
do_kbd(message *m)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
do_kbdaux(message *m)
|
||||
do_input(message *m)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -34,13 +19,7 @@ kb_init_once(void)
|
|||
}
|
||||
|
||||
int
|
||||
kbd_status(message *m)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
kbd_loadmap(message *m)
|
||||
kbd_loadmap(endpoint_t endpt, cp_grant_id_t grant)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,11 +239,11 @@ rs_write(register tty_t *tp, int try)
|
|||
if (tp->tty_outcaller == KERNEL) {
|
||||
/* We're trying to print on kernel's behalf */
|
||||
memcpy(rs->ohead,
|
||||
(void *) tp->tty_outgrant + tp->tty_outoffset,
|
||||
(char *) tp->tty_outgrant + tp->tty_outcum,
|
||||
count);
|
||||
} else {
|
||||
if ((r = sys_safecopyfrom(tp->tty_outcaller,
|
||||
tp->tty_outgrant, tp->tty_outoffset,
|
||||
tp->tty_outgrant, tp->tty_outcum,
|
||||
(vir_bytes) rs->ohead, count)) != OK) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -264,31 +264,21 @@ rs_write(register tty_t *tp, int try)
|
|||
rs_ostart(rs);
|
||||
if ((rs->ohead += ocount) >= bufend(rs->obuf))
|
||||
rs->ohead -= buflen(rs->obuf);
|
||||
tp->tty_outoffset += count;
|
||||
tp->tty_outcum += count;
|
||||
if ((tp->tty_outleft -= count) == 0) {
|
||||
/* Output is finished, reply to the writer. */
|
||||
if(tp->tty_outrepcode == TTY_REVIVE) {
|
||||
notify(tp->tty_outcaller);
|
||||
tp->tty_outrevived = 1;
|
||||
} else {
|
||||
tty_reply(tp->tty_outrepcode, tp->tty_outcaller,
|
||||
tp->tty_outproc, tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
}
|
||||
chardriver_reply_task(tp->tty_outcaller, tp->tty_outid,
|
||||
tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
tp->tty_outcaller = NONE;
|
||||
}
|
||||
|
||||
}
|
||||
if (tp->tty_outleft > 0 && tp->tty_termios.c_ospeed == B0) {
|
||||
/* Oops, the line has hung up. */
|
||||
if(tp->tty_outrepcode == TTY_REVIVE) {
|
||||
notify(tp->tty_outcaller);
|
||||
tp->tty_outrevived = 1;
|
||||
} else {
|
||||
tty_reply(tp->tty_outrepcode, tp->tty_outcaller,
|
||||
tp->tty_outproc, EIO);
|
||||
tp->tty_outleft = tp->tty_outcum = 0;
|
||||
}
|
||||
chardriver_reply_task(tp->tty_outcaller, tp->tty_outid, EIO);
|
||||
tp->tty_outleft = tp->tty_outcum = 0;
|
||||
tp->tty_outcaller = NONE;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -355,7 +345,6 @@ termios_baud_rate(struct termios *term)
|
|||
{
|
||||
int baud;
|
||||
switch(term->c_ospeed) {
|
||||
case B0: term->c_ospeed = DFLT_BAUD; baud = termios_baud_rate(term);
|
||||
case B300: baud = 300; break;
|
||||
case B600: baud = 600; break;
|
||||
case B1200: baud = 1200; break;
|
||||
|
|
@ -365,7 +354,14 @@ termios_baud_rate(struct termios *term)
|
|||
case B38400: baud = 38400; break;
|
||||
case B57600: baud = 57600; break;
|
||||
case B115200: baud = 115200; break;
|
||||
default: term->c_ospeed = DFLT_BAUD; baud = termios_baud_rate(term);
|
||||
case B0:
|
||||
default:
|
||||
/* Reset the speed to the default speed, then call ourselves
|
||||
* to convert the default speed to a baudrate. This call will
|
||||
* always return a value without inducing another recursive
|
||||
* call. */
|
||||
term->c_ospeed = DFLT_BAUD;
|
||||
baud = termios_baud_rate(term);
|
||||
}
|
||||
|
||||
return baud;
|
||||
|
|
@ -646,7 +642,7 @@ rs_read(tty_t *tp, int try)
|
|||
if (count > icount) count = icount;
|
||||
|
||||
/* Perform input processing on (part of) the input buffer. */
|
||||
if ((count = in_process(tp, rs->itail, count, -1)) == 0) break;
|
||||
if ((count = in_process(tp, rs->itail, count)) == 0) break;
|
||||
rs->icount -= count;
|
||||
if (!rs->idevready && rs->icount < RS_ILOWWATER) istart(rs);
|
||||
if ((rs->itail += count) == bufend(rs->ibuf))
|
||||
|
|
|
|||
|
|
@ -18,16 +18,10 @@
|
|||
|
||||
#include <minix/drivers.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/vm.h>
|
||||
#include <sys/video.h>
|
||||
#include <sys/mman.h>
|
||||
#include <minix/tty.h>
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/sys_config.h>
|
||||
#include <minix/vm.h>
|
||||
#include "tty.h"
|
||||
|
||||
/* Set this to 1 if you want console output duplicated on the first
|
||||
|
|
@ -129,7 +123,7 @@ static void flush(console_t *cons);
|
|||
static void parse_escape(console_t *cons, int c);
|
||||
static void scroll_screen(console_t *cons, int dir);
|
||||
static void set_6845(int reg, unsigned val);
|
||||
static void stop_beep(timer_t *tmrp);
|
||||
static void stop_beep(minix_timer_t *tmrp);
|
||||
static void cons_org0(void);
|
||||
static void disable_console(void);
|
||||
static void reenable_console(void);
|
||||
|
|
@ -142,6 +136,18 @@ static void vid_vid_copy(int src, int dst, int count);
|
|||
static void get_6845(int reg, unsigned *val);
|
||||
#endif
|
||||
|
||||
static int video_open(devminor_t minor, int access, endpoint_t user_endpt);
|
||||
static int video_close(devminor_t minor);
|
||||
static int video_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, int flags,
|
||||
endpoint_t user_endpt, cdev_id_t id);
|
||||
|
||||
static struct chardriver video_tab = {
|
||||
.cdr_open = video_open,
|
||||
.cdr_close = video_close,
|
||||
.cdr_ioctl = video_ioctl
|
||||
};
|
||||
|
||||
/*===========================================================================*
|
||||
* cons_write *
|
||||
*===========================================================================*/
|
||||
|
|
@ -174,16 +180,14 @@ int try;
|
|||
if (count > sizeof(buf)) count = sizeof(buf);
|
||||
if (tp->tty_outcaller == KERNEL) {
|
||||
/* We're trying to print on kernel's behalf */
|
||||
memcpy(buf, (void *) tp->tty_outgrant + tp->tty_outoffset,
|
||||
count);
|
||||
memcpy(buf, (char *) tp->tty_outgrant + tp->tty_outcum, count);
|
||||
} else {
|
||||
if ((result = sys_safecopyfrom(tp->tty_outcaller,
|
||||
tp->tty_outgrant, tp->tty_outoffset,
|
||||
tp->tty_outgrant, tp->tty_outcum,
|
||||
(vir_bytes) buf, count)) != OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tp->tty_outoffset += count;
|
||||
tbuf = buf;
|
||||
|
||||
/* Update terminal data structure. */
|
||||
|
|
@ -215,14 +219,10 @@ int try;
|
|||
|
||||
/* Reply to the writer if all output is finished or if an error occured. */
|
||||
if (tp->tty_outleft == 0 || result != OK) {
|
||||
if(tp->tty_outrepcode == TTY_REVIVE) {
|
||||
notify(tp->tty_outcaller);
|
||||
tp->tty_outrevived = 1;
|
||||
} else {
|
||||
tty_reply(tp->tty_outrepcode, tp->tty_outcaller,
|
||||
tp->tty_outproc, tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
}
|
||||
chardriver_reply_task(tp->tty_outcaller, tp->tty_outid,
|
||||
result != OK ? result : tp->tty_outcum);
|
||||
tp->tty_outcum = tp->tty_outleft = 0;
|
||||
tp->tty_outcaller = NONE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -789,7 +789,7 @@ static void beep()
|
|||
* This routine works by turning on the bits 0 and 1 in port B of the 8255
|
||||
* chip that drive the speaker.
|
||||
*/
|
||||
static timer_t tmr_stop_beep;
|
||||
static minix_timer_t tmr_stop_beep;
|
||||
pvb_pair_t char_out[3];
|
||||
u32_t port_b_val;
|
||||
|
||||
|
|
@ -811,82 +811,69 @@ static void beep()
|
|||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* video_open *
|
||||
*===========================================================================*/
|
||||
static int video_open(devminor_t minor, int UNUSED(access),
|
||||
endpoint_t UNUSED(user_endpt))
|
||||
{
|
||||
/* Should grant IOPL */
|
||||
disable_console();
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* video_close *
|
||||
*===========================================================================*/
|
||||
static int video_close(devminor_t minor)
|
||||
{
|
||||
reenable_console();
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* video_ioctl *
|
||||
*===========================================================================*/
|
||||
static int video_ioctl(devminor_t minor, unsigned long request,
|
||||
endpoint_t endpt, cp_grant_id_t grant, int flags,
|
||||
endpoint_t user_endpt, cdev_id_t id)
|
||||
{
|
||||
struct mapreqvm mapreqvm;
|
||||
int r, do_map;
|
||||
|
||||
switch (request) {
|
||||
case TIOCMAPMEM:
|
||||
case TIOCUNMAPMEM:
|
||||
do_map = (request == TIOCMAPMEM); /* else unmap */
|
||||
|
||||
if ((r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &mapreqvm,
|
||||
sizeof(mapreqvm))) != OK)
|
||||
return r;
|
||||
|
||||
if (do_map) {
|
||||
mapreqvm.vaddr_ret = vm_map_phys(user_endpt,
|
||||
(void *) mapreqvm.phys_offset, mapreqvm.size);
|
||||
r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &mapreqvm,
|
||||
sizeof(mapreqvm));
|
||||
} else {
|
||||
r = vm_unmap_phys(user_endpt, mapreqvm.vaddr, mapreqvm.size);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_video *
|
||||
*===========================================================================*/
|
||||
void do_video(message *m)
|
||||
void do_video(message *m, int ipc_status)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* Execute the requested device driver function. */
|
||||
r= EINVAL; /* just in case */
|
||||
switch (m->m_type) {
|
||||
case DEV_OPEN:
|
||||
/* Should grant IOPL */
|
||||
disable_console();
|
||||
r= OK;
|
||||
break;
|
||||
case DEV_CLOSE:
|
||||
reenable_console();
|
||||
r= OK;
|
||||
break;
|
||||
case DEV_IOCTL_S:
|
||||
switch(m->TTY_REQUEST) {
|
||||
case TIOCMAPMEM:
|
||||
case TIOCUNMAPMEM: {
|
||||
int r, do_map;
|
||||
struct mapreqvm mapreqvm;
|
||||
|
||||
do_map= (m->REQUEST == TIOCMAPMEM); /* else unmap */
|
||||
|
||||
r = sys_safecopyfrom(m->m_source,
|
||||
(cp_grant_id_t) m->IO_GRANT, 0,
|
||||
(vir_bytes) &mapreqvm, sizeof(mapreqvm));
|
||||
|
||||
if (r != OK)
|
||||
{
|
||||
printf("tty: sys_safecopyfrom failed\n");
|
||||
tty_reply(TASK_REPLY, m->m_source,
|
||||
m->USER_ENDPT, r);
|
||||
return;
|
||||
}
|
||||
|
||||
/* In safe ioctl mode, the POSITION field contains
|
||||
* the endpt number of the original requestor.
|
||||
* USER_ENDPT is always FS.
|
||||
*/
|
||||
|
||||
if(do_map) {
|
||||
mapreqvm.vaddr_ret = vm_map_phys(m->POSITION,
|
||||
(void *) mapreqvm.phys_offset, mapreqvm.size);
|
||||
if((r = sys_safecopyto(m->m_source,
|
||||
(cp_grant_id_t) m->IO_GRANT, 0,
|
||||
(vir_bytes) &mapreqvm,
|
||||
sizeof(mapreqvm))) != OK) {
|
||||
printf("tty: sys_safecopyto failed\n");
|
||||
}
|
||||
} else {
|
||||
r = vm_unmap_phys(m->POSITION,
|
||||
mapreqvm.vaddr, mapreqvm.size);
|
||||
}
|
||||
tty_reply(TASK_REPLY, m->m_source, m->USER_ENDPT, r);
|
||||
return;
|
||||
}
|
||||
}
|
||||
r= ENOTTY;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf(
|
||||
"Warning, TTY(video) got unexpected request %d from %d\n",
|
||||
m->m_type, m->m_source);
|
||||
r= EINVAL;
|
||||
}
|
||||
tty_reply(TASK_REPLY, m->m_source, m->USER_ENDPT, r);
|
||||
chardriver_process(&video_tab, m, ipc_status);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* beep_x *
|
||||
*===========================================================================*/
|
||||
|
|
@ -898,7 +885,7 @@ clock_t dur;
|
|||
* This routine works by turning on the bits 0 and 1 in port B of the 8255
|
||||
* chip that drive the speaker.
|
||||
*/
|
||||
static timer_t tmr_stop_beep;
|
||||
static minix_timer_t tmr_stop_beep;
|
||||
pvb_pair_t char_out[3];
|
||||
u32_t port_b_val;
|
||||
|
||||
|
|
@ -927,7 +914,7 @@ clock_t dur;
|
|||
/*===========================================================================*
|
||||
* stop_beep *
|
||||
*===========================================================================*/
|
||||
static void stop_beep(timer_t *UNUSED(tmrp))
|
||||
static void stop_beep(minix_timer_t *UNUSED(tmrp))
|
||||
{
|
||||
/* Turn off the beeper by turning off bits 0 and 1 in PORT_B. */
|
||||
u32_t port_b_val;
|
||||
|
|
@ -1139,12 +1126,11 @@ void select_console(int cons_line)
|
|||
/*===========================================================================*
|
||||
* con_loadfont *
|
||||
*===========================================================================*/
|
||||
int con_loadfont(m)
|
||||
message *m;
|
||||
int con_loadfont(endpoint_t endpt, cp_grant_id_t grant)
|
||||
{
|
||||
|
||||
/* Load a font into the EGA or VGA adapter. */
|
||||
int result;
|
||||
int r, r2;
|
||||
static struct sequence seq1[7] = {
|
||||
{ GA_SEQUENCER_INDEX, 0x00, 0x01 },
|
||||
{ GA_SEQUENCER_INDEX, 0x02, 0x04 },
|
||||
|
|
@ -1166,17 +1152,14 @@ message *m;
|
|||
|
||||
seq2[6].value= color ? 0x0E : 0x0A;
|
||||
|
||||
result = ga_program(seq1); /* bring font memory into view */
|
||||
r = ga_program(seq1); /* bring font memory into view */
|
||||
if (r != OK) return r;
|
||||
|
||||
if(sys_safecopyfrom(m->m_source, (cp_grant_id_t) m->IO_GRANT, 0,
|
||||
(vir_bytes) font_memory, GA_FONT_SIZE) != OK) {
|
||||
printf("tty: copying from %d failed\n", m->m_source);
|
||||
return EFAULT;
|
||||
}
|
||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) font_memory, GA_FONT_SIZE);
|
||||
|
||||
result = ga_program(seq2); /* restore */
|
||||
r2 = ga_program(seq2); /* restore */
|
||||
|
||||
return(result);
|
||||
return(r != OK ? r : r2);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -246,10 +246,11 @@ static int rs_write(register tty_t *tp, int try)
|
|||
/* Copy from user space to the RS232 output buffer. */
|
||||
if (tp->tty_outcaller == KERNEL) {
|
||||
/* We're trying to print on kernel's behalf */
|
||||
memcpy(rs->ohead, (void *) tp->tty_outgrant + tp->tty_outoffset, count);
|
||||
memcpy(rs->ohead, (char *) tp->tty_outgrant + tp->tty_outcum,
|
||||
count);
|
||||
} else {
|
||||
if ((r = sys_safecopyfrom(tp->tty_outcaller, tp->tty_outgrant,
|
||||
tp->tty_outoffset, (vir_bytes) rs->ohead, count)) != OK)
|
||||
tp->tty_outcum, (vir_bytes) rs->ohead, count)) != OK)
|
||||
printf("TTY: sys_safecopyfrom() failed: %d", r);
|
||||
}
|
||||
|
||||
|
|
@ -265,30 +266,20 @@ static int rs_write(register tty_t *tp, int try)
|
|||
rs_ostart(rs);
|
||||
if ((rs->ohead += ocount) >= bufend(rs->obuf))
|
||||
rs->ohead -= buflen(rs->obuf);
|
||||
tp->tty_outoffset += count;
|
||||
tp->tty_outcum += count;
|
||||
if ((tp->tty_outleft -= count) == 0) {
|
||||
/* Output is finished, reply to the writer. */
|
||||
if(tp->tty_outrepcode == TTY_REVIVE) {
|
||||
notify(tp->tty_outcaller);
|
||||
tp->tty_outrevived = 1;
|
||||
} else {
|
||||
tty_reply(tp->tty_outrepcode, tp->tty_outcaller,
|
||||
tp->tty_outproc, tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
}
|
||||
chardriver_reply_task(tp->tty_outcaller, tp->tty_outid,
|
||||
tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
tp->tty_outcaller = NONE;
|
||||
}
|
||||
}
|
||||
if (tp->tty_outleft > 0 && tp->tty_termios.c_ospeed == B0) {
|
||||
/* Oops, the line has hung up. */
|
||||
if(tp->tty_outrepcode == TTY_REVIVE) {
|
||||
notify(tp->tty_outcaller);
|
||||
tp->tty_outrevived = 1;
|
||||
} else {
|
||||
tty_reply(tp->tty_outrepcode, tp->tty_outcaller,
|
||||
tp->tty_outproc, EIO);
|
||||
tp->tty_outleft = tp->tty_outcum = 0;
|
||||
}
|
||||
chardriver_reply_task(tp->tty_outcaller, tp->tty_outid, EIO);
|
||||
tp->tty_outleft = tp->tty_outcum = 0;
|
||||
tp->tty_outcaller = NONE;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -597,7 +588,7 @@ static int rs_read(tty_t *tp, int try)
|
|||
if (count > icount) count = icount;
|
||||
|
||||
/* Perform input processing on (part of) the input buffer. */
|
||||
if ((count = in_process(tp, rs->itail, count, -1)) == 0) break;
|
||||
if ((count = in_process(tp, rs->itail, count)) == 0) break;
|
||||
|
||||
rs->icount -= count;
|
||||
if (!rs->idevready && rs->icount < RS_ILOWWATER) istart(rs);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
.include <bsd.own.mk>
|
||||
|
||||
FILES= dvorak.map french.map german.map italian.map japanese.map \
|
||||
latin-america.map olivetti.map polish.map russian-cp866.map \
|
||||
latin-america.map norwegian.map polish.map russian-cp866.map \
|
||||
russian.map scandinavian.map spanish.map uk.map \
|
||||
us-std-esc.map us-std.map us-swap.map russian-cp1251.map \
|
||||
us-std.map us-swap.map russian-cp1251.map \
|
||||
ukraine-koi8-u.map portuguese.map abnt2.map
|
||||
|
||||
.include "Makefile.inc"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user