# HG changeset patch # User David du Colombier <0intro@gmail.com> # Date 1334225654 -7200 # Node ID bd329fe2476d96c556e6a6ca609dc18134cae074 # Parent 6ba826535859dc3534915066040016e79decd8ce nix: sync with plan 9 R=nixiedev, quanstro CC=nix-dev http://codereview.appspot.com/5977045 Committer: Francisco J Ballesteros diff -r 6ba826535859 -r bd329fe2476d arm/include/u.h --- a/arm/include/u.h Wed Mar 28 17:14:41 2012 +0200 +++ b/arm/include/u.h Thu Apr 12 12:14:14 2012 +0200 @@ -22,7 +22,7 @@ typedef unsigned long long u64int; /* VFP FCR */ -#define FPINEX (1<<12) +#define FPINEX (1<<12) /* trap enables for exceptions */ #define FPUNFL (1<<11) #define FPOVFL (1<<10) #define FPZDIV (1<<9) @@ -37,7 +37,7 @@ #define FPPDBL 0 #define FPPMASK 0 /* FSR */ -#define FPAINEX (1<<4) +#define FPAINEX (1<<4) /* accrued exceptions */ #define FPAUNFL (1<<3) #define FPAOVFL (1<<2) #define FPAZDIV (1<<1) diff -r 6ba826535859 -r bd329fe2476d rc/bin/cpurc --- a/rc/bin/cpurc Wed Mar 28 17:14:41 2012 +0200 +++ b/rc/bin/cpurc Thu Apr 12 12:14:14 2012 +0200 @@ -40,8 +40,13 @@ # # auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1] # auth/cron >>/sys/log/cron >[2=1] & -# -# also rename some files: + +sshtun + +# keep other bootes processes from creating capabilities +rm -f '#¤/caphash' + +# also rename some files on an auth server: # # if(! test -e /rc/bin/service.auth/tcp567){ # mv /rc/bin/service.auth/authsrv.il566 /rc/bin/service.auth/il566 diff -r 6ba826535859 -r bd329fe2476d rc/bin/diffy --- a/rc/bin/diffy Wed Mar 28 17:14:41 2012 +0200 +++ b/rc/bin/diffy Thu Apr 12 12:14:14 2012 +0200 @@ -1,5 +1,5 @@ #!/bin/rc -# diffy [diff-opts] file... - diff file against yesterday's version(s) +# diffy [diff-opts] [file...] - diff file against yesterday's version(s) rfork e diffopts=() while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){ @@ -10,5 +10,7 @@ shift if(! ~ $#* 1) diffopts=($diffopts -m) +if (~ $#* 0) + * = (.) for(f) diff $diffopts `{yesterday $f} $f diff -r 6ba826535859 -r bd329fe2476d rc/bin/patch/list --- a/rc/bin/patch/list Wed Mar 28 17:14:41 2012 +0200 +++ b/rc/bin/patch/list Thu Apr 12 12:14:14 2012 +0200 @@ -12,7 +12,7 @@ exit no-sources } -if(~ $1 applied saved sorry maybe){ +if(~ $1 applied saved sorry maybe bad){ pref=$1^'/' shift } @@ -20,7 +20,7 @@ *=(`{ if(~ $pref *?*) builtin cd $pref - ls -t | grep -v '^(applied|saved|sorry|maybe)$' + ls -t | grep -v '^(applied|saved|sorry|maybe|bad)$' }) trunc=(sed 5q) diff -r 6ba826535859 -r bd329fe2476d sys/lib/kbmap/uk --- a/sys/lib/kbmap/uk Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/lib/kbmap/uk Thu Apr 12 12:14:14 2012 +0200 @@ -4,4 +4,5 @@ 1 4 '£ 1 40 '@ 0 86 '\ +4 86 ^\ 1 86 '| diff -r 6ba826535859 -r bd329fe2476d sys/man/2/dsa --- a/sys/man/2/dsa Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/2/dsa Thu Apr 12 12:14:14 2012 +0200 @@ -136,4 +136,5 @@ .IR rsa (2), .IR sechash (2), .IR prime (2), -.IR rand (2) +.IR rand (2), +.IR dsa (8) diff -r 6ba826535859 -r bd329fe2476d sys/man/2/encode --- a/sys/man/2/encode Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/2/encode Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,7 @@ .TH ENCODE 2 +.EQ +delim $$ +.EN .SH NAME dec64, enc64, dec32, enc32, dec16, enc16, encodefmt \- encoding byte arrays as strings .SH SYNOPSIS @@ -27,7 +30,6 @@ .B int encodefmt(Fmt*) .SH DESCRIPTION -.PP .IR Enc16 , .I enc32 and @@ -37,6 +39,10 @@ The encoding fails if .IR lim , the length of the output buffer, is too small. +They require +$2 n + 1$, ${ 8 n + 4 } over 5 + 1$ and +$4 { { n + 2 } over 3 } + 1$ bytes, +respectively. .PP .IR Dec16 , .I dec32 @@ -54,7 +60,7 @@ .IR print (2) to print encoded representations of byte arrays. The verbs are -.TP +.TP 3 .B H base 16 (i.e. hexadecimal). The default encoding is in upper case. The @@ -71,15 +77,12 @@ The length of the array is specified as .IR f2 . For example, to display a 15 byte array as hex: +.IP .EX +char x[15]; - char x[15]; - - fmtinstall('H', encodefmt); - print("%.*H\\n", sizeof x, x); - +fmtinstall('H', encodefmt); +print("%.*H\\n", sizeof x, x); .EE .SH SOURCE -.B /sys/src/libc/port/u32.c -.br -.B /sys/src/libc/port/u64.c +.B /sys/src/libc/port/u[136][246].c diff -r 6ba826535859 -r bd329fe2476d sys/man/3/cons --- a/sys/man/3/cons Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/3/cons Thu Apr 12 12:14:14 2012 +0200 @@ -242,7 +242,7 @@ Set the frequency for interpreting clock ticks to be .I freq ticks per second. -.PP +.SS "Statistics and Dynamic Status" The rest of the files contain (mostly) read-only strings. Each string has a fixed length: a .IR read (2) diff -r 6ba826535859 -r bd329fe2476d sys/man/8/booting --- a/sys/man/8/booting Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/booting Thu Apr 12 12:14:14 2012 +0200 @@ -24,7 +24,7 @@ other methods of rebooting are mentioned for some machines. .SS PCs To boot a PC, it is necessary to get -.B /386/9boot +.B /386/9load or .B /386/9load loaded into memory. @@ -36,14 +36,14 @@ .B 9load when the PC is reset or powered on. Other methods are described in -.IR 9boot (8). -.I 9boot +.IR 9load (8). +.I 9load or .I 9load then locates and loads a Plan 9 kernel, using configuration information from the matching file in .B /cfg/pxe -.RI ( 9boot ) +.RI ( 9load ) or the file .B plan9.ini stored in the @@ -51,7 +51,7 @@ configuration partition or on a DOS file system .RI ( 9load ). See -.IR 9boot (8) +.IR 9load (8) for details. .PP Once the kernel is booted, it behaves like the others. @@ -179,6 +179,12 @@ .L ether .I ndb attribute). +If loading from a non-Plan-9 +TFTP server, +replace +.L %C +with +.BI /cfg/pxe/ MAC. .PP First, establish a .I /cfg/pxe @@ -223,8 +229,8 @@ .EX setenv bootdelay 2 # \fItype the next two lines as one\fP -setenv bootcmd 'bootp; bootp; tftp 0x1000 /cfg/pxe/\fIMAC\fP; bootp; - tftp 0x800000; go 0x800000' +setenv bootcmd 'bootp; bootp; tftp 0x1000 %C; bootp; tftp 0x800000; + go 0x800000' saveenv .EE .PP @@ -234,7 +240,7 @@ instead: .IP .EX -\&'dhcp; tftpboot; tftpboot 0x1000 /cfg/pxe/\fIMAC\fP; bootz 0x500000' +\&'dhcp; tftpboot; tftpboot 0x1000 %C; bootz 0x500000' .EE .PP For Kirkwood Guruplugs, @@ -242,7 +248,7 @@ .LR "setenv bootcmd" : .IP .EX -\&'dhcp 0x800000; tftp 0x1000 /cfg/pxe/\fIMAC\fP; go 0x800000' +\&'dhcp 0x800000; tftp 0x1000 %C; go 0x800000' .EE .PP For IGEPv2 boards, @@ -250,7 +256,7 @@ .LR "setenv bootcmd" : .IP .EX -\&'tftp 0x80300000 /cfg/pxe/\fIMAC\fP; dhcp 0x80310000; go 0x80310000' +\&'tftp 0x80300000 %C; dhcp 0x80310000; go 0x80310000' .EE .PP For Gumstix Overo boards, @@ -258,16 +264,15 @@ .LR "setenv bootcmd" : .IP .EX -\&'bootp 0x80310000; bootp 0x80300000 /cfg/pxe/\fIMAC\fP; go 0x80310000' +\&'bootp 0x80310000; bootp 0x80300000 %C; go 0x80310000' .EE .PP For Trimslice systems, -type this as one line after +type this after .LR "setenv bootcmd" : .IP .EX -\&'dhcp; dhcp; tftpboot 0x410000; - tftpboot 0x400000 /cfg/pxe/\fIMAC\fP; go 0x410000' +\&'dhcp; dhcp; tftpboot 0x410000; tftpboot 0x400000 %C; go 0x410000' .EE .PP Thereafter, the boards will automatically boot via BOOTP and TFTP @@ -275,7 +280,7 @@ . .SH "SEE ALSO" .IR ndb (6), -.IR 9boot (8), +.IR 9load (8), .IR boot (8), .IR init (8), .IR plan9.ini (8) diff -r 6ba826535859 -r bd329fe2476d sys/man/8/dsa --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/man/8/dsa Thu Apr 12 12:14:14 2012 +0200 @@ -0,0 +1,171 @@ +.EQ +delim $$ +.EN +.TH DSA 8 +.SH NAME +dsagen, asn12dsa, dsa2pub, dsa2ssh \- generate and format dsa keys +.SH SYNOPSIS +.B auth/dsagen +.\" [ +.\" .B -b +.\" .I nbits +.\" ] +[ +.B -t +.I tag +] +.PP +.B auth/asn12dsa +[ +.B -t +.I tag +] +[ +.I file +] +.PP +.B auth/dsa2pub +[ +.I file +] +.PP +.B auth/dsa2ssh +[ +.B -c +.I comment +] [ +.I file +] +.SH DESCRIPTION +Plan 9 represents a DSA (Digital Signature Algorithm) +key as an attribute-value pair list +prefixed with the string +.BR key ; +this is the generic key format used by +.IR factotum (4). +A full DSA private key has the following attributes: +.TF secret +.TP +.B proto +must be +.B dsa +.TP +.B !secret +decryption key +.TP +.B p +modulus, a large prime +.TP +.B q +group order, another large prime that divides +.I p +- 1. +.TP +.B alpha +group generator +.TP +.B key +$"alpha" sup secret ~ mod ~ p$ +.PD +.LP +All the numbers are in hexadecimal. +A DSA public key omits the attributes beginning with +.LR ! . +A key may have other attributes as well (for example, a +.B service +attribute identifying how this key is typically used), +but to these utilities such attributes are merely comments. +.PP +For example, a private key and corresponding public key might look like this +(with [⋯] indicating elisions and \e marking line breaks for readability): +.IP +.EX +key proto=dsa p=D5[⋯]DB q=C2[⋯]E7 alpha=44[⋯]9B key=C1[⋯]3F \e + !secret=9E[⋯]3B +key proto=dsa p=D5[⋯]DB q=C2[⋯]E7 alpha=44[⋯]9B key=C1[⋯]3F +.EE +.LP +Note that the order of the attributes does not matter. +.PP +.I Dsagen +prints a randomly generated DSA private key +whose +.B n +has exactly +.I nbits +(default 1024) +significant bits. +If +.I tag +is specified, it is printed between +.B key +and +.BR proto=dsa ; +typically, +.I tag +is a sequence of attribute-value comments describing the key. +.PP +.I Asn12dsa +reads an DSA private key stored as ASN.1 +encoded in the binary Distinguished Encoding Rules (DER) +and prints a Plan 9 DSA key, +inserting +.I tag +exactly as +.I dsagen +does. +ASN.1/DER is a popular key format on Unix and Windows; +it is often encoded in text form using the Privacy Enhanced Mail (PEM) format +in a section labeled as an +.RB `` DSA +.B PRIVATE +.BR KEY .'' +The command: +.IP +.EX +auth/pemdecode 'DSA PRIVATE KEY' | auth/asn12dsa +.EE +.LP +extracts the key section from a textual ASN.1/DER/PEM key +into binary ASN.1/DER format and then +converts it to a Plan 9 DSA key. +.PP +.I Dsa2pub +reads a Plan 9 DSA public or private key, +removes the private attributes, and prints the resulting public key. +Comment attributes are preserved. +.PP +.I Dsa2ssh +reads a Plan 9 DSA public or private key and prints the public portion +in the format used by SSH: +.L ssh-dss +and a long base-64 encoded number. +.EQ +delim @@ +.EN +For compatibility with external SSH implementations, the public keys in +.B /sys/lib/ssh/keyring +and +.B $home/lib/keyring +are stored in this format. +.br +.ne 4 +.SH EXAMPLES +Generate a fresh key and configure a remote Unix system to +allow use of that key for logins: +.IP +.EX +auth/dsagen -t 'service=ssh' >key +auth/dsa2ssh key | ssh unix 'cat >>.ssh/authorized_keys' +cat key >/mnt/factotum/ctl +ssh unix +.EE +.SH SOURCE +.B /sys/src/cmd/auth +.SH "SEE ALSO +.IR ssh (1), +.IR factotum (4), +.IR pem (8), +.IR rsa (8) +.SH BUGS +There are too many key formats. diff -r 6ba826535859 -r bd329fe2476d sys/man/8/fossilcons --- a/sys/man/8/fossilcons Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/fossilcons Thu Apr 12 12:14:14 2012 +0200 @@ -1205,13 +1205,3 @@ .EX snap -a -s /snapshot/2003/1220/0700 -d /archive/2003/1220 .EE -.SH BUGS -It is prudent to avoid taking a snapshot at the same time as an -archival dump. -.I Fossil -has been seen to sometimes hang when they collide. -Snapshots are taken when -.BI time(0)/60% interval -is zero, so -an interval of 60 will take snapshots on the hour. -It's easiest to schedule the archival dumps to happen not exactly on the hour. diff -r 6ba826535859 -r bd329fe2476d sys/man/8/mk9660 --- a/sys/man/8/mk9660 Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/mk9660 Thu Apr 12 12:14:14 2012 +0200 @@ -16,6 +16,10 @@ [ .B -B .I bootfile +[ +.B -x +.I loader +] ] [ .B -p @@ -23,11 +27,11 @@ ] [ .B -s -src +.I src ] [ .B -v -volume +.I volume ] .I image .PP @@ -44,11 +48,11 @@ ] [ .B -s -src +.I src ] [ .B -v -volume +.I volume ] [ .B -m @@ -79,7 +83,7 @@ .PP The created CD image will be in ISO-9660 format, but by default the file names will -be stored in UTF-8 with no imposed length +be stored in UTF-8 with no imposed length or character restrictions. The .B -c @@ -88,7 +92,7 @@ to use only file names in ``8.3'' form that use digits, letters, and underscore. File names that do not conform are changed -to +to .BI D nnnnnn (for directories) or @@ -126,7 +130,7 @@ .B \e are allowed in Plan 9 file names but not in Joliet file names; non-conforming file names are translated -and a +and a .B _CONFORM.MAP file written as in the case of the @@ -137,7 +141,7 @@ .B -r flag is given, Rock Ridge extensions are written in the format of the system use sharing protocol; -this format provides Posix-style file metadata and is +this format provides Posix-style file metadata and is common on Unix platforms. .PP The options @@ -159,10 +163,10 @@ .I proto is used. .PP -The +The .B -: -flag causes -.B mk9660 +flag causes +.I mk9660 to replace colons in scanned file names with spaces; this is the inverse of the map applied by .IR dossrv (4) @@ -192,6 +196,14 @@ boot block. This gives the program in the boot block full (ATA) LBA access to the CD filesystem, not just the initial blocks that would fit on a floppy. +Additionally, +.B -x +can be used in conjunction with +.B -B +to make +.I mk9660 +annotate the boot file with the address and size of +the loader, which has to be a file in the CD's root directory. .PP The .B -D @@ -202,7 +214,7 @@ is similar in specification to .I mk9660 but creates and updates backup CD images in the style of -the +the .I dump file system (see @@ -216,7 +228,7 @@ option specifies a time (in seconds since January 1, 1970) to be used for naming the dump directory. .PP -The +The .B -m option specifies a maximum size for the image; if a backup would cause the image to grow larger than @@ -226,7 +238,7 @@ will exit with a non-empty status. .SH EXAMPLE .PP -Create an image of the Plan 9 source tree, +Create an image of the Plan 9 source tree, including a conformant ISO-9660 directory tree, Plan 9 extensions in the system use fields, and a Joliet directory tree. diff -r 6ba826535859 -r bd329fe2476d sys/man/8/ndb --- a/sys/man/8/ndb Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/ndb Thu Apr 12 12:14:14 2012 +0200 @@ -753,7 +753,7 @@ > .EE .LP -Print the names of all systems that boot via PXE. +Print the names of all PCs that boot via PXE. .IP .EX % ndb/query -a bootf /386/9pxeload sys diff -r 6ba826535859 -r bd329fe2476d sys/man/8/plan9.ini --- a/sys/man/8/plan9.ini Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/plan9.ini Thu Apr 12 12:14:14 2012 +0200 @@ -1,15 +1,21 @@ .TH PLAN9.INI 8 .SH NAME -plan9.ini \- configuration file for PCs +plan9.ini \- configuration file primarily for PCs .SH SYNOPSIS .I none .SH DESCRIPTION -When booting Plan 9 on a PC, the DOS program +When booting Plan 9 on a PC, the bootstrap programs described in .IR 9load (8) -first reads a DOS file -containing configuration information from the boot disk. +first read, +via TFTP or a FAT filesystem on the boot disk, +a file containing configuration information. This file, -.BR plan9.ini , +.BI /cfg/pxe/ hex-digits +(TFTP; see +.IR 9load (8)) +or +.B plan9.ini +(FAT), looks like a shell script containing lines of the form .IP .EX @@ -17,16 +23,6 @@ .EE .LP each of which defines a kernel or device parameter. -If -.I 9load -or -.I 9pxeload -loads the kernel over the network instead, -this file will be named -.BI /cfg/pxe/ hex-digits -(see -.IR 9load (8)) -on the local TFTP server. .PP Blank lines and Carriage Returns @@ -53,21 +49,25 @@ Not all elements are relevant to all devices; the relevant values and their defaults are defined below in the description of each device. .PP -The file is used by -.B 9load -and the kernel to configure the hardware available. +The file is used by the bootstrap programs +and the kernel to configure the hardware available, +although nowadays the kernel can usually detect the attached hardware +by itself. The information it contains is also passed to the boot process, and subsequently other programs, as environment variables (see .IR boot (8)). However, values whose names begin with an asterisk -.B * -are used by the kernel and are not converted into environment variables. +.L * +are used by the kernel and are stored in +.L #ec +rather than +.LR #e . .PP The following sections describe how variables are used. .SS ETHERNET -.SS \fLetherX=value\fP +.SS \fLetherX=\fIvalue This defines an Ethernet interface. .IR X , a unique monotonically increasing number beginning at 0, @@ -81,9 +81,10 @@ Almost all cards can be automatically detected. For debugging purposes, automatic probing can be disabled by specifying the line -.BR *noetherprobe= . +.LR *noetherprobe= . +.ig This automatic probing is only done by the kernel, not by -.IR 9load (8). +the bootstrap programs. Thus, if you want to load a kernel over the Ethernet, you need to specify an .B ether0 @@ -91,6 +92,7 @@ .I 9load can find the Ethernet card, even if the kernel would have automatically detected it. +.. .PP Some cards are software configurable and do not require all options. Unspecified options default to the factory defaults. @@ -98,7 +100,6 @@ Known .IR TYPE s are -.\" .TF ga620 .TF vt6102 .PD .TP @@ -122,6 +123,7 @@ Alteon Acenic fiber and copper cards, the DEC DEGPA-SA and the SGI Acenic. Completely configurable. +Can't boot through these due to enormous firmware loads. .TP .B dp83820 National Semiconductor DP83820-based Gigabit Ethernet adapters, notably @@ -140,9 +142,6 @@ .B i82598 The Intel 8259[89] 10-Gigabit Ethernet PCI-Express controllers. Completely configurable. -Can't boot through these due to lack of a -.I 9load -driver. .TP .B i82557 Cards using the Intel 8255[789] Fast Ethernet PCI Bus LAN Controller such as the @@ -191,6 +190,9 @@ .B vt6102 The VIA VT6102 Fast Ethernet Controller (Rhine II). .TP +.B vt6105m +The VIA VT6105M Fast Ethernet Controller (Rhine III). +.TP .B smc91cxx SMC 91cXX chip-based PCMCIA adapters, notably the SMC EtherEZ card. .TP @@ -409,7 +411,8 @@ (S)ATA controllers are autodetected. .SS \fLusbX=type=uhci\fP .SS \fLusbX=type=ohci\fP -This specifies the settings for a USB UHCI or OHCI controller. +.SS \fLusbX=type=ehci\fP +This specifies the settings for a USB UHCI, OHCI or EHCI controller. Like the Ethernet controllers, USB controllers are autodetected after scanning for the ones listed in .IR plan9.ini . @@ -419,7 +422,7 @@ Also like the Ethernet controllers, USB autoprobing can be disabled by specifying the line .BR *nousbprobe= . -.SS \fLscsiX=value\fP +.SS \fLscsiX=\fIvalue This defines a SCSI interface which cannot be automatically detected by the kernel. .PP @@ -466,8 +469,8 @@ .I slot to use as a root device for bootstrapping. .SS AUDIO -.SS \fLaudioX=value\fP -This defines a sound interface. +.SS \fLaudioX=\fIvalue +This defines a pre-USB sound interface. .PP Known types are .TF ess1688 @@ -515,7 +518,7 @@ The line .B serial=type=com can be used to specify settings for a PCMCIA modem. -.SS \fLmouseport=value\fP +.SS \fLmouseport=\fIvalue This specifies where the mouse is attached. .I Value can be @@ -532,13 +535,13 @@ .TP .B 1 for COM2 -.SS \fLmodemport=value\fP +.SS \fLmodemport=\fIvalue Picks the UART line to call out on. This is used when connecting to a file server over an async line. .I Value is the number of the port. -.SS \fLconsole=value params\fP +.SS \fLconsole=\fIvalue params This is used to specify the console device. The default value is @@ -581,7 +584,7 @@ .SS "PC CARD" .SS \fLpccard0=disabled\fP Disable probing for and automatic configuration of PC card controllers. -.SS \fLpcmciaX=type=XXX irq=value\fP +.SS \fLpcmciaX=type=XXX irq=\fIirq If the default IRQ for the PCMCIA is correct, this entry can be omitted. The value of @@ -589,242 +592,10 @@ is ignored. .SS \fLpcmcia0=disabled\fP Disable probing for and automatic configuration of PCMCIA controllers. -.SS BOOTING -.SS \fLbootfile=value\fP -This is used to direct the actions of -.IR 9load (8) -by naming the device and file from which to load the kernel. -.SS \fLrootdir=dir\fP -.SS \fLrootspec=spec\fP -These are used by -.IR 9load (8) -to identify the directory -.I dir -to make the root directory for the kernel, and the -file system specifier -.I spec -(see -.B mount -in -.IR bind (2)) -on which it can be found. -These are usually used to test variant file systems for distributions, etc. -.SS \fLbootargs=value\fP -The value of this variable is passed to -.IR boot (8) -by the kernel as the name of the root file system. -It is typically used to specify additional arguments to -pass to -.IR kfs (4) -or -.IR ipconfig (8). -For example, if the system is to run from a local -.IR kfs (4) -partition, the definition might read -.BR bootargs=local!#S/sdC0/fs . -See -.IR boot (8) -for more. -.SS \fLnobootprompt=value\fP -Suppress the -.L "root from" -prompt and use -.I value -as the answer instead. -.SS \fLuser=value\fP -Suppress the -.L "user" -prompt and use -.I value -as the answer instead. -.SS \fLdebugfactotum=\fP -Causes -.IR boot (8) -to start -.I factotum -with the -.B -p -option, so that it can be debugged. -.SS \fLfactotumopts=options\fP -Causes -.IR boot (8) -to start -.I factotum -with the given -.IR options , -which must be a single word (i.e., contain no whitespace). -.SS \fLventi=value\fP -When booting from a local fossil server backed by a local -or remote venti server, -this variable specifies how to establish the connection to the -venti server. -See -.IR boot (8) -for more. -.SS \fLcfs=value\fP -This gives the name of the file holding the disk partition -for the cache file system, -.IR cfs (4). -Extending the -.B bootargs -example, one would write -.BR cfs=#S/sdC0/cache . -.SS \fLbootdisk=value\fP -This deprecated variable was used to specify the disk used by -the cache file system and other disk-resident services. -It is superseded by -.B bootargs -and -.BR cfs . -.SS \fLpartition=value\fP -This defines the partition table -.IR 9load (8) -will examine to find disk partitioning information. -By default, a partition table in a Plan 9 partition -is consulted; if no such table is found, an old-Plan 9 -partition table on the next-to-last or last sector -of the disk is consulted. -A value of -.B new -consults only the first table, -.B old -only the second. -.SS \fLreadparts=\fP -Causes -.I boot -to look for MBR and Plan 9 partition tables on all -.IR sd (3) -disks, even before -.I factotum -is started, so NVRAM, for example, may be found. -On PCs, -.I 9load -normally does this, -so this variable is intended for other architectures. -.SS \fLfs=a.b.c.d\fP -.SS \fLauth=a.b.c.d\fP -These specify the IP address of the file and authentication server -to use when mounting a network-provided root file system. -They are used only if the addresses cannot be determined via DHCP. -.SS PROCESSOR -.SS \fL*norealmode=\fP -The PC kernel switches the processor to 16-bit real mode -to run BIOS interrupts, for example to find the memory map or to enable VESA. -This variable disables such switches. -.SS \fL*noe820scan=\fP -When available, the PC kernel uses the BIOS E820 memory map -to size memory. This variable disables the scan. -.SS \fL*maxmem=value\fP -This defines the maximum physical address that the system will scan when sizing memory. -By default the PC operating system will scan up to 3.75 gigabytes -(0xF0000000, the base of kernel virtual address space), but setting -.B *maxmem -will limit the scan. -.B *maxmem -must be less than 3.75 gigabytes. -This variable is not consulted if using the E820 memory map. -.SS \fL*kernelpercent=value\fP -This defines what percentage of available memory is reserved for the kernel allocation pool. -The remainder is left for user processes. The default -.I value -is -.B 30 -on CPU servers, -.B 60 -on terminals with less than 16MB of memory, -and -.B 40 -on terminals with memories of 16MB or more. -Terminals use more kernel memory because -.IR draw (3) -maintains its graphic images in kernel memory. -This deprecated option is rarely necessary in newer kernels. -.SS \fL*nomce=value\fP -If machine check exceptions are supported by the processor, -then they are enabled by default. -Setting this variable to -.B 1 -causes them to be disabled even when available. -.SS \fL*nomp=\fP -A multiprocessor machine will enable all processors by default. -Setting -.B *nomp -restricts the kernel to starting only one processor and using the -traditional interrupt controller. -.SS \fL*ncpu=value\fP -Setting -.B *ncpu -restricts the kernel to starting at most -.I value -processors. -.SS \fL*pcimaxbno=value\fP -This puts a limit on the maximum bus number probed -on a PCI bus (default 7). -For example, a -.I value -of 1 should suffice on a 'standard' motherboard with an AGP slot. -This, and -.B *pcimaxdno -below are rarely used and only on troublesome or suspect hardware. -.SS \fL*pcimaxdno=value\fP -This puts a limit on the maximum device number probed -on a PCI bus (default 31). -.SS \fL*nopcirouting=\fP -Disable pci routing during boot. May solve interrupt routing -problems on certain machines. -.SS \fL*nodumpstack=\fP -Disable printing a stack dump on panic. -Useful if there is only a limited cga screen available, -otherwise the textual information about the panic may scroll off. -.\" .SS \fL*nobios=\fP -.\" what does this do? something with pci -.SS \fLioexclude=value\fP -Specifies a list of ranges of I/O ports to exclude from use by drivers. -Ranges are inclusive on both ends and separated by commas. -For example: -.EX - ioexclude=0x330-0x337,0x430-0x43F -.EE -.SS \fLumbexclude=value\fP -Specifies a list of ranges of UMB to exclude from use by drivers. -Ranges are inclusive on both ends and separated by commas. -For example: -.EX - umbexclude=0xD1800-0xD3FFF -.EE -.SS \fLapm0=\fP -This enables the ``advanced power management'' interface -as described in -.IR apm (3) -and -.IR apm (8). -The main feature of the interface is the ability to watch -battery life (see -.IR stats (8)). -It is not on by default because it causes problems on some laptops. -.SS VIDEO -.SS \fLmonitor=value\fP -.SS \fLvgasize=value\fP -These are used not by the kernel but by -.I termrc -(see -.IR cpurc (8)) -when starting -.IR vga (8). -.SS \fL*dpms=value\fP -This is used to specify the screen blanking behavior of the MGA4xx -video driver. -Values are -.BR standby , -.BR suspend , -and -.BR off . -The first two specify differing levels of power saving; -the third turns the monitor off completely. .SS NVRAM -.SS \fLnvram=file\fP -.SS \fLnvrlen=length\fP -.SS \fLnvroff=offset\fP +.SS \fLnvram=\fIfile\fP +.SS \fLnvrlen=\fIlength\fP +.SS \fLnvroff=\fIoffset\fP This is used to specify an nvram device and optionally the length of the ram and read/write offset to use. These values are consulted by @@ -835,7 +606,7 @@ .IR secstore (1) password for use by .IR factotum (4). -.SS \fLnvr=value\fP +.SS \fLnvr=\fIvalue This is used by the WORM file server kernel to locate a file holding information to configure the file system. The file cannot live on a SCSI disk. @@ -856,6 +627,239 @@ .I unit is the numeric unit id. This variant syntax is a vestige of the file server kernel's origins. +.SS BOOTING +.SS \fLbootfile=\fIvalue +This is used to direct the actions of +the bootstrap programs +by naming the device and file from which to load the kernel. +.SS \fLrootdir=\fIdir +.SS \fLrootspec=\fIspec +These are used by the bootstrap programs +to identify the directory +.I dir +to make the root directory for the kernel, and the +file system specifier +.I spec +(see +.B mount +in +.IR bind (2)) +on which it can be found. +These are usually used to test variant file systems for distributions, etc. +.SS \fLbootargs=\fIargs +The value of this variable is passed to +.IR boot (8) +by the kernel as the name of the root file system. +It is typically used to specify additional arguments to +pass to +.IR kfs (4) +or +.IR ipconfig (8). +For example, if the system is to run from a local +.IR kfs (4) +partition, the definition might read +.BR bootargs=local!#S/sdC0/fs . +See +.IR boot (8) +for more. +.SS \fLnobootprompt=\fIroot +Suppress the +.L "root from" +prompt and use +.I root +as the answer instead. +.SS \fLuser=\fIuser +Suppress the +.L "user" +prompt and use +.I user +as the answer instead. +.SS \fLdebugfactotum=\fP +Causes +.IR boot (8) +to start +.I factotum +with the +.B -p +option, so that it can be debugged. +.SS \fLfactotumopts=\fIoptions +Causes +.IR boot (8) +to start +.I factotum +with the given +.IR options , +which must be a single word (i.e., contain no whitespace). +.SS \fLventi=\fIvalue +When booting from a local fossil server backed by a local +or remote venti server, +this variable specifies how to establish the connection to the +venti server. +See +.IR boot (8) +for more. +.SS \fLcfs=\fIpartition +This names the file holding the disk partition +for the cache file system, +.IR cfs (4). +Extending the +.B bootargs +example, one would write +.BR cfs=#S/sdC0/cache . +.SS \fLbootdisk=\fIvalue +This deprecated variable was used to specify the disk used by +the cache file system and other disk-resident services. +It is superseded by +.B bootargs +and +.BR cfs . +.SS \fLpartition=\fIvalue +This defines the partition table +.IR 9load (8) +will examine to find disk partitioning information. +By default, a partition table in a Plan 9 partition +is consulted; if no such table is found, an old-Plan 9 +partition table on the next-to-last or last sector +of the disk is consulted. +A value of +.B new +consults only the first table, +.B old +only the second. +.SS \fLreadparts=\fP +Causes +.IR boot (8) +to look for MBR and Plan 9 partition tables on all +.IR sd (3) +disks, even before +.I factotum +is started, so NVRAM, for example, may be found. +On PCs, +.I 9load +(but not +.IR 9load ) +normally does this and passes the partitions found in +.BR #ec/sd\fICn\fPpart . +.SS \fLfs=\fIa.b.c.d +.SS \fLauth=\fIa.b.c.d +These specify the IP address of the file and authentication server +to use when mounting a network-provided root file system. +They are used only if the addresses cannot be determined via DHCP. +.SS PROCESSOR +.SS \fL*norealmode=\fP +The PC kernel switches the processor to 16-bit real mode +to run BIOS interrupts, for example to find the memory map or to enable VESA. +This variable disables such switches. +.SS \fL*noe820scan=\fP +When available, the PC kernel uses the BIOS E820 memory map +to size memory. This variable disables the scan. +.SS \fL*maxmem=\fIaddress +This defines the maximum physical address that the system will scan when sizing memory. +By default the PC operating system will scan up to 3.75 gigabytes +(0xF0000000, the base of kernel virtual address space), but setting +.B *maxmem +will limit the scan. +.B *maxmem +must be less than 3.75 gigabytes. +This variable is not consulted if using the E820 memory map. +.SS \fL*kernelpercent=\fIpercent +This defines the percentage of available memory reserved for the kernel allocation pool. +The remainder is left for user processes. The default +.I percent +is +.B 30 +on CPU servers, +.B 60 +on terminals with less than 16MB of memory, +and +.B 40 +on terminals with memories of 16MB or more. +Terminals use more kernel memory because +.IR draw (3) +maintains its graphic images in kernel memory. +This deprecated option is rarely necessary in newer kernels. +.SS \fL*nomce=\fIvalue +If machine check exceptions are supported by the processor, +then they are enabled by default. +Setting this variable to +.B 1 +causes them to be disabled even when available. +.SS \fL*nomp=\fP +A multiprocessor machine will enable all processors by default. +Setting +.B *nomp +restricts the kernel to starting only one processor and using the +traditional interrupt controller. +.SS \fL*ncpu=\fIcpus\fP +Setting +.B *ncpu +restricts the kernel to starting at most +.I cpus +processors. +.SS \fL*pcimaxbno=\fIbno\fP +Limits the maximum bus number probed +on a PCI bus (default 7). +For example, a +.I bno +of 1 should suffice on a 'standard' motherboard with an AGP slot. +This, and +.B *pcimaxdno +below are rarely used and only on troublesome or suspect hardware. +.SS \fL*pcimaxdno=\fIdno\fP +Limits the maximum device number probed +on a PCI bus (default 31). +.SS \fL*nopcirouting=\fP +Disable pci routing during boot. May solve interrupt routing +problems on certain machines. +.SS \fL*nodumpstack=\fP +Disable printing a stack dump on panic. +Useful if there is only a limited cga screen available, +otherwise the textual information about the panic may scroll off. +.\" .SS \fL*nobios=\fP +.\" what does this do? something with pci +.SS \fLioexclude=\fIrange\fP +Specifies a list of ranges of I/O ports to exclude from use by drivers. +Ranges are inclusive on both ends and separated by commas. +For example: +.EX + ioexclude=0x330-0x337,0x430-0x43F +.EE +.SS \fLumbexclude=\fIrange\fP +Specifies a list of ranges of UMB to exclude from use by drivers. +Ranges are inclusive on both ends and separated by commas. +For example: +.EX + umbexclude=0xD1800-0xD3FFF +.EE +.SS \fLapm0=\fP +This enables the ``advanced power management'' interface +as described in +.IR apm (3) +and +.IR apm (8). +The main feature of the interface is the ability to watch +battery life (see +.IR stats (8)). +It is not on by default because it causes problems on some laptops. +.SS VIDEO +.SS \fLmonitor=\fImonitor +.SS \fLvgasize=\fIx\fPx\fIy\fPx\fId +These are used not by the kernel but by +.I termrc +(see +.IR cpurc (8)) +when starting +.IR vga (8). +.SS \fL*dpms=\fIvalue +This is used to specify the screen blanking behavior of the MGA4xx +video driver. +Values are +.BR standby , +.BR suspend , +and +.BR off . +The first two specify differing levels of power saving; +the third turns the monitor off completely. .SS Multiple Configurations .PP A diff -r 6ba826535859 -r bd329fe2476d sys/man/8/rsa --- a/sys/man/8/rsa Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/man/8/rsa Thu Apr 12 12:14:14 2012 +0200 @@ -2,7 +2,7 @@ .SH NAME rsagen, rsafill, asn12rsa, rsa2pub, rsa2ssh, rsa2x509 \- generate and format rsa keys .SH SYNOPSIS -.B rsagen +.B auth/rsagen [ .B -b .I nbits @@ -12,12 +12,12 @@ .I tag ] .PP -.B rsafill +.B auth/rsafill [ .I file ] .PP -.B asn12rsa +.B auth/asn12rsa [ .B -t .I tag @@ -26,17 +26,17 @@ .I file ] .PP -.B rsa2pub +.B auth/rsa2pub [ .I file ] .PP -.B rsa2ssh +.B auth/rsa2ssh [ .I file ] .PP -.B rsa2x509 +.B auth/rsa2x509 [ .B -e .I expiretime @@ -86,10 +86,10 @@ .PD .LP All the numbers are in hexadecimal except -.I size , +.IR size , which is decimal. An RSA public key omits the attributes beginning with -.L ! . +.LR ! . A key may have other attributes as well (for example, a .B service attribute identifying how this key is typically used), @@ -235,8 +235,9 @@ .SH SOURCE .B /sys/src/cmd/auth .SH "SEE ALSO +.IR ssh (1), .IR factotum (4), -.IR pem (8), -.IR ssh (1) +.IR dsa (8), +.IR pem (8) .SH BUGS There are too many key formats. diff -r 6ba826535859 -r bd329fe2476d sys/src/9/pc/ether8169.c --- a/sys/src/9/pc/ether8169.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/pc/ether8169.c Thu Apr 12 12:14:14 2012 +0200 @@ -218,7 +218,7 @@ */ enum { /* Ring sizes (<= 1024) */ Ntd = 64, /* Transmit Ring */ - Nrd = 256, /* Receive Ring */ + Nrd = 1024, /* Receive Ring */ Mtu = ETHERMAXTU, Mps = ROUNDUP(ETHERMAXTU+4, 128), @@ -516,6 +516,7 @@ } if(csr32r(ctlr, Dtccr) & Cmd) error(Eio); + dtcc = ctlr->dtcc; edev->oerrs = dtcc->txer; @@ -844,6 +845,7 @@ qunlock(&ctlr->alock); error(Enomem); } + memset(ctlr->dtcc, 0, sizeof(Dtcc)); /* paranoia */ rtl8169init(edev); ctlr->init = 1; } @@ -1211,7 +1213,7 @@ edev->port = ctlr->port; edev->irq = ctlr->pcidev->intl; edev->tbdf = ctlr->pcidev->tbdf; - edev->mbps = 100; + edev->mbps = 1000; edev->maxmtu = Mtu; /* diff -r 6ba826535859 -r bd329fe2476d sys/src/9/pc/kbd.c --- a/sys/src/9/pc/kbd.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/pc/kbd.c Thu Apr 12 12:14:14 2012 +0200 @@ -661,6 +661,10 @@ /* disable mouse */ if (outbyte(Cmd, 0x60) < 0 || outbyte(Data, ccc) < 0) print("i8042: kbdinit mouse disable failed\n"); + + /* set typematic rate/delay (0 -> delay=250ms & rate=30cps) */ + if(outbyte(Data, 0xf3) < 0 || outbyte(Data, 0) < 0) + print("i8042: kbdinit set typematic rate failed\n"); } void diff -r 6ba826535859 -r bd329fe2476d sys/src/9/pc/memory.c --- a/sys/src/9/pc/memory.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/pc/memory.c Thu Apr 12 12:14:14 2012 +0200 @@ -53,13 +53,6 @@ &mapupa[nelem(mapupa)-1], }; -static Map xmapupa[16]; -static RMap xrmapupa = { - "unbacked physical memory", - xmapupa, - &xmapupa[nelem(xmapupa)-1], -}; - static Map mapram[16]; static RMap rmapram = { "physical memory", @@ -262,7 +255,7 @@ static void umbscan(void) { - uchar *p; + uchar o[2], *p; /* * Scan the Upper Memory Blocks (0xA0000->0xF0000) for pieces @@ -281,31 +274,31 @@ p = KADDR(0xD0000); while(p < (uchar*)KADDR(0xE0000)){ /* - * Test for 0x55 0xAA before poking obtrusively, - * some machines (e.g. Thinkpad X20) seem to map - * something dynamic here (cardbus?) causing weird - * problems if it is changed. + * Check for the ROM signature, skip if valid. */ if(p[0] == 0x55 && p[1] == 0xAA){ p += p[2]*512; continue; } + /* + * Is it writeable? If yes, then stick it in + * the UMB device memory map. A floating bus will + * return 0xff, so add that to the map of the + * UMB space available for allocation. + * If it is neither of those, ignore it. + */ + o[0] = p[0]; p[0] = 0xCC; + o[1] = p[2*KB-1]; p[2*KB-1] = 0xCC; - if(p[0] != 0xCC || p[2*KB-1] != 0xCC){ - p[0] = 0x55; - p[1] = 0xAA; - p[2] = 4; - if(p[0] == 0x55 && p[1] == 0xAA){ - p += p[2]*512; - continue; - } - if(p[0] == 0xFF && p[1] == 0xFF) - mapfree(&rmapumb, PADDR(p), 2*KB); + if(p[0] == 0xCC && p[2*KB-1] == 0xCC){ + p[0] = o[0]; + p[2*KB-1] = o[1]; + mapfree(&rmapumbrw, PADDR(p), 2*KB); } - else - mapfree(&rmapumbrw, PADDR(p), 2*KB); + else if(p[0] == 0xFF && p[1] == 0xFF) + mapfree(&rmapumb, PADDR(p), 2*KB); p += 2*KB; } @@ -821,7 +814,7 @@ umbrwmalloc(ulong addr, int size, int align) { ulong a; - uchar *p; + uchar o[2], *p; if(a = mapalloc(&rmapumbrw, addr, size, align)) return(ulong)KADDR(a); @@ -833,10 +826,15 @@ if((a = umbmalloc(addr, size, align)) == 0) return 0; p = (uchar*)a; + o[0] = p[0]; p[0] = 0xCC; + o[1] = p[size-1]; p[size-1] = 0xCC; - if(p[0] == 0xCC && p[size-1] == 0xCC) + if(p[0] == 0xCC && p[size-1] == 0xCC){ + p[0] = o[0]; + p[size-1] = o[1]; return a; + } umbfree(a, size); return 0; diff -r 6ba826535859 -r bd329fe2476d sys/src/9/pc/usbohci.c --- a/sys/src/9/pc/usbohci.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/pc/usbohci.c Thu Apr 12 12:14:14 2012 +0200 @@ -1252,7 +1252,7 @@ static void interrupt(Ureg *, void *arg) { - Td *td, *ntd, *td0; + Td *td, *ntd; Hci *hp; Ctlr *ctlr; ulong status, curred; @@ -1261,36 +1261,33 @@ hp = arg; ctlr = hp->aux; ilock(ctlr); - status = ctlr->ohci->intrsts; - status &= ctlr->ohci->intrenable; + ctlr->ohci->intrdisable = Mie; + coherence(); + status = ctlr->ohci->intrsts & ctlr->ohci->intrenable; status &= Oc|Rhsc|Fno|Ue|Rd|Sf|Wdh|So; frno = TRUNC(ctlr->ohci->fmnumber, Ntdframes); - if((status & Wdh) != 0){ + if(status & Wdh){ /* lsb of donehead has bit to flag other intrs. */ td = pa2ptr(ctlr->hcca->donehead & ~0xF); - }else - td = nil; - td0 = td; - for(i = 0; td != nil && i < 1024; i++){ - if(0)ddprint("ohci tdinterrupt: td %#p\n", td); - ntd = pa2ptr(td->nexttd & ~0xF); - td->nexttd = 0; - if(td->ep == nil || td->io == nil) - panic("ohci: interrupt: ep %#p io %#p", td->ep, td->io); - ohciinterrupts[td->ep->ttype]++; - if(td->ep->ttype == Tiso) - isointerrupt(ctlr, td->ep, td->io, td, frno); - else - qhinterrupt(ctlr, td->ep, td->io, td, frno); - td = ntd; + for(i = 0; td != nil && i < 1024; i++){ + if(0)ddprint("ohci tdinterrupt: td %#p\n", td); + ntd = pa2ptr(td->nexttd & ~0xF); + td->nexttd = 0; + if(td->ep == nil || td->io == nil) + panic("ohci: interrupt: ep %#p io %#p", + td->ep, td->io); + ohciinterrupts[td->ep->ttype]++; + if(td->ep->ttype == Tiso) + isointerrupt(ctlr, td->ep, td->io, td, frno); + else + qhinterrupt(ctlr, td->ep, td->io, td, frno); + td = ntd; + } + if(i >= 1024) + print("ohci: bug: more than 1024 done Tds?\n"); + ctlr->hcca->donehead = 0; } - if(i == 1024) - print("ohci: bug: more than 1024 done Tds?\n"); - - if(pa2ptr(ctlr->hcca->donehead & ~0xF) != td0) - print("ohci: bug: donehead changed before ack\n"); - ctlr->hcca->donehead = 0; ctlr->ohci->intrsts = status; status &= ~Wdh; @@ -1313,6 +1310,7 @@ } if(status != 0) print("ohci interrupt: unhandled sts 0x%.8lux\n", status); + ctlr->ohci->intrenable = Mie | Wdh | Ue; iunlock(ctlr); } @@ -2496,8 +2494,9 @@ ctlr = hp->aux; ilock(ctlr); - ctlr->ohci->intrenable = 0; + ctlr->ohci->intrdisable = Mie; ctlr->ohci->control = 0; + coherence(); delay(100); iunlock(ctlr); } diff -r 6ba826535859 -r bd329fe2476d sys/src/9/pc/vgavmware.c --- a/sys/src/9/pc/vgavmware.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/pc/vgavmware.c Thu Apr 12 12:14:14 2012 +0200 @@ -176,7 +176,11 @@ if(p == nil) error(err[0]? err: "no vmware vga card found"); - vgalinearaddr(scr, vmrd(vm, Rfbstart), vmrd(vm, Rfbsize)); + /* + * empirically, 2*fbsize enables 1280x1024x32, not just 1024x768x32. + * is fbsize in bytes or pixels? + */ + vgalinearaddr(scr, vmrd(vm, Rfbstart), 2*vmrd(vm, Rfbsize)); if(scr->apsize) addvgaseg("vmwarescreen", scr->paddr, scr->apsize); } diff -r 6ba826535859 -r bd329fe2476d sys/src/9/port/devssl.c --- a/sys/src/9/port/devssl.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/port/devssl.c Thu Apr 12 12:14:14 2012 +0200 @@ -1055,6 +1055,7 @@ char *p, *np, *e, buf[128]; uchar *x; + x = nil; s = dstate[CONV(c->qid)]; if(s == 0) panic("sslwrite"); @@ -1130,6 +1131,10 @@ if(p) *p++ = 0; + if(waserror()){ + free(x); + nexterror(); + } if(strcmp(buf, "fd") == 0){ s->c = buftochan(p); @@ -1149,9 +1154,8 @@ s->state = Sclear; s->maxpad = s->max = (1<<15) - s->diglen - 1; - if(strcmp(p, "clear") == 0){ - goto out; - } + if(strcmp(p, "clear") == 0) + goto outx; if(s->in.secret && s->out.secret == 0) setsecret(&s->out, s->in.secret, s->in.slen); @@ -1192,17 +1196,21 @@ m = (strlen(p)*3)/2; x = smalloc(m); t = dec64(x, m, p, strlen(p)); + if(t <= 0) + error(Ebadarg); setsecret(&s->in, x, t); - free(x); } else if(strcmp(buf, "secretout") == 0 && p != 0) { m = (strlen(p)*3)/2 + 1; x = smalloc(m); t = dec64(x, m, p, strlen(p)); + if(t <= 0) + error(Ebadarg); setsecret(&s->out, x, t); - free(x); } else error(Ebadarg); - +outx: + free(x); + poperror(); out: qunlock(&s->in.ctlq); qunlock(&s->out.q); diff -r 6ba826535859 -r bd329fe2476d sys/src/9/port/portclock.c --- a/sys/src/9/port/portclock.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/9/port/portclock.c Thu Apr 12 12:14:14 2012 +0200 @@ -7,6 +7,10 @@ #include "ureg.h" #include "../port/error.h" +enum { + Maxtimerloops = 20*1000, +}; + struct Timers { Lock; @@ -14,6 +18,7 @@ }; static Timers timers[MAXMACH]; +static int timersinited; ulong intrcount[MAXMACH]; ulong fcallcount[MAXMACH]; @@ -166,15 +171,18 @@ Timer *t; Timers *tt; uvlong when, now; - int callhzclock; + int count, callhzclock; static int sofar; intrcount[m->machno]++; callhzclock = 0; tt = &timers[m->machno]; now = fastticks(nil); + if(now == 0) + panic("timerintr: zero fastticks()"); ilock(tt); - while(t = tt->head){ + count = Maxtimerloops; + while((t = tt->head) != nil){ /* * No need to ilock t here: any manipulation of t * requires tdel(t) and this must be done with a @@ -201,6 +209,12 @@ ilock(tt); if(t->tmode == Tperiodic) tadd(tt, t); + if (--count <= 0) { + count = Maxtimerloops; + iprint("timerintr: probably stuck in while loop; " + "scrutinise clock.c or use faster cycle " + "counter\n"); + } } iunlock(tt); } @@ -213,6 +227,7 @@ /* * T->tf == nil means the HZ clock for this processor. */ + timersinited = 1; todinit(); t = malloc(sizeof(*t)); if(t == nil) @@ -230,6 +245,8 @@ Timer *nt; uvlong when; + if(!timersinited) + panic("addclock0link: timersinit not called yet"); /* Synchronize to hztimer if ms is 0 */ nt = malloc(sizeof(Timer)); if(nt == nil) diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5a/a.h --- a/sys/src/cmd/5a/a.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5a/a.h Thu Apr 12 12:14:14 2012 +0200 @@ -175,9 +175,5 @@ int mycreat(char*, int); int systemtype(int); int pathchar(void); -char* mygetwd(char*, int); -int myexec(char*, char*[]); -int mydup(int, int); int myfork(void); -int mypipe(int*); void* mysbrk(ulong); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5a/lex.c --- a/sys/src/cmd/5a/lex.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5a/lex.c Thu Apr 12 12:14:14 2012 +0200 @@ -311,6 +311,11 @@ "MOVWD", LTYPE3, AMOVWD, "MOVWF", LTYPE3, AMOVWF, + "LDREX", LTYPE3, ALDREX, + "LDREXD", LTYPE3, ALDREXD, + "STREX", LTYPE9, ASTREX, + "STREXD", LTYPE9, ASTREXD, + /* "ABSF", LTYPEI, AABSF, "ABSD", LTYPEI, AABSD, @@ -326,6 +331,8 @@ "NRMD", LTYPEI, ANRMD, */ + "SQRTF", LTYPEI, ASQRTF, + "SQRTD", LTYPEI, ASQRTD, "CMPF", LTYPEL, ACMPF, "CMPD", LTYPEL, ACMPD, "ADDF", LTYPEK, AADDF, @@ -417,9 +424,9 @@ } pathname = allocn(pathname, 0, 100); - if(mygetwd(pathname, 99) == 0) { + if(getwd(pathname, 99) == 0) { pathname = allocn(pathname, 100, 900); - if(mygetwd(pathname, 999) == 0) + if(getwd(pathname, 999) == 0) strcpy(pathname, "/???"); } } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5a/mkfile --- a/sys/src/cmd/5a/mkfile Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5a/mkfile Thu Apr 12 12:14:14 2012 +0200 @@ -16,4 +16,4 @@ < /sys/src/cmd/mkone YFLAGS=-D1 -d -lex.$O: ../cc/macbody ../cc/lexbody ../cc/compat +lex.$O: ../cc/macbody ../cc/lexbody diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/5.out.h --- a/sys/src/cmd/5c/5.out.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/5.out.h Thu Apr 12 12:14:14 2012 +0200 @@ -25,6 +25,7 @@ #define NFREG 8 #define FREGRET 0 #define FREGEXT 7 +#define FREGTMP 15 /* compiler allocates register variables F0 up */ /* compiler allocates external registers F7 down */ @@ -92,6 +93,8 @@ AMULD, ADIVF, ADIVD, +// ASQRTF, +// ASQRTD, ASRL, ASRA, @@ -143,6 +146,16 @@ ASIGNAME, + /* moved here to preserve values of older identifiers */ + ASQRTF, + ASQRTD, + + ALDREX, + ASTREX, + + ALDREXD, + ASTREXD, + ALAST, }; @@ -173,7 +186,8 @@ #define D_SHIFT (D_NONE+19) #define D_FPCR (D_NONE+20) -#define D_REGREG (D_NONE+21) +#define D_REGREG (D_NONE+21) +#define D_ADDR (D_NONE+22) /* name */ #define D_EXTERN (D_NONE+3) diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/enam.c --- a/sys/src/cmd/5c/enam.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/enam.c Thu Apr 12 12:14:14 2012 +0200 @@ -94,5 +94,11 @@ "BXRET", "DWORD", "SIGNAME", + "SQRTF", + "SQRTD", + "LDREX", + "STREX", + "LDREXD", + "STREXD", "LAST", }; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/gc.h --- a/sys/src/cmd/5c/gc.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/gc.h Thu Apr 12 12:14:14 2012 +0200 @@ -3,7 +3,7 @@ /* * 5c/arm - * Arm 7500 + * Arm */ #define SZ_CHAR 1 #define SZ_SHORT 2 diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/peep.c --- a/sys/src/cmd/5c/peep.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/peep.c Thu Apr 12 12:14:14 2012 +0200 @@ -1069,7 +1069,7 @@ if(v->type == D_REG) { if(v->reg <= REGEXT && v->reg > exregoffset) return 2; - if(v->reg == REGARG) + if(v->reg == (uchar)REGARG) return 2; } if(v->type == D_FREG) @@ -1087,7 +1087,7 @@ case ATEXT: /* funny */ if(v->type == D_REG) - if(v->reg == REGARG) + if(v->reg == (uchar)REGARG) return 3; return 0; } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/reg.c --- a/sys/src/cmd/5c/reg.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/reg.c Thu Apr 12 12:14:14 2012 +0200 @@ -1125,7 +1125,7 @@ int BtoR(long b) { - b &= 0x01fcL; + b &= 0x01fcL; // excluded R9 and R10 for m and g if(b == 0) return 0; return bitno(b); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5c/swt.c --- a/sys/src/cmd/5c/swt.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5c/swt.c Thu Apr 12 12:14:14 2012 +0200 @@ -579,7 +579,7 @@ w = packflg; break; - case Ael1: /* initial allign of struct element */ + case Ael1: /* initial align of struct element */ for(v=t; v->etype==TARRAY; v=v->link) ; w = ewidth[v->etype]; @@ -600,7 +600,7 @@ } break; - case Aarg1: /* initial allign of parameter */ + case Aarg1: /* initial align of parameter */ w = ewidth[t->etype]; if(w <= 0 || w >= SZ_LONG) { w = SZ_LONG; @@ -614,7 +614,7 @@ w = SZ_LONG; break; - case Aaut3: /* total allign of automatic */ + case Aaut3: /* total align of automatic */ o = align(o, t, Ael2); o = align(o, t, Ael1); w = SZ_LONG; /* because of a pun in cc/dcl.c:contig() */ diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/5l/obj.c --- a/sys/src/cmd/5l/obj.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/5l/obj.c Thu Apr 12 12:14:14 2012 +0200 @@ -1229,6 +1229,8 @@ s->value = n*4; } +static int brcond[] = {ABEQ, ABNE, ABCS, ABCC, ABMI, ABPL, ABVS, ABVC, ABHI, ABLS, ABGE, ABLT, ABGT, ABLE}; + void doprof2(void) { @@ -1283,7 +1285,7 @@ } /* - * BL profin, R2 + * BL profin */ q = prg(); q->line = p->line; @@ -1323,6 +1325,7 @@ p->link = q; p = q; } + /* * RET */ @@ -1330,21 +1333,46 @@ q->as = ARET; q->from = p->from; q->to = p->to; + q->cond = p->cond; q->link = p->link; + q->reg = p->reg; p->link = q; - /* - * BL profout - */ - p->as = ABL; - p->from = zprg.from; - p->to = zprg.to; - p->to.type = D_BRANCH; - p->cond = ps4; - p->to.sym = s4; + if(p->scond != 14) { + q = prg(); + q->as = ABL; + q->from = zprg.from; + q->to = zprg.to; + q->to.type = D_BRANCH; + q->cond = ps4; + q->to.sym = s4; + q->link = p->link; + p->link = q; - p = q; + p->as = brcond[p->scond^1]; /* complement */ + p->scond = 14; + p->from = zprg.from; + p->to = zprg.to; + p->to.type = D_BRANCH; + p->cond = q->link->link; /* successor of RET */ + p->to.offset = q->link->link->pc; + p = q->link->link; + } else { + + /* + * BL profout + */ + p->as = ABL; + p->from = zprg.from; + p->to = zprg.to; + p->to.type = D_BRANCH; + p->cond = ps4; + p->to.sym = s4; + p->scond = 14; + + p = q; + } continue; } } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/bind.c --- a/sys/src/cmd/bind.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/bind.c Thu Apr 12 12:14:14 2012 +0200 @@ -47,6 +47,6 @@ void usage(void) { - fprint(2, "usage: bind [-b|-a|-c|-bc|-ac] new old\n"); + fprint(2, "usage: bind [-q] [-b|-a|-c|-bc|-ac] new old\n"); exits("usage"); } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/disk/9660/boot.c --- a/sys/src/cmd/disk/9660/boot.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/disk/9660/boot.c Thu Apr 12 12:14:14 2012 +0200 @@ -196,10 +196,27 @@ } void +Cfillpbs(Cdimg *cd) +{ + uvlong o; + int n; + + if(cd->bootdirec == nil || cd->loaderdirec == nil) + return; + o = Cwoffset(cd); + Cwseek(cd, 3 + cd->bootdirec->block * Blocksize); /* jmp over magic */ + + Cputnl(cd, cd->loaderdirec->block, 4); /* ptr to loader */ + n = (cd->loaderdirec->length + Blocksize - 1) / Blocksize; + Cputnl(cd, n, 4); /* loader size */ + Cputnl(cd, Blocksize, 4); /* loader size */ + Cwseek(cd, o); +} + +void findbootimage(Cdimg *cd, Direc *root) { Direc *d; - d = walkdirec(root, cd->bootimage); if(d == nil){ fprint(2, "warning: did not encounter boot image\n"); @@ -208,3 +225,16 @@ cd->bootdirec = d; } + +void +findloader(Cdimg *cd, Direc *root) +{ + Direc *d; + + d = walkdirec(root, cd->loader); + if(d == nil){ + fprint(2, "warning: did not encounter boot loader\n"); + return; + } + cd->loaderdirec = d; +} diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/disk/9660/cdrdwr.c --- a/sys/src/cmd/disk/9660/cdrdwr.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/disk/9660/cdrdwr.c Thu Apr 12 12:14:14 2012 +0200 @@ -44,6 +44,7 @@ Cputisopvd(cd, info); if(info.flags & CDbootable){ cd->bootimage = info.bootimage; + cd->loader = info.loader; cd->flags |= info.flags & (CDbootable|CDbootnoemu); Cputbootvol(cd); } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/disk/9660/dump9660.c --- a/sys/src/cmd/disk/9660/dump9660.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/disk/9660/dump9660.c Thu Apr 12 12:14:14 2012 +0200 @@ -120,10 +120,17 @@ case 'v': info.volumename = atom(EARGF(usage())); break; + case 'x': + info.flags |= CDpbs; + info.loader = EARGF(usage()); + break; default: usage(); }ARGEND + if(info.flags & CDpbs && !(info.flags & CDbootnoemu)) + usage(); + if(mk9660 && (fix || now || maxsize)) usage(); @@ -206,9 +213,11 @@ if(cd->bootimage){ findbootimage(cd, &iroot); + if(cd->loader) + findloader(cd, &iroot); Cupdatebootcat(cd); } - + /* create Joliet tree */ if(cd->flags & CDjoliet) copydirec(&jroot, &iroot); @@ -263,6 +272,8 @@ */ newnull = Cputdumpblock(cd); } + if(info.flags & CDpbs) + Cfillpbs(cd); /* * Write _conform.map. @@ -336,7 +347,7 @@ writedumpdirs(cd, &idumproot, Cputisodir); if(cd->flags & CDjoliet) writedumpdirs(cd, &jdumproot, Cputjolietdir); - + /* * Patch in new root directory entry. */ diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/disk/9660/iso9660.h --- a/sys/src/cmd/disk/9660/iso9660.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/disk/9660/iso9660.h Thu Apr 12 12:14:14 2012 +0200 @@ -114,8 +114,10 @@ uvlong bootcatptr; ulong bootcatblock; uvlong bootimageptr; + Direc *loaderdirec; Direc *bootdirec; char *bootimage; + char *loader; Biobuf brd; Biobuf bwr; @@ -134,6 +136,7 @@ CDdump = 1<<5, CDbootable = 1<<6, CDbootnoemu = 1<<7, + CDpbs= 1<<8, }; typedef struct Tx Tx; @@ -157,12 +160,9 @@ char *preparer; char *application; char *bootimage; + char *loader; }; -//enum { -// Blocklen = 2048, /* unused */ -//}; - /* * This is a doubly binary tree. * We have a tree keyed on the MD5 values @@ -294,7 +294,9 @@ void Cputbootcat(Cdimg*); void Cupdatebootvol(Cdimg*); void Cupdatebootcat(Cdimg*); +void Cfillpbs(Cdimg*); void findbootimage(Cdimg*, Direc*); +void findloader(Cdimg*, Direc*); /* cdrdwr.c */ Cdimg *createcd(char*, Cdinfo); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9excl.c --- a/sys/src/cmd/fossil/9excl.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9excl.c Thu Apr 12 12:14:14 2012 +0200 @@ -9,14 +9,14 @@ Excl* tail; } ebox; -typedef struct Excl { +struct Excl { Fsys* fsys; uvlong path; ulong time; Excl* next; Excl* prev; -} Excl; +}; enum { LifeTime = (5*60), diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9fsys.c --- a/sys/src/cmd/fossil/9fsys.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9fsys.c Thu Apr 12 12:14:14 2012 +0200 @@ -4,8 +4,6 @@ #include "fns.h" #include "9.h" -typedef struct Fsys Fsys; - struct Fsys { VtLock* lock; @@ -662,7 +660,7 @@ goto Out1; n = 0; for(;;){ - if(blockWrite(bb)){ + if(blockWrite(bb, Waitlock)){ while(bb->iostate != BioClean){ assert(bb->iostate == BioWriting); vtSleep(bb->ioready); @@ -844,9 +842,9 @@ fs = fsys->fs; cacheCountUsed(fs->cache, fs->elo, &used, &tot, &bsize); - consPrint("\t%s: %,llud used + %,llud free = %,llud (%llud%% used)\n", + consPrint("\t%s: %,llud used + %,llud free = %,llud (%.1f%% used)\n", fsys->name, used*(vlong)bsize, (tot-used)*(vlong)bsize, - tot*(vlong)bsize, used*100LL/tot); + tot*(vlong)bsize, used*100.0/tot); return 1; } diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9lstn.c --- a/sys/src/cmd/fossil/9lstn.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9lstn.c Thu Apr 12 12:14:14 2012 +0200 @@ -3,7 +3,7 @@ #include "9.h" typedef struct Lstn Lstn; -typedef struct Lstn { +struct Lstn { int afd; int flags; char* address; @@ -11,7 +11,7 @@ Lstn* next; Lstn* prev; -} Lstn; +}; static struct { VtLock* lock; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9p.c --- a/sys/src/cmd/fossil/9p.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9p.c Thu Apr 12 12:14:14 2012 +0200 @@ -1133,7 +1133,7 @@ /* * Currently, the only defined version * is "9P2000"; ignore any later versions. - */ + */ v = strtol(&t->version[2], 0, 10); if(v >= 2000){ r->version = VERSION9P; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9srv.c --- a/sys/src/cmd/fossil/9srv.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9srv.c Thu Apr 12 12:14:14 2012 +0200 @@ -3,7 +3,7 @@ #include "9.h" typedef struct Srv Srv; -typedef struct Srv { +struct Srv { int fd; int srvfd; char* service; @@ -11,7 +11,7 @@ Srv* next; Srv* prev; -} Srv; +}; static struct { VtLock* lock; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/9user.c --- a/sys/src/cmd/fossil/9user.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/9user.c Thu Apr 12 12:14:14 2012 +0200 @@ -9,7 +9,7 @@ typedef struct Ubox Ubox; typedef struct User User; -typedef struct User { +struct User { char* uid; char* uname; char* leader; @@ -19,11 +19,11 @@ User* next; /* */ User* ihash; /* lookup by .uid */ User* nhash; /* lookup by .uname */ -} User; +}; #pragma varargck type "U" User* -typedef struct Ubox { +struct Ubox { User* head; User* tail; int nuser; @@ -31,7 +31,7 @@ User* ihash[NUserHash]; /* lookup by .uid */ User* nhash[NUserHash]; /* lookup by .uname */ -} Ubox; +}; static struct { VtLock* lock; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/cache.c --- a/sys/src/cmd/fossil/cache.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/cache.c Thu Apr 12 12:14:14 2012 +0200 @@ -9,9 +9,6 @@ typedef struct BAddr BAddr; enum { - Nowaitlock, - Waitlock, - BadHeap = ~0, }; @@ -25,7 +22,6 @@ struct Cache { VtLock *lk; - VtLock *dirtylk; int ref; int mode; @@ -163,7 +159,6 @@ nbl = nblocks * 4; c->lk = vtLockAlloc(); - c->dirtylk = vtLockAlloc(); /* allowed to dirty blocks */ c->ref = 1; c->disk = disk; c->z = z; @@ -561,12 +556,15 @@ switch(b->iostate){ default: abort(); + case BioLabel: + if(mode == OOverWrite) + /* + * leave iostate as BioLabel because data + * hasn't been read. + */ + return b; + /* fall through */ case BioEmpty: - case BioLabel: - if(mode == OOverWrite){ - blockSetIOState(b, BioClean); - return b; - } diskRead(c->disk, b); vtSleep(b->ioready); break; @@ -1098,16 +1096,14 @@ if(b->iostate == BioDirty) return 1; - assert(b->iostate == BioClean); + assert(b->iostate == BioClean || b->iostate == BioLabel); - vtLock(c->dirtylk); vtLock(c->lk); b->iostate = BioDirty; c->ndirty++; if(c->ndirty > (c->maxdirty>>1)) vtWakeup(c->flush); vtUnlock(c->lk); - vtUnlock(c->dirtylk); return 1; } @@ -1171,7 +1167,7 @@ * Otherwise, bail. */ int -blockWrite(Block *b) +blockWrite(Block *b, int waitlock) { uchar *dmap; Cache *c; @@ -1195,7 +1191,7 @@ } lockfail = 0; - bb = _cacheLocalLookup(c, p->part, p->addr, p->vers, Nowaitlock, + bb = _cacheLocalLookup(c, p->part, p->addr, p->vers, waitlock, &lockfail); if(bb == nil){ if(lockfail) @@ -1476,10 +1472,13 @@ bl.next = nil; bl.recurse = recurse; - p = blistAlloc(b); + if(b->part == PartSuper && b->iostate == BioClean) + p = nil; + else + p = blistAlloc(b); if(p == nil){ /* - * We were out of blists so blistAlloc wrote b to disk. + * b has already been written to disk. */ doRemoveLink(b->c, &bl); return; @@ -2008,7 +2007,7 @@ b = _cacheLocalLookup(c, p->part, p->addr, p->vers, Nowaitlock, &lockfail); - if(b && blockWrite(b)){ + if(b && blockWrite(b, Nowaitlock)){ c->nflush++; blockPut(b); return 1; @@ -2088,12 +2087,6 @@ void cacheFlush(Cache *c, int wait) { - /* - * Lock c->dirtylk so that more blocks aren't being dirtied - * while we try to write out what's already here. - * Otherwise we might not ever finish! - */ - vtLock(c->dirtylk); vtLock(c->lk); if(wait){ while(c->ndirty){ @@ -2106,7 +2099,6 @@ }else if(c->ndirty) vtWakeup(c->flush); vtUnlock(c->lk); - vtUnlock(c->dirtylk); } /* diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/dat.h --- a/sys/src/cmd/fossil/dat.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/dat.h Thu Apr 12 12:14:14 2012 +0200 @@ -34,6 +34,9 @@ }; enum { + Nowaitlock, + Waitlock, + NilBlock = (~0UL), MaxBlock = (1UL<<31), }; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/fns.h --- a/sys/src/cmd/fossil/fns.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/fns.h Thu Apr 12 12:14:14 2012 +0200 @@ -39,7 +39,7 @@ void blockSetIOState(Block*, int); Block* _blockSetLabel(Block*, Label*); int blockSetLabel(Block*, Label*, int); -int blockWrite(Block*); +int blockWrite(Block*, int); Disk* diskAlloc(int); int diskBlockSize(Disk*); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/fossil/fs.c --- a/sys/src/cmd/fossil/fs.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/fossil/fs.c Thu Apr 12 12:14:14 2012 +0200 @@ -204,8 +204,8 @@ superPack(super, b->data); blockDirty(b); if(forceWrite){ - while(!blockWrite(b)){ - /* BUG: what should really happen here? */ + while(!blockWrite(b, Waitlock)){ + /* this should no longer happen */ fprint(2, "%s: could not write super block; " "waiting 10 seconds\n", argv0); sleep(10*1000); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/ndb/cs.c --- a/sys/src/cmd/ndb/cs.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/ndb/cs.c Thu Apr 12 12:14:14 2012 +0200 @@ -163,6 +163,7 @@ { "icmp", iplookup, iptrans, 1 }, { "icmpv6", iplookup, iptrans, 1 }, { "rudp", iplookup, iptrans, 1 }, + { "ssh", iplookup, iptrans, 1 }, { "telco", telcolookup, telcotrans, 1 }, { 0 }, }; diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/ndb/dn.c --- a/sys/src/cmd/ndb/dn.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/ndb/dn.c Thu Apr 12 12:14:14 2012 +0200 @@ -17,6 +17,7 @@ Deftarget = 1<<30, /* effectively disable aging */ Minage = 1<<30, Defagefreq = 1<<30, /* age names this often (seconds) */ + Restartmins = 600, /* these settings will trigger frequent aging */ // Deftarget = 4000, @@ -139,6 +140,7 @@ }; ulong target = Deftarget; +ulong start; Lock dnlock; static ulong agefreq = Defagefreq; @@ -715,6 +717,17 @@ unlock(&dnvars); db2cache(needrefresh); + + /* if we've been running for long enough, restart */ + if(start == 0) + start = time(nil); + if(0 && time(nil) - start > Restartmins*60){ // TODO + dnslog("killing all dns procs for timed restart"); + postnote(PNGROUP, getpid(), "die"); + dnvars.mutex = 0; + exits("restart"); + } + dnageall(0); /* let others back in */ @@ -2006,11 +2019,16 @@ assert(rp->magic == RRmagic); assert(!rp->cached); + /* our callers often hold dnlock. it's needed to examine dp safely. */ dp = rp->owner; if(dp){ - assert(dp->magic == DNmagic); - for(nrp = dp->rr; nrp; nrp = nrp->next) - assert(nrp != rp); /* "rrfree of live rr" */ + /* if someone else holds dnlock, skip the sanity check. */ + if (canlock(&dnlock)) { + assert(dp->magic == DNmagic); + for(nrp = dp->rr; nrp; nrp = nrp->next) + assert(nrp != rp); /* "rrfree of live rr" */ + unlock(&dnlock); + } } switch(rp->type){ diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/ndb/dns.c --- a/sys/src/cmd/ndb/dns.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/ndb/dns.c Thu Apr 12 12:14:14 2012 +0200 @@ -25,6 +25,8 @@ typedef struct Job Job; typedef struct Network Network; +extern ulong start; + int vers; /* incremented each clone/attach */ static volatile int stop; @@ -116,6 +118,20 @@ } void +justremount(char *service, char *mntpt) +{ + int f; + + f = open(service, ORDWR); + if(f < 0) + abort(); /* service */; + while (mount(f, -1, mntpt, MAFTER, "") < 0) { + dnslog("dns mount -a on %s failed: %r", mntpt); + sleep(5000); + } +} + +void main(int argc, char *argv[]) { int kid, pid; @@ -211,9 +227,10 @@ sysfatal("%s exists; another dns instance is running", servefile); free(dir); -// unmount(servefile, mntpt); -// remove(servefile); + /* don't unmount here; could deadlock */ +// while (unmount(servefile, mntpt) >= 0) +// ; mountinit(servefile, mntpt); /* forks, parent exits */ srand(now*getpid()); @@ -226,11 +243,18 @@ * fork without sharing heap. * parent waits around for child to die, then forks & restarts. * child may spawn udp server, notify procs, etc.; when it gets too - * big, it kills itself and any children. - * /srv/dns and /net/dns remain open and valid. + * big or too old, it kills itself and any children. + * + * /srv/dns remains open and valid, but /net/dns was only mounted in + * a child's separate namespace from 9p service, to avoid a deadlock + * from serving our own namespace, so we must remount it upon restart, + * in a separate process and namespace. */ for (;;) { - kid = rfork(RFPROC|RFFDG|RFNOTEG); + start = time(nil); + /* don't unmount here; could deadlock */ +// unmount(servefile, mntpt); + kid = rfork(RFPROC|RFFDG|RFNOTEG|RFNAMEG); switch (kid) { case -1: sysfatal("fork failed: %r"); @@ -239,14 +263,14 @@ dnudpserver(mntpt); if(sendnotifies) notifyproc(); - io(); + io(); /* serve 9p; return implies restart */ _exits("restart"); - default: - while ((pid = waitpid()) != kid && pid != -1) - continue; - break; } - dnslog("dns restarting"); + sleep(1000); /* wait for 9p service to start */ + justremount(servefile, mntpt); + while ((pid = waitpid()) != kid && pid != -1) + continue; + dnslog("restarting"); } } @@ -280,11 +304,11 @@ if(pipe(p) < 0) abort(); /* "pipe failed" */; - /* copy namespace to avoid a deadlock */ - switch(rfork(RFFDG|RFPROC|RFNAMEG)){ + switch(rfork(RFFDG|RFPROC)){ case 0: /* child: hang around and (re)start main proc */ close(p[1]); procsetname("%s restarter", mntpt); + mfd[0] = mfd[1] = p[0]; break; case -1: abort(); /* "fork failed\n" */; @@ -304,12 +328,13 @@ /* * put ourselves into the file system + * it's too soon; we need 9p service running. */ - if(mount(p[1], -1, mntpt, MAFTER, "") < 0) - fprint(2, "dns mount failed: %r\n"); +// if(mount(p[1], -1, mntpt, MAFTER, "") < 0) +// dnslog("dns mount -a on %s failed: %r", mntpt); + close(p[1]); _exits(0); } - mfd[0] = mfd[1] = p[0]; } Mfile* diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/samterm/mesg.c --- a/sys/src/cmd/samterm/mesg.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/samterm/mesg.c Thu Apr 12 12:14:14 2012 +0200 @@ -33,10 +33,7 @@ rcv(void) { int c; - static state = 0; - static count = 0; - static i = 0; - static int errs = 0; + static int count = 0, errs = 0, i = 0, state = 0; while((c=rcvchar()) != -1) switch(state){ @@ -645,10 +642,17 @@ if(n >= 0){ if(!s1) n = 0; - s1 = realloc(s1, n+1); - if (!s1) - panic("realloc"); - s1[n] = 0; + if(n > SNARFSIZE){ + s1 = strdup(""); + if (!s1) + panic("strdup"); + n = strlen(s1); + }else{ + s1 = realloc(s1, n+1); + if (!s1) + panic("realloc"); + s1[n] = 0; + } snarflen = n; outTs(Tsetsnarf, n); if(n>0 && write(1, s1, n)!=n) diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/upas/fs/imap4.c --- a/sys/src/cmd/upas/fs/imap4.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/upas/fs/imap4.c Thu Apr 12 12:14:14 2012 +0200 @@ -412,7 +412,11 @@ return -1; } sha1(connp->cert, connp->certlen, digest, nil); - if(!imap->thumb || !okThumbprint(digest, imap->thumb)){ + /* + * don't do this any more. our local it people are rotating their + * certificates faster than we can keep up. + */ + if(0 && (!imap->thumb || !okThumbprint(digest, imap->thumb))){ close(sfd); werrstr("server certificate %.*H not recognized", SHA1dlen, digest); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/upas/fs/pop3.c --- a/sys/src/cmd/upas/fs/pop3.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/upas/fs/pop3.c Thu Apr 12 12:14:14 2012 +0200 @@ -130,7 +130,11 @@ return "server did not provide TLS certificate"; } sha1(conn.cert, conn.certlen, digest, nil); - if(!pop->thumb || !okThumbprint(digest, pop->thumb)){ + /* + * don't do this any more. our local it people are rotating their + * certificates faster than we can keep up. + */ + if(0 && (!pop->thumb || !okThumbprint(digest, pop->thumb))){ fmtinstall('H', encodefmt); close(fd); free(conn.cert); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/usb/kb/hid.c --- a/sys/src/cmd/usb/kb/hid.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/usb/kb/hid.c Thu Apr 12 12:14:14 2012 +0200 @@ -31,7 +31,7 @@ else high = 0; ch->b += nbits; - return high | low; + return MSK(nbits)&(high | low); } static void @@ -52,25 +52,42 @@ *vp = get8bits(ch, nbi); } -/* TODO check report id, when it does appear (not all devices) */ int parsereportdesc(HidRepTempl *temp, uchar *repdesc, int repsz) { - int i, j, l, n, isptr, hasxy, hasbut, nk; + int i, j, l, n, isptr, hasxy, hasbut, nk, ncoll; int ks[MaxVals]; HidInterface *ifs; ifs = temp->ifcs; isptr = 0; hasxy = hasbut = 0; + ncoll = 0; n = 0; nk = 0; memset(ifs, 0, sizeof *ifs * MaxIfc); - for(i = 0; i < repsz / 2; i += 2){ - if(n == MaxIfc || repdesc[i] == HidEnd) + for(i = 0; i < repsz; i += 2){ + if(n == MaxIfc) break; + if(repdesc[i] == HidEnd){ + i--; + ncoll--; + if(ncoll == 0) + break; + } switch(repdesc[i]){ + case HidReportId: + switch(repdesc[i+1]){ + case HidReportApp: + temp->id = repdesc[i+1]; + break; + default: + fprint(2, "report type %#ux bad\n", + repdesc[i+1]); + return -1; + } + break; case HidTypeUsg: switch(repdesc[i+1]){ case HidX: @@ -118,9 +135,16 @@ ifs[n].nbits = 1; nk = 0; break; + case HidCollection: + ncoll++; + break; } } temp->nifcs = n; + for(i = 0; i < n; i++) + temp->sz += temp->ifcs[i].nbits * temp->ifcs[i].count; + temp->sz = (temp->sz + 7) / 8; + if(isptr && hasxy && hasbut) return 0; fprint(2, "bad report: isptr %d, hasxy %d, hasbut %d\n", diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/usb/kb/hid.h --- a/sys/src/cmd/usb/kb/hid.h Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/usb/kb/hid.h Thu Apr 12 12:14:14 2012 +0200 @@ -95,17 +95,22 @@ }; struct HidRepTempl{ + int id; /* id which may not be present */ + uint sz; /* in bytes */ int nifcs; HidInterface ifcs[MaxIfc]; }; enum { /* report types */ + + HidReportApp = 0x01, HidTypeUsgPg = 0x05, HidPgButts = 0x09, HidTypeRepSz = 0x75, HidTypeCnt = 0x95, + HidCollection = 0xa1, HidTypeUsg = 0x09, HidPtr = 0x01, @@ -116,7 +121,7 @@ HidInput = 0x81, HidReportId = 0x85, - HidEnd = 0x0c, + HidEnd = 0xc0, }; void dumpreport(HidRepTempl *templ); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/usb/kb/kb.c --- a/sys/src/cmd/usb/kb/kb.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/usb/kb/kb.c Thu Apr 12 12:14:14 2012 +0200 @@ -275,6 +275,13 @@ static char buts[] = {0x0, 0x2, 0x1}; c = ch->e / 8; + + /* sometimes there is a report id, sometimes not */ + if(c == kd->templ.sz + 1) + if(ch->buf[0] == kd->templ.id) + ch->b += 8; + else + return -1; parsereport(&kd->templ, ch); if(kbdebug) @@ -354,7 +361,6 @@ ch.e = 8 * c; if(f->ptrvals(f, &ch, &x, &y, &b) < 0) continue; - if(f->accel){ x = scale(f, x); y = scale(f, y); @@ -619,6 +625,11 @@ kd->in = in; kd->dev = d; res = -1; + kd->ep = openep(d, ep->id); + if(kd->ep == nil){ + fprint(2, "kb: %s: openep %d: %r\n", d->dir, ep->id); + return; + } if(!kd->bootp) res= setfirstconfig(kd, ep->id, desc, sizeof desc); if(res > 0) @@ -632,11 +643,6 @@ } }else if(kbdebug) dumpreport(&kd->templ); - kd->ep = openep(d, ep->id); - if(kd->ep == nil){ - fprint(2, "kb: %s: openep %d: %r\n", d->dir, ep->id); - return; - } if(opendevdata(kd->ep, OREAD) < 0){ fprint(2, "kb: %s: opendevdata: %r\n", kd->ep->dir); closedev(kd->ep); diff -r 6ba826535859 -r bd329fe2476d sys/src/cmd/usb/usbd/usbd.c --- a/sys/src/cmd/usb/usbd/usbd.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/cmd/usb/usbd/usbd.c Thu Apr 12 12:14:14 2012 +0200 @@ -731,6 +731,10 @@ werrstr("reset not implemented"); return -1; } + if(strncmp(buf, "exit", 4) == 0){ + threadexitsall(nil); + return cnt; + } if(tokenize(buf, toks, nelem(toks)) != 2){ werrstr("usage: debug|fsdebug n"); return -1; @@ -744,7 +748,7 @@ else if(strcmp(toks[0], "diskargs") == 0) setdrvargs("disk", toks[1]); else{ - werrstr("unkown ctl '%s'", buf); + werrstr("unknown ctl '%s'", buf); return -1; } fprint(2, "%s: debug %d fsdebug %d\n", argv0, usbdebug, usbfsdebug); diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/getcallerpc.s --- a/sys/src/libc/arm/getcallerpc.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/getcallerpc.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,3 +1,3 @@ -TEXT getcallerpc(SB), $-4 +TEXT getcallerpc(SB), 1, $-4 MOVW 0(R13), R0 RET diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/main9p.s --- a/sys/src/libc/arm/main9p.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/main9p.s Thu Apr 12 12:14:14 2012 +0200 @@ -34,8 +34,8 @@ TEXT _savearg(SB), 1, $0 RET -TEXT _callpc(SB), 1, $0 - MOVW argp-4(FP), R(arg) +TEXT _callpc(SB), 1, $-4 + MOVW 0(R13), R(arg) RET DATA _exitstr<>+0(SB)/4, $"main" diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/memmove.s --- a/sys/src/libc/arm/memmove.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/memmove.s Thu Apr 12 12:14:14 2012 +0200 @@ -5,9 +5,9 @@ TMP = 3 /* N and TMP don't overlap */ TMP1 = 4 -TEXT memcpy(SB), $-4 +TEXT memcpy(SB), $0 B _memmove -TEXT memmove(SB), $-4 +TEXT memmove(SB), $0 _memmove: MOVW R(TS), to+0(FP) /* need to save for return value */ MOVW from+4(FP), R(FROM) diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/strchr.s --- a/sys/src/libc/arm/strchr.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/strchr.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,4 @@ -TEXT strchr(SB), $-4 +TEXT strchr(SB), $0 MOVBU c+4(FP), R1 CMP $0, R1 BEQ _null diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/strcmp.s --- a/sys/src/libc/arm/strcmp.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/strcmp.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,4 @@ -TEXT strcmp(SB), $-4 +TEXT strcmp(SB), $0 MOVW R0, R1 MOVW s2+4(FP), R2 diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/strcpy.s --- a/sys/src/libc/arm/strcpy.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/strcpy.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,4 @@ -TEXT strcpy(SB), $-4 +TEXT strcpy(SB), $0 MOVW R0, to+0(FP) /* need to save for return value */ MOVW from+4(FP), R1 MOVW $0xFF, R2 /* mask */ diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/tas.s --- a/sys/src/libc/arm/tas.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/tas.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,4 @@ -TEXT _tas(SB), $-4 +TEXT _tas(SB), 1, $-4 MOVW R0,R1 MOVW $1,R0 SWPW R0,(R1) /* fix: deprecated in armv7 */ diff -r 6ba826535859 -r bd329fe2476d sys/src/libc/arm/vlop.s --- a/sys/src/libc/arm/vlop.s Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libc/arm/vlop.s Thu Apr 12 12:14:14 2012 +0200 @@ -1,4 +1,4 @@ -TEXT _mulv(SB), $0 +TEXT _mulv(SB), 1, $0 MOVW 4(FP),R8 /* l0 */ MOVW 8(FP),R11 /* h0 */ MOVW 12(FP),R4 /* l1 */ diff -r 6ba826535859 -r bd329fe2476d sys/src/libmach/5db.c --- a/sys/src/libmach/5db.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libmach/5db.c Thu Apr 12 12:14:14 2012 +0200 @@ -61,7 +61,7 @@ */ Machdata armmach = { - {0, 0, 0, 0xD}, /* break point */ + {0x70, 0x00, 0x20, 0xD1}, /* break point */ /* D1200070 */ 4, /* break point size */ leswab, /* short to local byte order */ @@ -210,6 +210,10 @@ op = (48+24+4) + ((w >> 22) & 0x1) + ((w >> 19) & 0x2); break; case 4: /* block data transfer (r)(r) */ + if ((w & 0xfe50ffff) == 0xf8100a00) { /* v7 RFE */ + op = 99; + break; + } op = (48+24+4+4) + ((w >> 20) & 0x1); break; case 5: /* branch / branch link */ @@ -632,19 +636,16 @@ char buf[8]; ulong rn; - sprint(buf, "R%ld", (i->w >> 16) & 0xf); + snprint(buf, sizeof(buf), "R%ld", (i->w >> 16) & 0xf); rn = rget(map, buf); - if((i->w & (1<<24)) == 0) { /* POSTIDX */ - sprint(buf, "R%ld", rn); - return rget(map, buf); - } + if((i->w & (1<<24)) == 0) /* POSTIDX */ + return rn; if((i->w & (1<<25)) == 0) { /* OFFSET */ - sprint(buf, "R%ld", rn); if(i->w & (1U<<23)) - return rget(map, buf) + (i->w & BITS(0,11)); - return rget(map, buf) - (i->w & BITS(0,11)); + return rn + (i->w & BITS(0,11)); + return rn - (i->w & BITS(0,11)); } else { /* REGOFF */ ulong index = 0; uchar c; @@ -856,6 +857,7 @@ /* 48+24+4+4+2+2+4+4 = 92 */ "UNK", armunk, 0, "", + /* new v7 arch instructions */ /* 93 */ "LDREX", armdpi, 0, "(R%n),R%d", "STREX", armdpi, 0, "R%s,(R%n),R%d", @@ -865,6 +867,9 @@ "DSB", armunk, 0, "", "DMB", armunk, 0, "", "ISB", armunk, 0, "", + +/* 99 */ + "RFEV7%P%a", armbdt, 0, "(R%n)", }; static void diff -r 6ba826535859 -r bd329fe2476d sys/src/libmp/port/mpfactorial.c --- a/sys/src/libmp/port/mpfactorial.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libmp/port/mpfactorial.c Thu Apr 12 12:14:14 2012 +0200 @@ -42,7 +42,7 @@ max++; if(max > mmax){ mmax++; - if(max > nelem(stk)) + if(max >= nelem(stk)) abort(); stk[max] = mpnew(Dbits); } diff -r 6ba826535859 -r bd329fe2476d sys/src/libmp/port/strtomp.c --- a/sys/src/libmp/port/strtomp.c Wed Mar 28 17:14:41 2012 +0200 +++ b/sys/src/libmp/port/strtomp.c Thu Apr 12 12:14:14 2012 +0200 @@ -144,9 +144,12 @@ mpbits(b, n*5); p = malloc(n); if(p == nil) - return a; + return buf; m = dec32(p, n, buf, n); - betomp(p, m, b); + if(m == -1) + a = buf; + else + betomp(p, m, b); free(p); return a; }