Commit Graph

6606 Commits (master)

Author SHA1 Message Date
cinap_lenrek c10e21b491 libthread: reduce stack usage of threadkill*(), open /proc/n/ctl with OCEXEC flag 2020-12-07 14:31:02 +01:00
cinap_lenrek e45bd6814a libthread: reduce stack usage for ioprocs, open /proc/n/ctl with OCEXEC flag 2020-12-07 14:29:45 +01:00
cinap_lenrek 1e2657ee97 libthread: simplify threadsetname()
- open /proc/n/args with OCEXEC flag
- reduce stack usage by using smaller buffer for path
- format pid as ulong
2020-12-07 14:27:46 +01:00
cinap_lenrek f1e15da8f5 libc: open internal file-descriptor with OCEXEC flag 2020-12-07 14:24:51 +01:00
cinap_lenrek 544bca0290 rio: format pid's as ulongs 2020-12-07 14:23:41 +01:00
cinap_lenrek ed3ae3faa3 rio: open /dev/snarf with OCEXEC flag when writing 2020-12-07 14:23:23 +01:00
cinap_lenrek c86a960880 rio: simplify filsysinit() by using getuser(), format pid's as ulongs 2020-12-07 14:22:30 +01:00
kvik a92ffdbbfb libndb: remove db file size limit
Removes the 128 kB limit for files making up the database.
We used to skip over and complain about files that exceeded
the limit, forcing the user to generate hash files.

This caused things to inexplicably stop working after a file
hit the hidden limit, which is unreasonable behaviour considering
that libndb happily, albeit slowly, works with bigger files.
2020-12-07 00:36:41 +01:00
cinap_lenrek c924edb91d merge 2020-12-06 22:06:32 +01:00
cinap_lenrek 23b52bbf23 pc64: assign fpsave/fprestore only once in fpuinit() 2020-12-06 22:05:00 +01:00
kvik d15439ee76 ptrap: implement filtering on plumb attributes 2020-12-06 21:52:01 +01:00
cinap_lenrek cd38d41356 pc64: AMD64 mandates SSE support, remove the check in fpuinit() 2020-12-06 21:44:26 +01:00
cinap_lenrek dcdb2bfb9a xen: use pc/fpu.c 2020-12-06 21:28:11 +01:00
cinap_lenrek 8c1bde46f0 pc, pc64: move all fpu specific code from main.c to fpu.c 2020-12-06 21:07:30 +01:00
Sigrid dbbae6d384 xen: fix for the last avx changes 2020-12-06 20:28:53 +01:00
Sigrid 97b3291533 amd64: FP: back to static size for allocation and copying 2020-12-06 19:40:57 +01:00
Sigrid 334c5e1134 amd64: FP: always use enough to fit AVX state and align to 64 bytes 2020-12-06 19:31:56 +01:00
Sigrid 66b6185845 amd64, vmx: support avx/avx2 for host/guest; use *noavx= in plan9.ini to disable 2020-12-06 18:48:32 +01:00
cinap_lenrek 753a35b52a rio: undo previous commit, was a stupid idea 2020-12-06 15:08:23 +01:00
cinap_lenrek a0d12784bd rio: give visual clue during sweep and bandsizing when window is too small
We color the window border with a dark red in case the
window is too small.
2020-12-06 14:50:50 +01:00
cinap_lenrek bf2a6f7865 rio: use libdraw's badrect() to exclude some extreme cases in goodrect() 2020-12-06 14:44:23 +01:00
cinap_lenrek 082560fd5b rio: rewrite better portion() function 2020-12-06 13:20:29 +01:00
Sigrid f5d9b2222b rio: handle corner selection for resizing better (thanks cinap) 2020-12-06 13:04:36 +01:00
Sigrid a696951c6c rio: goodrect: clarify minimal height and actually use the smallest reasonable value 2020-12-06 13:02:33 +01:00
Sigrid 7f7c151687 rio: allow windows as small as one line of text, still scrollable 2020-12-06 12:17:05 +01:00
Sigrid ecb12c8718 aux/status^(bar msg): few small fixes (thanks umbraticus) 2020-12-06 11:55:27 +01:00
Alex Musolino 5d790e08ca cwfs: fix interpretation of startdump argument 2020-12-06 13:54:10 +10:30
cinap_lenrek abcc56afef pc/dma, pc/sdide: use uintptr for physical address instead of ulong 2020-12-05 17:01:24 +01:00
cinap_lenrek 178a9d12c6 pc, pc64: allocate dma bounce buffer right after xinit() 2020-12-05 16:59:30 +01:00
cinap_lenrek 99696c414a pc, pc64: exclude memory regions with unusual MTRR cache attributes
Use the MTRR registers to exclude memory ranges that
do not have the expected cache attributes:

RAM -> writeback
UMB -> uncached
UPA -> uncached
2020-12-05 16:57:12 +01:00
Sigrid 4ca5e1b3a3 faces: add -c option to remove faces with button 1 click (thanks sirjofri) 2020-12-04 09:33:55 +01:00
cinap_lenrek 4b6072e60f merge 2020-12-02 00:57:21 +01:00
cinap_lenrek 1bce6d0981 libdraw: do not force flushimage() on freescreen()
This causes visual flashes of white in rio. If it is
really needed (it is rare) it should be done by the caller.
2020-12-02 00:56:21 +01:00
cinap_lenrek 7d55aa8a32 rio: properly restore the windows contents on /dev/mouse close
The previous resize optimization now means that the wfill()
is skipped on resize for libdraw programs.

So do it once /dev/mouse is closed and the window processes
the Refresh message.
2020-12-02 00:53:58 +01:00
Ori Bernstein 2652cbee57 proof: don't confuse ""(1) (thanks Stuart Morrow)
"" looks for patterns in the form 'prompt;' or 'prompt%',
and gets confused when proof emits 'illegal;'. This change
replaces the ';' with a ':', which both matches other
conventional error outputs and prevents "" from getting
confused.
2020-11-30 13:13:49 -08:00
cinap_lenrek c931e96364 rio: avoid redrawing window text on resize for programs using libdraw
As long as the client as the mouse file open
and maintains reading the winname file of the window
after a resize we will avoid drawing the text frame
on a resize as it will be overdrawn by the client.

This reduces flicker on resize somewhat for slow systems.
2020-11-29 17:51:57 +01:00
cinap_lenrek 1d93a5628a pc, pc64, xen: rewrite interrupt handling code
This implements proper intrdisable() support for all
interrupt controllers.

For enable, (*arch->intrassign)(Vctl*) fills in the
Vctl.enable and Vctl.disable pointers with the
appropriate routines and returns the assigned
vector number.

Once the Vctl struct has been linked to its vector
chain, Vctl.enable(Vctl*, shared) gets called with a
flag if the vector has been already enabled (shared).

This order is important here as enabling the interrupt
on the controller before we have linked the chain can
cause spurious interrupts, expecially on mp system
where the interrupt can target a different cpu than
the caller of intrenable().

The intrdisable() case is the other way around.
We first disable the interrupt on the controller
and after that unlink the Vctl from the chain.
On a multiprocessor, the xfree() of the Vctl struct
is delayed to avoid freeing it while it is still
in use by another cpu.

The xen port now also uses pc/irq.c which has been
made generic enougth to handle xen's irq scheme.
Also, archgeneric is now a separate file to avoid
pulling in dependencies from the 8259 interrupt
controller code.
2020-11-29 17:43:22 +01:00
Alex Musolino 32a5ff9658 games/mix: fix decoding of shift instructions 2020-11-28 23:03:44 +10:30
Alex Musolino 2619be4d4d games/mix: fix SLAX and SRAX instructions (thanks nicolagi)
MIX shift instructions shift by bytes not bits.
2020-11-28 23:02:28 +10:30
Sigrid 0b9c6fa117 fplot: add hyperbolic functions 2020-11-27 10:51:16 +01:00
Sigrid df18213ce3 fplot: add abs 2020-11-27 10:34:16 +01:00
Alex Musolino 2a907fd459 games/mix: fix implementation of MOVE instruction (thanks nicolagi)
Plan 9 memcpy(2) uses the same implementation as memmove(2) to handle
overlapping ranges.  Hovewer, the MIX MOVE instruction, as described
in TAOCP, specifically does not do this.  It copies words one at a
time starting from the lowest address.

This change also expands the address validation to check that all
addresses within the source and destination ranges are valid before
proceeding.
2020-11-27 11:19:49 +10:30
Alex Musolino 781a8f8d9f upas: fix mk nuke 2020-11-25 19:54:52 +10:30
Ori Bernstein bd6747ccd0 upas/*: fix mkfile issues (thanks amavect)
Fixes 3 issues in our upas mkfiles:
- mk/mkfile and send/mkfile were rebuilding
  only the rfc822.tab.$O, even though the
  header also needed to be rebuilt.
- CLEANFILES had a pattern that  would not
  get expanded.
- Third, ../upas/mkfile was being included
  in the wrong place and making the wrong
  rule default.
2020-11-22 11:36:23 -08:00
cinap_lenrek a041c90431 pc, pc64: move common irq handling code out of trap.c
Move the common irq handling code out of trap.c
into pc/irq.c so that it can be shared between 386
and amd64 ports.
2020-11-22 17:44:21 +01:00
mischief 486ce60546 efi: prefer plan9.ini from ESP we loaded from
currently the EFI loader's behavior is to search all disks in a
firmware-defined order.  we search the list returned by the firmware
in reverse order in the hopes of searching the first 9FAT instead of
the ESP, but this results in unintuitive behavior when there are
multiple FAT partitions (possibly in multiple disks), such as loading
a plan9.ini and kernel from a different disk than the one you executed
the EFI loader from.

to resolve this, we change the EFI loader to instead prefer read
plan9.ini and the kernel from the same disk as the EFI loader was read
from, and then fall back to the old behavior, since the old behavior
is relied on by current installations.
2020-11-21 14:18:52 -08:00
Ori Bernstein ad9b1234c3 dc: fix crashes with : operator (thanks istvan bak)
dc crashes because a Blk* sometimes ends getting double freed.
To make it crash, any of these lines will do:
(each line is a separate input to dc):

1 sa 2 :a le d sa v :a
1 sa 2 :a le d sa :a
1 sa 2 :a le d sa c

Fix by assigning p to sptr->val before EMTPY causes a jump.

Additionally, dcgetwd() can return 0. all other uses check for
0 ptr; Also fix a buffer overflow.
2020-11-21 17:56:34 -08:00
Ori Bernstein 03f209427b upas: make 'all' the default target
When consolidating the duplicated targets, the
one that actually got built ended up arbitrary.
Put in a 'default' target that runs 'mk all'.
2020-11-21 16:13:20 -08:00
cinap_lenrek 6dd605dbe2 pc, pc64: fix grub multiboot
It appears that our IDT overlaps with the data structures
passed from grub in multiboot load.

So defer setup of the interrupt table after the multiboot
parameters have been processed.
2020-11-21 23:15:19 +01:00
cinap_lenrek 59308f15dd merge 2020-11-21 22:04:15 +01:00
cinap_lenrek b438fd9d09 ether8169: fix interrupt panic before init, defer initialization until attach
The driver used to register the interrupt handler just
after reset, tho the Ctlr struct, including the buffer
descriptor arrays where only allocated on attach.

This moves most of the reset/init out of pnp
function and into attach. This also means we can
error out and even retry on the next attach.

The logic of the reseter kproc has been changed:
now it is only started once the first initialization
completely succeeded. This avoids the strange qlock
passing.

Implement a shutdown function so the device gets
halted for /dev/reboot.

Assume 64 bit physical addresses for dma.

Check that pci bar0 is actually I/O.
2020-11-21 22:03:13 +01:00
cinap_lenrek 0f56fefd45 pc, pc64: implement disabling of msi interrupts 2020-11-21 21:48:25 +01:00
mischief f8738fd757 nusb/kb, nusb/joy: dont try to set protocol on nonboot devices
the hid 1.11 specification says that for hid devices which arent in
the boot subclass (subclass 1), it is only optional to support the set
protocol command.  for my devices, trying to set protocol results in a
stall error and unusable devices.

fixes my Tex Shinobi keyboard and Playstation 4 controller.
2020-11-21 12:31:54 -08:00
cinap_lenrek 2594b99629 pc, pc64: new MTRR code supporting AMD TOM2 MSR and fixed mtrr ranges
The new MTRR code handles overlapping ranges
and supports AMD specific TOM2 MSR.

The format in /dev/archctl now only shows
the effective cache ranges only, without
exposing the low level registers.
2020-11-21 16:26:46 +01:00
cinap_lenrek e6684dbfda pc, pc64: disable all pci devices for /dev/reboot
Make sure all pci busmaster activity is disabled,
including MSI/MSI-X interrupts, before switching
control to the new kernel.
2020-11-21 16:17:20 +01:00
cinap_lenrek c5d08a602c pc, pc64: disable all pci devices in pcicfginit()
Make sure all pci busmaster activity is disabled,
including MSI/MSI-X interrupts. Drivers will later
reenable once taking control of a device.
2020-11-21 16:10:56 +01:00
cinap_lenrek 1376d39ef1 kernel: add portable pcimsienable()/pcimsidisable(), disable MSI/MSI-X on pcidisable()/pcireset()
This avoids some duplication in the pci support code and
allows pcireset() to diable MSI and MSI-X interrupts
when disabling or reseting a device.
2020-11-21 16:02:21 +01:00
cinap_lenrek cedded7b50 etherm10g: remove duplicated pci capability enum 2020-11-21 00:45:44 +01:00
cinap_lenrek da54e4bfc2 kernel: remove unused pcinextcap() function 2020-11-21 00:41:57 +01:00
cinap_lenrek 9f054063ec pc/l.s: remove unsued m0gdtptr/m0idtptr structs 2020-11-21 00:06:55 +01:00
Anthony Martin ef2fdb6fdd awk: fix truncated input after fflush
Before the "native" awk work, a call to the fflush function resulted
in one or more calls to the APE fflush(2).

Calling fflush on a stream open for reading has different behavior
based on the environment: within APE, it's a no-op¹; on OpenBSD, it's
an error²; in musl, it depends on whether or not the underlying file
descriptor is seekable³; etc. I'm sure glibc is subtly different.

Now that awk uses libbio, things are different: calling Bflush(2) on a
file open for reading simply discards any data in the buffer. This
explains why we're seeing truncated input. When awk attempts to read
in the next record, there's nothing in the buffer and no more data to
read so it gets EOF and exits normally. Note that this behavior is not
documented in bio(2). It was added in the second edition but I haven't
figured out why or what depends on it.

The simple fix is to have awk only call Bflush on files that were
opened for writing. You could argue that this is the only correct
behavior according to the awk(1) manual and it is, in fact, how GNU
awk behaves⁴.

1. /sys/src/ape/lib/ap/stdio/fflush.c
2. https://cvsweb.openbsd.org/src/lib/libc/stdio/fflush.c?rev=1.9
3. https://git.musl-libc.org/cgit/musl/tree/src/stdio/fflush.c
4. https://git.savannah.gnu.org/cgit/gawk.git/tree/io.c#n1492
2020-11-19 23:05:26 -08:00
Ori Bernstein 1e3dd86128 upas/*: cleanup mkfiles (thanks amavect)
Changeset 50ad211fb12f broke the libcommon rule in
mkupas. Deleting the 'mk clean' in the recipe fixes
this.

Cleanup includes deleting UPDATE vars from all mkfiles,
reorganization of vars in TARG,LIB,OFILE,HFILE order,
and deletion of extra vars used for UPDATE.
2020-11-17 18:37:38 -08:00
cinap_lenrek 972f95aa63 pc, pc64: load idt early in trapinit0()
loading the interrupt vector table early allows
us to handle traps during bootup before mmuinit()
which gives better diagnostics for debugging.

we also can handle general protection fault on
rdmsr() and wrmsr() which helps during
cpuidentify() and archinit() when probing for
cpu features.
2020-11-17 23:30:09 +01:00
cinap_lenrek 8cb33f2f18 pc/l.s: load virtual gdt pointer after mmu switch
before removing the double map at 0, load our
initial gdt pointer with its new KZERO based
virtual address.

this is prerequisite for handling traps early during
bootup before mmuinit() loads the final gdt.
2020-11-17 23:18:08 +01:00
cinap_lenrek e8111e517d nusb/cam: don't videoclose() when open failed
The fsdestroyfid() is called regardless if the open succeeded
or failed. This causes erroneous videoclose() when opening
the frame or video file while the camera is active.
2020-11-16 19:56:13 +01:00
kvik fc36bf0711 diff: fix change marker for -c mode 2020-11-16 19:19:37 +01:00
kvik 3fbcc5f410 ptrap: fail if invoked with no arguments 2020-11-16 11:45:05 +01:00
cinap_lenrek b80975da8b aux/cpuid: fix final newline on printbits() 2020-11-15 22:47:45 +01:00
cinap_lenrek 3f835565d5 etheriwl: bring back recovery on flushq timeout 2020-11-15 14:54:09 +01:00
cinap_lenrek 2a946b24a6 audiohda: do not enable interrupts before intrenable()
When using /dev/reboot, the MSI vecor might have already
been setup causing interrupts to fire on the designated
cpu while we send the commands to the card.
2020-11-15 14:34:17 +01:00
cinap_lenrek 0c846e605b audiohda: reset irbsts bits in hdainterrupt() (thanks LordCreepity)
reseting irbsts bits in hdacmd() only works
while interrupts are disabled during hdareset().
once interrupts are enabled we need to reset the
irbsts bits in the interrupt handler or else the
interrupt never clears and locks up the system.
2020-11-11 00:55:53 +01:00
Ori Bernstein e543995bba imap4d: imap4date should ignore time and timezone (RFC3501, 6.4.4) 2020-11-08 14:21:14 -08:00
Ori Bernstein 4257a5292a upas/marshal: add -S saveto to save outgoing mail, fix -F
Upas/marshal -F was broken with the '-8' command, and silly
without it: It used aliases passed on the command line, so
the destination address was ignored with -8 was passed.

In addition, it would create a new mailbox for any aliases
being sent to, instead of putting them all in one location.

The new -S option is similar to -F, but specifies where the
message should go.
2020-11-06 18:15:15 -08:00
cinap_lenrek 6f15a730f3 merge 2020-11-04 23:09:47 +01:00
cinap_lenrek 6cc223ee56 pc/pc64: fix faulty mtrr slot reuse (thanks Fulton)
The change 3306:c5cf77167bfe made the code reuse MTRR slots
of the default memory type.

But this did not take overlapping ranges into account!

If two or more variable-range MTRRs overlap, the following rules apply:

a.	If the memory types are identical, then that memory type is used.
b.	If at least one of the memory types is UC, then UC memory type is used.
c.	If at least of of the memory types is WT. and the only other memory type
	is WB, then th WT memory type is used.
d.	If the combination of memory types is not listed above,
	then the memory type used in undefined.

It so happend that on a Dell Latitude E7450 that the BIOS defines
the default type as UC. and the first slot defines a 16GB range
of type WB. Then the rest of the ranges mark the PCI space back
as UC, but overlapping the first WB range! This works because
of rule (B) above.

When trying to make the framebuffer write-combining, we would
falsely reuse one of the UC sub-ranges and making the UC memory
into WB as a side effect.

Thanks to Fulton for his patience and providing debug logs and
doing experiments for us to narrow the problem down.
2020-11-04 23:08:52 +01:00
cinap_lenrek 9cca88895e merge 2020-11-03 20:47:14 +01:00
cinap_lenrek 0ba91ae22a pc, pc64: allocate i/o port space for unassigned pci bars, move ioalloc() to port/iomap.c
With some newer UEFI firmware, not all pci bars get
programmed and we have to assign them ourselfs.

This was already done for memory bars. This change
adds the same for i/o port space, by providing a
ioreservewin() function which can be used to allocate
port space within the parent pci-pci bridge window.

Also, the pci code now allocates the pci config
space i/o ports 0xCF8/0xCFC so userspace needs to
use devpnp to access pci config space now. (see
latest realemu change).

Also, this moves the ioalloc()/iofree() code out
of devarch into port/iomap.c as it can be shared
with the ppc mtx kernel.
2020-11-03 20:46:09 +01:00
Ori Bernstein 97de3f67c2 upas/common: delete library on 'mk clean'
libcommon.a$O doesn't end with a .a, so mk
doesn't know how to look inside it in order
to check if the files are up to date.

This means that when 'mk clean' is run,
libcommon.a$O looks up to date:

	% mk clean
	...
	% mk
	mk: 'default' is up to date

Deleting the library works around this problem.
2020-11-02 13:12:34 -08:00
cinap_lenrek aad55ccc2d mtx: fix pci access routines (see changeset 8012:78891f472fbf) 2020-11-02 20:53:20 +01:00
Sigrid f4d2067373 audio/wavdec: add -s option 2020-11-02 11:46:50 +01:00
cinap_lenrek a4c6dc1d3d aux/realemu: use #$/pci/B.D.Fraw to access pci config space
This prevents VESA bios from accessing the pci
CONFIG_ADDRESS/CONFIG_DATA registers (0xCF8/0xCFC)
directly to access pci config space.

This makes sure the access to pci config space is
properly serialized by the kernel.
2020-11-02 01:14:30 +01:00
cinap_lenrek 2063019560 vmx: mask out bits 0:2 and 24:30 of pci CONFIG_ADDRESS on read
These bits are reserved, and by the specification,
must return zero on read.

This is also used by plan 9 for detecting config mode #1.
2020-11-02 01:01:48 +01:00
Ori Bernstein d75d842cf5 rc: show line numbers on error
This change provides a location for errors
like 'null list in concatenation'.
2020-11-01 11:56:26 -08:00
Ori Bernstein b5086c1863 libc: recurse on smaller half of array
Our qsort has an optimization to recurse on one
half of the array, and do a tail call on the other
half. Unfortunately, the condition deciding which
half of the array to recurse on was wrong, so we
were recursing on the larger half of the array and
iterating on the smaller half.

This meant that if we picked the partition poorly,
we were pessimizing our stack usage instead of
optimizing it.

This change reduces our stack usage from O(n)
to O(log(n)) for poorly chosen pivots.
2020-11-01 11:23:39 -08:00
Alex Musolino 51b22d8548 jpg: treat EOF as EOI marker
Some jpegs, rightly or wrongly, do not contain an EOI marker.  This
causes jpg(1) to bail out even after correctly parsing the entire
image.
2020-10-31 15:44:49 +10:30
Ori Bernstein 31eb1b9d72 vt: improve behavior of chording
vt chording behaves slightly differently from other
applications: a chord must be fully released before
the next chord can be applied. This makes any change
in chord apply the action.
2020-10-30 13:23:16 -07:00
cinap_lenrek 5f2cf12f38 ip/cifsd: fix missing int return type for vpack() (thanks pr) 2020-10-29 18:26:35 +01:00
Sigrid d541c7bfd3 aux/cpuid: decode leaf 7; extend leaf 13 decoding 2020-10-29 11:27:26 +01:00
cinap_lenrek 0205392410 audiohda: make it work with qemu (thanks mischief)
the driver was not using irb interrupts
and was just polling the irb write pointer
to wait for command completion.

this is not supported by qemu.

qemu requires the use of irb interrupt handshake
and it refuses to accept the next command until we
acknowledge the irb interrupt.
2020-10-27 15:16:03 +01:00
cinap_lenrek 950d970671 ip/tinc: fix reportedge()
supplying a non-ip address in ADD_EDGE crashes the unix tincd.

the reason was that we where misreporting ADD_EDGE messages;
ignoring the information from our peers; and always supplying
the Address string from our configuration instead of the
connections ip address.

now we just report the edge information as is.
2020-10-25 22:27:30 +01:00
Sigrid 55945f6f24 vmx/vga: fix allocimage leaks 2020-10-23 00:16:47 +02:00
khm 19273fdee3 upas/fs/mbox.c: fix cosmetic typo 2020-10-22 13:46:00 -07:00
Sigrid 797a5ac470 libaml: add (nop) "signal" op 2020-10-21 12:06:25 +02:00
Ori Bernstein 78bed738e1 vncv: pick an auth type that we support
We used to pick the highest auth type regardless of whether
we supported it. Now we filter down to types that we support.
2020-10-18 19:30:14 -07:00
cinap_lenrek 87385accde sdiahci: accept AHCI controllers from ASMedia vendor id (thanks mischief) 2020-10-19 01:20:29 +02:00
cinap_lenrek a5764f8181 pc, pc64: remove mystery "type" bits in pcicfgrw*raw() (fixes qemu, thanks mischief)
the access functions for pci config space in config mode #1
used to set bit 0 in the register offset if the access was
to a device on any bus different from 0.

it is completely unclear why this was done and i can't find
any documentation on this.

but for sure, this breaks all pci config spacess access to
pci devices behind a bridge on qemu. with -trace pci* it
was discovered that all config space register offsets on
devies behind pci brige where off by one.

on real hardware, setting bit 0 in the offset doesnt appear
to be an issue.

thanks mischief for reporting and providing a qemu demo
configuration to reproduce the problem.
2020-10-18 23:39:07 +02:00
cinap_lenrek d1604b5f9c sdnvme: use PCIWADDR() instead of PADDR() 2020-10-18 17:02:42 +02:00
cinap_lenrek 96e9f3707c etherbcm: handle 64-bit host addresses, use PCIWADDR() instead of PADDR() 2020-10-18 17:01:50 +02:00
cinap_lenrek 30417c12fd audiohda: use PCIWADDR() instead of PADDR(), handle 64-bit dma addresses 2020-10-18 17:00:04 +02:00
Ori Bernstein 83efe2f157 etheriwl: delay before crystal calibration
On my 6235 card, if we calibrate the crystal
immediately after disabling wimax, the the
firmware gets unhappy. A short nap before
sending the command prevents the command from
timing out.
2020-10-18 10:50:07 -04:00
Ori Bernstein 98c07541bb nusb/serial: add ids for FT230X (thanks mischief) 2020-10-17 19:27:21 -07:00
Ori Bernstein 90601f6e47 merge 2020-10-17 19:04:17 -07:00
Ori Bernstein a41b74059b upas: fix appendfolder timestamps (thanks umbraticus)
When moving messages between folders, mbappend,
deliver, and nedmail were trying to parse the
timestamp ouut of the message. They were doing
it incorrectly, trying to include the user name
as part of the date format.

Change to pass just the date to the date parser.
2020-10-17 18:59:36 -07:00
cinap_lenrek 3cfa8326b8 etheriwl: don't break controller on command flush timeout
ori and echoline are reporting regression on some 6000 cards;
which sometimes time out on crystal calibration command;
which is expected by the driver. but the new code used
to force a device reset on any command timeout.

reverting to old behaviour until for now until we have
a chance investigating.
2020-10-18 03:05:35 +02:00
cinap_lenrek cf8ff0e713 sdnvme: handle machines with more cpu's than submit queues (thanks mischief)
We used to assume a 1:1 pairing of processors to submit queues.
With recent machines, we now got more cpu cores than what some
nvme drives support so we need to distribute the queues across
these cpu's which requires locking on command submission.

There is a feature get/set command to probe the number of submit
and completion queues, but we decided to just handling
submission queue create command error gracefully as it is simpler
and has less chance of regression with existing setups.

Thanks to mischief for investigating and writing the code.
2020-10-18 02:51:32 +02:00
cinap_lenrek 5fd2e746e1 merge 2020-10-17 21:30:10 +02:00
cinap_lenrek 0b094303f3 ndb/dnsdebug: add -c flag to debug caching dns server behaviour 2020-10-17 21:28:56 +02:00
cinap_lenrek bf18724738 ndb/dns: mark ns record authoritative when in our area for delegation
I have the problem that i need to delegate a subdomain
to another name server that is confused about its own zone
(and its own name) returning unusable ns records.

With this, one can make up a nameserver entry in ndb that
is authoritative and owned by us for that nameserver,
and then put it in the soa=delegated ns entry.

This promotes the ns record in the soa=delegated to
Authoritative, which avoids overriding the ns rr's from
the confused server for the delegated zone.
2020-10-17 21:28:25 +02:00
Sigrid dfbf774bbb games/nes: workaround for truncated chr 2020-10-15 10:30:40 +02:00
cinap_lenrek d310da13ba ip/torrent: try harder allocating ports
we used to only allocate ports from 6881 to 6890,
which limits the maximum of parallel torrents to 9.

this change make it go up to 9000, which gives us
at best 2120 ports, which is overkill but ports might
be randomly occupied by other connections.
2020-10-12 02:03:52 +02:00
cinap_lenrek 3e880cd07d upas/fs: fix truncation of plumb date
the new date format introduced by the previous commit;
using numeric timezone offsets; needs one character more,
so increase the date format buffer to 31 characters.
2020-10-11 14:59:49 +02:00
cinap_lenrek c7598b18f3 kernel: get rid of unused ucallocb
the whole idea of a ucallocb() is bad, as even access to the
metadata header would be in uncached memory. also, it tuns out
that it was never used by anyone.
2020-10-09 22:05:32 +02:00
Sigrid 4a75ad5ec8 vmx: add Kmod4 2020-10-09 16:47:34 +02:00
Ori Bernstein 53234798c0 etheriwl: add Wireless 8260 card
After the latest tweaks to the order of operations,
the card works.
2020-10-05 14:10:12 -07:00
cinap_lenrek 204a96f163 merge 2020-10-05 22:43:25 +02:00
cinap_lenrek d49b9e1b84 etheriwl: remove stations *after* disabling binding quotas, drain all queues in rxoff7000() 2020-10-05 22:42:13 +02:00
kvik 6f76d00300 rio: move the code for 'send' into a function
Makes the code a bit nicer and allows reusing wsend() in patches.
2020-10-04 22:45:22 +02:00
cinap_lenrek 2aff96f17c etheriwl: add for Intel Wireless-AC 9260
the 9000 series uses a new receive descriptor format
wich appears to reqire 4k aligned buffers. the old
format "halfworks" and just makes the firmware not
respond to any commands after the enable paging command.

the smartfifo command appears to causes problems.
but apparently not issuing it at all seems to work
fine on both the 8265 and 9260. so removing the code
for now.

issuing the bindingquota command before associated
makes association impossible. but enabling afterwards
works fine. (tested in 8265 and 9260).

the prph access functions now mask the address with
0xfffff. it is unclear why linux and openbsd drivers
specify addresses beyond that in ther register constants.

the timeevent change is interesting. the timeevent
needs to be restarted when it has stoped to make sure
probing/association packets are sent during the evnet.
2020-10-04 21:10:53 +02:00
kvik fa1d6ffd83 bootrc: allow kbmap to be set via plan9.ini (thanks Aaron Bieber) 2020-10-01 17:47:52 +02:00
Ori Bernstein c63cd980a4 acme: revert stray changes
forgot I had local changes when testing, re-revert scrolling.
2020-09-29 07:28:47 -07:00
Ori Bernstein fb42cf0dda vncv: implement rfb 3.8 protocol (thanks Iruatã)
Gnome and bhyve's VNC servers implement the RFB 3.8
protocol, so we need to support it in the client in
order to connect.
2020-09-27 09:43:43 -07:00
Ori Bernstein 16766169e2 aux/vga: eepc igfx support (thanks p.kosyh)
This patch to makes 1024x600x32 work. Without it
only 800x600 is supported.

To load this mode, run:

	aux/vga -m eeepc -l 1024x600x32
2020-09-26 20:47:17 -07:00
Ori Bernstein d9f9e10e7b upas: convert to tmdate, change timezone format
Complete the conversion of upas to remove ctime,
use the new date library, and print time zones
in +hhmm format, instead of NNN format.

This may affect code that expects specific names
for timezones. Fix that code.
2020-09-26 11:20:42 -07:00
Ori Bernstein eb6b1e672c merge 2020-09-25 16:51:08 -07:00
Sigrid 878911b628 aux/acpi: connect EC region handler, fixes battery status on eeepc 1000px (thanks Peter Kosyh) 2020-09-25 10:28:25 +02:00
kvik 2968225196 syscall: fix build problem caused by stale tab.h
Recently the script which generates tab.h and the code including it got
incompatibly changed.  People reported problems involving syntax errors
when trying to rebuild the system following a sysupdate.

The problem was with the script being embedded within a mkfile rule,
meaning that mk didn't notice it changing and therefore didn't rebuild
the target file.  For people who were rebuilding the system this meant
that the old tab.h got included, causing syntax errors.

This patch moves the codegen script into a file and tells mk about this
new dependency, so that tab.h will get rebuilt for everyone.  I also
took an opportunity to rewrite the script, hopefuly making it easier to
follow.
2020-09-23 17:17:52 +02:00
Alex Musolino 23de6808f7 ftpd: handle "allo" command by treating it as a no-op
RFC959 says:

	"The ALLO command should be treated as a NOOP (no
	operation) by those servers which do not require
	that the maximum size of the file be declared
	beforehand..."
2020-09-23 12:44:05 +09:30
Ori Bernstein 9f8d62ab64 libc: ignore '?' in date format strings
Ignoring '?' when formatting date strings allows
the format strings to be reused for parsing. This
is convenient, since we don't need to duplicate
the format strings.
2020-09-22 19:24:01 -07:00
Ori Bernstein 77c3cb50fb libc: make yday 0-based, as docs suggest
Tm.yday is docuemnted as being 0-based, and our new api
should respect that. Fix the code so that this is true.
2020-09-22 19:21:51 -07:00
Ori Bernstein 313aebb964 acme: import changes from plan9port (thanks jxy)
Import the following improvements and bugfixes from plan9port:

	4650064a acme: scale window bodies on resize, not including tag space
	d28913a9 acme: save/restore multiline tags in Dump/Load
	d2df5d6c acme: fix crash in X |cat with multiple windows
	3d6e5cb5 acme: preserve window position and selection during Get
2020-09-22 11:42:15 -07:00
Ori Bernstein 8fe1d622b5 diff: support unified diff via -u
The format produced by `diff -u` is inferior to that
produced by `diff -c`, but it's what ape/patch and
unix patch expect, so it's useful to generate it.

This patch adds `diff -u`.
2020-09-21 09:40:42 -07:00
kvik aa7c8cac11 syscall: utility overhaul
Following is a list of functional changes:

* The -o flag outputs the entire buffer to the length returned
  by the syscall, or, in case of fd2path(2) and errstr(2), to '\0'.
* The -x flag is removed; the above makes it possible to pipe
  into xd(1) to get the same result.
* The -s flag uses dirfmt(2) to format the stat message, instead
  of trying to imitate ls(1).
* Stderr reports are normalized and made easier to parse.

The code also suffered a number of stylistic changes.
2020-09-20 14:49:12 +02:00
Ori Bernstein e3166b4fe8 upas/fs: fix handing of multi-line header fields (thanks theinicke)
Right now, upasfs exposes header lines as is, without stripping
out new lines. It also documents that it provides one header per
line in the info file.

As a result, when we get a mail with headers that span lines,
our tools get confused.

These split lines are not semantically meaningful. From RFC5322:

  2.2.3.  Long Header Fields

   Each header field is logically a single line of characters comprising
   the field name, the colon, and the field body.  For convenience
   however, and to deal with the 998/78 character limitations per line,
   the field body portion of a header field can be split into a
   multiple-line representation; this is called "folding".  The general
   rule is that wherever this specification allows for folding white
   space (not simply WSP characters), a CRLF may be inserted before any
   WSP.

As a result, to simplify processing, we should just strip out the
line separators when exposing the headers from upasfs.
2020-09-17 16:11:10 -07:00
BurnZeZ 77b819d585 ptrap: fix /env/status always being set on main process exit 2020-09-16 20:45:49 +00:00
kvik be876a06ac syscall: don't append '\n' to the output 2020-09-16 13:18:43 +02:00
cinap_lenrek d3ebd02bef merge 2020-09-13 20:34:30 +02:00
cinap_lenrek 4f85115526 kernel: massive pci code rewrite
The new pci code is moved to port/pci.[hc] and shared by
all ports.

Each port has its own PCI controller implementation,
providing the pcicfgrw*() functions for low level pci
config space access. The locking for pcicfgrw*() is now
done by the caller (only port/pci.c).

Device drivers now need to include "../port/pci.h" in
addition to "io.h".

The new code now checks bridge windows and membars,
while enumerating the bus, giving the pc driver a chance
to re-assign them. This is needed because some UEFI
implementations fail to assign the bars for some devices,
so we need to do it outselfs. (See pcireservemem()).

While working on this, it was discovered that the pci
code assimed the smallest I/O bar size is 16 (pcibarsize()),
which is wrong. I/O bars can be as small as 4 bytes.
Bit 1 in an I/O bar is also reserved and should be masked off,
making the port mask: port = bar & ~3;
2020-09-13 20:33:17 +02:00
Ori Bernstein 3873eb06d9 games/4s: increase thread size (thanks majiru)
It seems like on amd64, we're overflowing the stack.
Let's not do that.
2020-09-13 11:21:21 -07:00
Ori Bernstein d7b541eaf3 faces: remove log support
Use a damn plumber, you animals!
2020-09-12 17:40:41 -07:00
cinap_lenrek 693485e9c4 etheriwl: add support for Intel Wireless AC 8265 2020-09-06 16:53:39 +02:00
cinap_lenrek a87b6909bc wifi: add packet timestamping support 2020-09-06 16:51:02 +02:00
Ori Bernstein f444d6c3f2 tmparse: put in local timezone hack
Ctime is defined as printing a 3-character timezone
name. The timezone name is ambiguous. For example,
EST refers to both Australian and American eastern
time. On top of that, we don't want to make the
tzabbrev table exhaustive. So, we put in this hack:

Before we consult the well known table of timezones,
we check if the local time matches the timezone name.

On top of that, tm2sec

If you want unambiguous timezone parsing, use numeric
timezone offsets (Z, ZZ formats).
2020-09-01 19:32:45 -07:00
Ori Bernstein e0278f6917 seconds: tolerate trailing whitespace in dates
This allows handling dates with leading and trailing whitespace,
including newlines.
2020-09-01 19:03:17 -07:00
cinap_lenrek e9cd41467e upas: appendfolder() don't be picky about the timezone of ctime()
This is temporary fix, we should try to emulate the previous
behaviour where we accept at least our local timezone, and
otherwise ignore the offset.
2020-09-01 23:08:58 +02:00
cinap_lenrek 20d8cd0d63 upas: appendfolder(): skip the address from unix header before date 2020-09-01 23:01:45 +02:00
cinap_lenrek feda48624b upas/fs: extract proper date from unix header
do not try to parse the m->unixfrom field, it only contains
the unix mail address.

instead, have parseunix() save a pointer into the unixheader
after the unix mail address for the unixdate, and later use
it to derive the mails timestamp.
2020-09-01 21:39:45 +02:00
Alex Musolino 79b4ec29a1 upas/fs: remove unused function date822tounix 2020-09-01 22:25:06 +09:30
Alex Musolino e6bfbd0d33 png: remove bogus chanlen warning 2020-09-01 21:54:10 +09:30
Ori Bernstein ec533a1ad8 ape/ctype.h: add isblank, fix functions (thanks staalmannen)
Our ctype.h mistakenly ommitted isblank. Add it in.

While we're here, the make the 'isfoo()' functions
are broken: they're offsetting into the array, and
don't work with negative character values.

Sync the function bodies with the macros, and make
them produce correct results.
2020-08-29 11:09:20 -07:00
Ori Bernstein b7b077375f faces(1): remove bespoke date parser
In addition to being more code, this date parser would
treat local times as local, but anything that wasn't a
local time would get parsed as gmt, due to a quirk of
how tm2sec used to work.

This moves the code to tmparse, and fixes timezone parsing
at the same time.
2020-08-27 10:32:02 -07:00
Ori Bernstein 68aa4d5254 tmparse: fix typo 2020-08-26 12:12:44 -07:00
Ori Bernstein 17abfa51ca libc: tmparse should ignore leading whitespace
We almost always want to skip leading whitespace in time
formats, so make tmparse just do it. This fixes upas mbox
parsing, which leaves a leading whitespace at the start of
the date.
2020-08-26 10:23:00 -07:00
Ori Bernstein b1a13414cd tm2sec: clear new fields in tm
Old users of the time APIs would hand-craft
time structs without first zeroing all the
members. When this got into tmnorm(), we
would try to access the new members, and
things would go off the rails.

This makes tm2sec() clear the new fields
before passing them to the new APIs, so
that the hand-crafted structs remain
valid.
2020-08-24 14:47:10 -07:00
Sigrid 0505f8fb3a nusb/lib: use fmtprint for the entire dump to be printed out 2020-08-23 12:14:32 +02:00
cinap_lenrek 603d9812a7 kernel: fix Abind cyclic reference and mounthead leaks (thanks Alex Musolino)
The Abind case in namec() needs to cunique() the chan
before attaching the umh mount head pointer onto it.

This is because we cannot give a reference to the mount
head to any of the mh->mount...->to channels, as they
will never go away until the mount head goes away.
This is a cyclic reference.

This could be reproduced with:

	@{rfork n; mount -a '#s/boot' /mnt/root; bind /mnt/root /}

Also, fix memory leaks around cunique(), which can
error, leaking the mount head we got from domount().

Move the umh != nil check inside cunique().
2020-08-23 05:07:30 +02:00
Sigrid b6fde0c7b9 libaml: fix fault when the second operand of comparison cannot be converted 2020-08-20 08:28:24 +02:00
Sigrid de34481f8b oggdec: give it enough chance to seek from the start, where first seek might be still too close to the beginning of the file 2020-08-18 16:45:00 +02:00
Sigrid 5405ee61ae audio/oggdec: allow -s 0 2020-08-12 22:26:06 +02:00
Sigrid 601dd12651 audio/mp3dec: mad timer duration is all wrong, use samples instead 2020-08-12 11:42:00 +02:00
Sigrid 81dba13271 audio/mp3dec: add -s SECONDS option 2020-08-12 10:43:46 +02:00
Sigrid 4ba367d435 audio/oggdec: add -s SECONDS option to seek before decoding 2020-08-11 17:26:33 +02:00
Sigrid 2e6f158f4d audio/flacdec: add -s SECONDS option to seek before decoding 2020-08-11 17:25:53 +02:00
Ori Bernstein 1e315f896d aux/ms2, aux/na: fix warnings
aux/na was comparing the return of putc with <0, when it should
have been comparing against EOF, which is not specified as -ve.

aux/ms2 was zero-extending the mask for the address when it
should have been sign extended.
2020-08-10 19:35:05 -07:00
Ori Bernstein c834f535b7 seconds: use new libc date api 2020-08-10 19:02:09 -07:00
Ori Bernstein 6d3a2e6531 date: use new libc date apis. 2020-08-10 19:01:45 -07:00
Ori Bernstein 9db78003db merge 2020-08-10 19:00:59 -07:00
Sigrid 6e039d7b49 vmx: does not do well with certain fb widths, so restrict it 2020-08-10 16:38:26 +02:00
Ori Bernstein e702cfcafd upas/fs: port date parsing to libc apis
There was a lot of code in upas/fs to deal with dates.
Now there isn't.
2020-08-09 19:46:38 -07:00
Ori Bernstein 9d446410c5 ip/httpd: fix 'mk nuke' 2020-08-09 19:00:06 -07:00
Ori Bernstein 56e869ac70 libc: new date apis
The current date and time APIs on Plan 9 are not good. They're
inflexible, non-threadsafe, and don't expose timezone information.

This commit adds new time APIs that allow parsing arbitrary
dates, work from multiple threads, and can handle timezones
effectively.
2020-08-09 18:58:44 -07:00
Ori Bernstein 3ba1d83d20 cc: promote integer constants according to c99 spec.
C99 integer constants with no type suffix promote differently
depending on the way that they're written: hex and oct consts
promote as int => uint => long => ulong => vlong => uvlong.
Decimal constants are always signed.

We used to promote all values to uint on overflow, and never
went wider. This change fixes that, and adds a warning when
a decimal constant that would have been promoted to uint in
the past gets promoted to int.
2020-08-08 11:39:25 -07:00
cinap_lenrek ac4e21f52d ndb/dns: allow multiple txt, nullrr, cert, key and sig records (thanks kvik)
The de-duplication of txt, nullrr, cert, key and sig records
reduced all records to a single one.

Also, dblookup1() missed the txt record case and did not return
a unique list of rr's.

Now we consider these records unique if their value is different.
The new txtequiv() function does that for TXT records, which is
a bit tricky as it needs to take different segmentation into account.
2020-08-08 18:37:10 +02:00
Sigrid 93b475981e vmx: set xstart to either nsec or cycles depending on what is available 2020-08-07 17:08:49 +02:00
Sigrid 1cddff55da libttf: fix cmap subtable offset type and rank UCS-4 higher (more codepoints). fixes runes > 0xffff 2020-08-05 14:25:21 +02:00
cinap_lenrek e1da4f1750 kernel: don't strip binaries in bootfs.paq 2020-08-04 16:31:24 +02:00
cinap_lenrek 5915d12ea4 qball: remove unused #include <stdio.h> 2020-08-04 16:27:27 +02:00
cinap_lenrek d913f652f5 devmnt: print chanpath for unexpected reply tag 2020-08-04 16:23:22 +02:00
cinap_lenrek 53800208bd rc: avoid stat calls for directory globbing
On Plan9, we can count on Readdir() onlydirs argument
to work, which allows us to avoid stating every single
file to see if it is a directory.
2020-08-04 16:21:37 +02:00
Sigrid e9df4c718a libttf: check directory() result 2020-08-04 11:42:43 +02:00
cinap_lenrek 4bbf1d12b5 7c: now really fix OASxxx operations
the previous patch broke 64-bit ops as the type for the
operation is determined from the first argument to
gopcode() (nod1.type), not the type the result (nod.type).

so we need to include the conversion of nod1 type to
the type of nod.
2020-08-04 00:50:33 +02:00
cinap_lenrek 1d07c2a161 merge 2020-08-03 23:17:32 +02:00
cinap_lenrek d42f9b5110 reverting 7c change, breaks some 64-bit shifts... 2020-08-03 23:16:41 +02:00
cinap_lenrek c4cf92b99e merge 2020-08-03 21:52:22 +02:00
cinap_lenrek 053a6526e2 acme: reverting scroll change, causes continuous scrolling with scrollwheel 2020-08-03 21:51:25 +02:00
cinap_lenrek cbe45e78f9 7c: fix wrong type on OASxxx operations
the bug can be reproduced with the following test case:

#include <u.h>
#include <libc.h>

void
main()
{
	int size = 1;
	size*=1.5;
	exits(0);
}

this produces the following assembly:

	TEXT	main+0(SB),0,$16
	MOVW	$1,R1
	FCVTZSDW	$1.50000000000000000e+00,R2	<- tries to convert rhs to int??
	MULW	R2,R1,R2 <- multiplication done in int? bug!
	MOV	$0,R0
	BL	,exits+0(SB)
	RETURN	,
	END	,

the confusion comes from the *= operation using the wrong type
for the multiplication. in this case we should use the float
type of the rhs, do the operation, and then convert the result
back to int type of the lhs.

this change ports the same logic from 5c's getasop().
2020-08-02 19:48:25 +02:00
Ori Bernstein 9e27ee094c deroff: fix out-of-bounds access if runes above 0X80 are inside EQ clauses (thanks mmnmnnmnmm, via plan9port)
Characters greater than 0X80 will cause a read beyond the bounds of the
array chars[]. For particular unicode characters this can cause deroff
to segfault.

A minimal example:
$ deroff
.EQ
u∈
Segmentation fault

Throughout deroff, charclass() is used instead of directly indexing
chars[] so I presume this was just missed.
2020-08-01 10:54:03 -07:00
Ori Bernstein 6dbecfb457 htmlroff: fix out of bounds access (thanks Rei-sen, via plan9port)
_readx() uses rune count as its argument and not size, so we should
pass nelem() instead of sizeof().
2020-08-01 10:49:29 -07:00
kvik e5894dccea pre-lib9p servers: fix incorrect Tversion handling
version(5) says:

	If the server does not understand the client's version
	string, it should respond with an Rversion message (not
	Rerror) with the version string the 7 characters
	``unknown''.

Pre-lib9p file servers -- all except cwfs(4) -- do return Rerror.

lib9p(2) follows the above spec, although ignoring the next part
concerning comparison after period-stripping.  It assumes an
Fcall.version starting with "9P" is correctly formed and returns
the only supported version of the protocol, which seems alright.

This patch brings pre-lib9p servers in accordance with the spec.
2020-08-01 15:27:28 +02:00
Sigrid 88a468f205 vmx(1): use _tos->cyclefreq (thanks cinap) 2020-08-01 15:23:51 +02:00
Ori Bernstein d287f178aa dc: increase exponent limit (thanks unboe, lyndon)
dc has an arbitrary limit on the size of the exponent. Lets
replace it with a different arbitrary limit.
2020-07-31 08:52:17 -07:00
Sigrid 9965e575f8 vmx(1): add missing file 2020-07-31 15:51:32 +02:00
Sigrid 853f0e33fe vmx(1): use cycles() instead of nsec() when possible
this provides better timing and reduced number of syscalls (~2.7M old
vs ~35K new in a test)
2020-07-31 15:48:54 +02:00
Sigrid de27182a8e vmx: use _actual_ system kbmap 2020-07-31 11:24:02 +02:00
Sigrid eb65fc5e69 aux/acpi: forgot to commit -p option 2020-07-30 15:59:04 +02:00
Sigrid edb6f64d35 aux/acpi: write a man page, fix usage, call threadexits 2020-07-30 11:25:14 +02:00
Alex Musolino 02f19713a1 sshfs: update usage text to match man page 2020-07-29 13:56:03 +09:30
Ori Bernstein c03079ad08 upasfs: make imap debug logging less noisy
The current logging prints a debug line for every
message in an inbox, which is unusably verbose.
This removes the prints for unchanged messages,
and adds a print for flag changes.
2020-07-26 19:12:48 -07:00
Ori Bernstein ea98dafce5 replica: fix mkfile script installation (thanks Amavect)
The $SCRIPTS were added to $TARG, which complicates the all rule, as
each script's object file must be suppressed.
Fix by removing $SCRIPTS from $TARG, removing the script object file
suppression rule, and overriding the install rule.

The script bin install rule assumes that only one script install is
called at a time. Valid calls like 'mk -a /$objtype/replica/changes
/$objtype/replica/pull' will fail.
Fix by adding a for loop.

Remove the unused $UPDATE variable.
2020-07-20 18:58:52 -07:00
cinap_lenrek 9ea93a5fd3 libndb: order subnets by prefix length for ndbipinfo() lookups
to reproduce:

ipnet=foo0 ip=192.168.0.0 ipmask=/16
ipnet=foo1 ip=192.168.0.0 ipmask=/24
ip=192.168.0.1 sys=foo2

% ndb/ipquery sys foo2 ipnet ipmask
ipnet=foo0 ipmask=/16

we would expect to get ipnet=foo1 here as it is more
specific subnet.

the solution is to order the subnets by prefix length
in subnet() before calling filter(), so that we process
the longest prefixes first.
2020-07-17 16:53:20 +02:00
Ori Bernstein 407cf4ac6e ape: simplify mkfile (thanks amavect)
ape cp, mv, and cc build with ?c, not pcc
ape cp and mv just ignore one or two extra flags,
instead of providing posix compatibility
it's better to fail then do nothing

remove cp.c and mv.c
move cc.c to /sys/src/ape/9src so it doesn't
need its own mkfile rule
2020-07-16 15:22:42 -07:00
cinap_lenrek 61b1134df9 merge 2020-07-16 03:12:31 +02:00
cinap_lenrek e7e6f4fc90 pc64: disable interrupts in mmuwalk() for checkmmu()
we have to disable interrupts during mmuwalk() of user pages
as we can get preempted during mmu walk and the original
m->pml4 might become one of a different process.
2020-07-16 03:11:27 +02:00
Ori Bernstein 0366f11300 cpp: fix mutually recursive macros
Handle cases where parameterless macros expand to each other:

	#define FOO BAR
	#define BAR FOO
	FOO

There were cases where the macros didn't make it into the hidesets,
and we would recurse infinitely. This fixes that.
2020-07-13 18:50:14 -07:00
cinap_lenrek 77ddc8c654 kernel: make segments non-executable when icache is not maintained
This change makes it mandatory for programs to call segflush() on
code that is not in the text segment if they want to execute it.

As a side effect, this means that everything but the text segment
will be non-executable by default, even without the SG_NOEXEC
attribute. Segments with the SG_NOEXEC attribute never become
executable, even when segflush() is called on them.
2020-07-12 21:42:26 +02:00
cinap_lenrek 11fcf41472 aux/cpuid: flush instruction cache of after patching trampoline 2020-07-12 19:37:38 +02:00
cinap_lenrek 2c8c2bc727 hjfs: update mtime and qid.vers for directory on rename
when wstating a file, its directory should be updated to
reflect this change.

here is what the manpage states:

> The mtime field reflects the time of the last change of content
> (except when later changed by wstat). For a directory it is the
> time of the most recent remove, create, or wstat of a file in the
> directory.
2020-07-12 18:54:22 +02:00
cinap_lenrek a469cffafe cwfs: update mtime and qid.vers for directory on rename
when wstating a file, its directory should be updated to
reflect this change.

here is what the manpage states:

> The mtime field reflects the time of the last change of content
> (except when later changed by wstat). For a directory it is the
> time of the most recent remove, create, or wstat of a file in the
> directory.
2020-07-12 18:52:28 +02:00
cinap_lenrek ad26dc48a6 imap4d: fix missing return in %δ format of Dfmt() 2020-07-05 22:15:02 +02:00
cinap_lenrek b33eb658e2 imap4d: get rid of unixdate/unixfrom handling
all this logic is already done by upas/fs, the unixdate and from
fields in the info file will always be correct.
2020-07-05 21:18:26 +02:00
cinap_lenrek 24dcdb54b8 imap4d: fix mkfile to have the correct default target 2020-07-05 21:16:41 +02:00
cinap_lenrek fc2a3496fe upas/fs: wait until the index becomes unlocked
For big mailboxes with imap4d, ignoring the index and trying to scan
the mailbox concurrently is not very productive. Just wait for the
other upas/fs to write the whole index.

The issue is that imap might time out and make another connection
spawning even more upas/fs instances that all then try to rebuild
the index concurrently.
2020-07-05 21:15:55 +02:00
cinap_lenrek 786ec28b7b upas/fs: fix wrong nparts field index (changed in previous commit) 2020-07-05 19:51:59 +02:00
cinap_lenrek e844c77845 nedmail: don't try to shoot down subcommand on interrupt
this breaks interrupt key handling in rio. theres also no
point in trying todo so as rio sends the note to the whole
process group so the subcommand should have got the note
already.

just wait for the subprocess to terminate.
2020-07-05 18:17:20 +02:00
cinap_lenrek 43e56e26de upas/fs: put date822 into the index, fix from and replyto handling
the date, from and replyto fields where unstable, in that the value
read depended on the state of the cache.

fixing the from and replyto fields is easy, we just handle the
substitution in parsebody().

the date field however requires us to put the date822 into the index
so it can be recovered without requiering to reparse the header
(and body, as we might have a message/rfc822 message with promoted
fields).

with these changes, the fields will be consistent and independnet
of the cache state.

a small optimization also has been added:

after parsing the body, attachments and substitution of from/replyto,
the boundary and unixfrom strings are not needed anymore and can
be freed early.
2020-07-05 17:44:32 +02:00
cinap_lenrek e161f1c8ba upas/fs: fix memory leak in ref822() 2020-07-05 17:05:49 +02:00
Ori Bernstein a71450412a imap4d: respect errors from read(), remove debug prints
When read() failed, we were casting the -1 return to
unsigned, which would cause us to index out of bounds.
found using dovecot imap test suite. While we're here,
let's remove the stray debug prints.
2020-07-03 11:29:45 -07:00
Alex Musolino a3a4f5c3e3 kbdfs/mklatin: allow >16 bit runes in /lib/keyboard 2020-07-03 22:14:49 +09:30
cinap_lenrek 03852d9408 bcm64: increase maximum segment size to 8GB
make it possible for one process to use all
of physical memory.
2020-07-03 01:17:38 +02:00
cinap_lenrek 91994dc5d8 bcm64: handle 8GB of physical memory for raspberry pi4
widen and move the KMAP window to a new address so we can
handle the 8GB of physical memory of the new raspberry pi4.

the new memory map on pi4 uses the following 4 banks:

0x000000000	0x03e600000
0x040000000	0x0fc000000 <- soc.dramsize (only < 4GB)
0x100000000	0x180000000
0x180000000 0x200000000
2020-07-02 21:12:40 +02:00
cinap_lenrek bd23963c8f bcm64: fix usb xhci controller on pi4 8GB variant (thanks richard miller)
On the 8GB variant of the raspberry pi 4,
the eeprom chip for the xhci controller is missing and
instead loaded from sdram (by the gpu firmware).

for this, the gpu firmware needs to be notified of
the xhci controllers pci bus address (after reset)
that was assigned by our pci enumeration code.
2020-07-02 21:04:01 +02:00
cinap_lenrek 85132f197b upas/fs: move unixheader handling to parseheaders()
parsing the unixheader in mdir fetch routine is the wrong place,
as no invalid character handling has been performed yet. also
the string is not neccesarily null terminated.

avoid duplication with plan9 mbox parsing and just do it in
parseheaders(), which already handles faking the unix headers
for pop3 and imap.
2020-06-29 00:23:37 +02:00
cinap_lenrek 30ab804b58 kernel: segflush() needs to flush tlb of other processes
instruction cache maintenance is done on tlb miss;
when a page gets fauled in; with putmmu() checking
the page->txtflush cpu bitmap.

syssegflush() used to only call flushmmu() after
segflush() for the calling process, but when a segment
is shared with other processes, we have to flush the
other processes tlb as well.

this adds the missing procflushseg() call into segflush().

note that procflushseg() leaves the calling process alone,
so the flushmmu() call in syssegflush() is still required.

segmentioproc() does not need to call flushmmu() after
segflush() as it is never going to jump to the modified
page, hence the stale icache does not matter.
2020-06-28 16:26:59 +02:00
cinap_lenrek 675ebaeca3 aux/trampoline: Implement inactivity timeout (-t option)
Using aux/trampoline to relay udp traffic needs a inactivity
timeout to be practical as there is no explicit connection
termination.
2020-06-27 16:40:53 +02:00
cinap_lenrek 739bb1a06f upas/fs: remove now unused Mtrunc mimeflags constant 2020-06-24 19:21:47 +02:00
cinap_lenrek d7613e356c upas/fs: use memchr() instead of strchr() in hdrlen()
make sure we look for the end of the header within the
pointer range, and not accidentally read beyond hend.

also, messages are not null terminated, so this could
even go beyond the email data buffer.

get rid of mimeflag which was only used for some assert
checks.

take header length into account when comparing header
against ignored header strings.
2020-06-24 19:18:37 +02:00
cinap_lenrek 1e8eb61a37 merge 2020-06-24 18:47:03 +02:00
cinap_lenrek b33773def8 ip/tinc: run script sub-shell in its own environment 2020-06-24 18:45:58 +02:00
Alex Musolino 200c18bc15 upas/marshal: make attachment failure fatal 2020-06-22 16:34:31 +09:30
cinap_lenrek 55d8082842 usbxhci: implement isochronous in transfers (for webcam, audio recording) 2020-06-21 21:42:13 +02:00
cinap_lenrek 4fb65ae3e8 devusb: keep isochronous ep->hz consistent with maxpkt, ntds and pollival
The sample frequency is an artificial parameter used for
isochronous out transfers to better match the target
frequency (usually, a sound card).

when hz is set, devusb adjusts the endpoint's maxpkt to get
the requested frequency and a multiple of the samplesize per
packet.

however, when hz is not set, then we should calculate the
frequency from maxpkt, ntds and pollival, so all parameters
will be consistent with each other.
2020-06-21 21:36:50 +02:00
Alex Musolino 78a6eb52c8 abaco: add fonts.h to HFILES in mkfile (thanks eekee) 2020-06-21 19:34:54 +09:30
cinap_lenrek 7c3477cb61 ip/torrent: fix size check in 64-bit "v" unpack (thanks pr) 2020-06-19 20:19:57 +02:00
cinap_lenrek febe84af75 libc: revert date change again. this is getting ridicuoulus.
this breaks the sample from the seconds manpage, and overall
produces funky results. this needs alot more testing.

term% seconds '23 may 2011'
seconds: tmparse: invalid date 23 may 2011 near 'may 2011'

term% seconds '2019-01-01 00:00:00'
-118370073600
2020-06-15 00:12:57 +02:00
Ori Bernstein 8b3efcfc4e libc, seconds: new time and date apis (try 2)
Redo date handling in libc almost entirely. This allows
handling dates and times from outside your timezones,
fixes timezone loading in multithreaded applications,
and allows parsing and formatting using custom format
strings.

As a test of the APIs, we replace the formatting code in
seconds(1), shrinking it massively.

The last commit missed a few removals, and made it
unnecessarily hard to do an update.
2020-06-14 09:33:32 -07:00
cinap_lenrek f380851ddb libc: reverting previous change until ori can fix it 2020-06-14 04:47:22 +02:00
Ori Bernstein e2ee991490 libc, seconds: new time and date apis.
Redo date handling in libc almost entirely. This allows
handling dates and times from outside your timezones,
fixes timezone loading in multithreaded applications,
and allows parsing and formatting using custom format
strings.

As a test of the APIs, we replace the formatting code in
seconds(1), shrinking it massively.
2020-06-13 12:38:49 -07:00
cinap_lenrek 8ffcc91b1b merge 2020-06-12 01:36:50 +02:00
cinap_lenrek ac6cb9af29 ramfs: make Elocked[] more consistent (thanks fazlul)
Go expects the error to be one of the three errors returned in
Bell Labs Plan 9. As listed in
f7ba82d68f/src/cmd/go/internal/lockedfile/lockedfile_plan9.go (L16):

	// Opening an exclusive-use file returns an error.
	// The expected error strings are:
	//
	//  - "open/create -- file is locked" (cwfs, kfs)
	//  - "exclusive lock" (fossil)
	//  - "exclusive use file already open" (ramfs)
	var lockedErrStrings = [...]string{
		"file is locked",
		"exclusive lock",
		"exclusive use file already open",
	}
2020-06-12 01:35:37 +02:00
kvik 57362e0c8c acme: implement position-dependent scroll-wheel scrolling
This brings acme scrolling behaviour in line with that of 9front's rio
and sam, where the amount scrolled varies with a vertical position of
the pointer within the window, similar to how the scrollbar works.

At some point it would be good to implement a line-at-a-time scrolling
when the Shift key is pressed, as seen in rio.  For this to happen the
acme keyboard input needs to be rewritten in terms of /dev/kbd instead
of relying on keyboard(2) -- that is, the /dev/cons interface.
2020-06-11 15:33:57 +02:00
Ori Bernstein db6e26d55e libplumb: add missing mkfile 2020-06-09 12:23:24 -07:00
cinap_lenrek 7c8d75a309 acme: add missing logf.c 2020-06-07 17:06:33 +02:00
cinap_lenrek 29fee6a8ed ip/6in4: request ipv4 packets only in ipmux filter 2020-06-07 16:56:54 +02:00
cinap_lenrek 5474646164 devip: implement ipv6 support in ipmux packet filter
Added a ver= field to the filter to distinguish the ip version.
By default, a filter is parsed as ipv6, and after parsing
proto, src and dst fields are converted to ipv4. When no
ver= field is specified, a ip version filter is implicitely
added and both protocols are parsed.

This change also gets rid of the fast compare types as the
filed might not be aligned correctly in the packet.

This also fixes the ifc= filter, as we have to check any
local address.
2020-06-07 16:56:01 +02:00
cinap_lenrek 8f087e019f snoopy: add ipmux pseudo protocol
the ipmux pseudo protocol handles the extra ipv6 interface address
prefixed to the ip header as used by /net/ipmux packet filter.
2020-06-07 16:48:04 +02:00
cinap_lenrek 85ffa283f6 devip: fix parseipmask() prototype in ip.h 2020-06-07 16:45:55 +02:00
Ori Bernstein d2be4787c6 acme: import event log from plan9port (thanks fshahriar)
Based off the following 3 commits:

	4a3fb87264f8bc03fc62f00ef335056f30d18023
	45f8ba54143323f08a21343633764caa59aa3ea3
	fdf6ef333705c844bcf3ccf2f93b2773f1a6aa41

Reading /mnt/acme/log reports a log of window create,
put, focus, and delete events, as they happen. It blocks
until the next event is available.

Example log output:

	8 new /Users/rsc/foo.go
	8 put /Users/rsc/foo.go
	8 del /Users/rsc/foo.go

This lets acme-aware programs react to file writes, for example
compiling code, running a test, or updating an import block.
2020-06-06 19:05:00 -07:00
cinap_lenrek e46000f076 devip: pick less surprising interface address in header for incoming UDP packets
We used to just return the first address of the incoming
interface regardless of if the address matches the source
ip type and scope.

This change tries to find the best interface address that
will match the source ip so it can be used as a source
address when replying to the packet.
2020-06-06 23:46:01 +02:00
cinap_lenrek 1a5dafcc3d merge 2020-06-06 16:52:01 +02:00
cinap_lenrek 301148756e aux/vga: use 64-bit physical addresses for pci membar 2020-06-06 16:44:14 +02:00
cinap_lenrek 4c8d2b0ebf devlml: use 64-bit physical addresses 2020-06-06 16:31:39 +02:00
cinap_lenrek 7db23bb2f0 audiosb16: cleanup audioprobe(), cast ISAConf.port to ulong 2020-06-06 16:31:07 +02:00
cinap_lenrek 652508728d audioac97: use 64-bit physical addresses 2020-06-06 16:25:00 +02:00
cinap_lenrek 966cf77439 audiohda: use 64-bit physical addresses, check pci membar types 2020-06-06 16:23:58 +02:00
cinap_lenrek aff63ef284 pc/pcmciamodem: cast i/o port to ulong 2020-06-06 16:21:42 +02:00
cinap_lenrek 7347012d42 pc/pmmc: check pci membar type 2020-06-06 16:19:25 +02:00
cinap_lenrek e49d187dff uartaxp: use 64-bit physical addresses and check pci membar types 2020-06-06 16:18:52 +02:00
cinap_lenrek 403fef45c1 pc/wavelan: print Ether.port as 64-bit value 2020-06-06 16:18:06 +02:00
cinap_lenrek 13963cd5e0 sd53c8xx: use 64-bit physical addresses 2020-06-06 16:16:48 +02:00
cinap_lenrek 8003f4f00f sdmv50xx: use 64-bit physical addresses and check pci membar type 2020-06-06 16:16:03 +02:00
cinap_lenrek 15e90cedc1 sdiahci: use 64-bit physical addresses 2020-06-06 16:14:58 +02:00
cinap_lenrek caf8df6478 sdodin: use 64-bit physical addresses and check pci membar type 2020-06-06 16:14:02 +02:00
cinap_lenrek 2907f7ffc4 sdnvme: make sure pci membar type is memory 2020-06-06 16:10:58 +02:00
cinap_lenrek dd2d6c9430 usbuhci: make sure pci membar type is i/o 2020-06-06 16:10:04 +02:00
cinap_lenrek a3626a6efa usbehcipc: use 64-bit physical addresses and check pci membar type 2020-06-06 16:05:40 +02:00
cinap_lenrek 8243b6600f pc/ether*: use 64-bit physical addresses and check pci membar types and sizes 2020-06-06 16:04:24 +02:00
cinap_lenrek 3bebd3f5e2 pc/vga*: use 64-bit physical addresses and check pci membar types and sizes 2020-06-06 15:58:18 +02:00
cinap_lenrek a8f64e53fe archacpi: use 64-bit uvlong for physical addresses 2020-06-06 15:44:17 +02:00
cinap_lenrek 6184a4ef2e devvga: use 64-bit physical addresses for framebuffer 2020-06-06 15:23:50 +02:00
cinap_lenrek 182e18ecff devpccard: use 64-bit physical addresses 2020-06-06 15:21:27 +02:00
cinap_lenrek 4eeaedbcaf usbxhci: use 64-bit physical addresses 2020-06-06 15:18:18 +02:00
cinap_lenrek b6becc7a64 devpnp, devether, devusb: cast ISAConf.port to uvlong (for 32-bit implementations)
The ISAConf.port might still be 32-bit on some archs.
2020-06-06 15:17:08 +02:00
cinap_lenrek 6ae50ce330 devusb: print Hci.port as 64-bit uvlong 2020-06-06 15:12:50 +02:00
cinap_lenrek d4213dbce5 devether: print Ether.port as 64-bit uvlong 2020-06-06 15:11:56 +02:00
cinap_lenrek 0a96d33a1c devpnp: print pci membar as 64-bit uvlong 2020-06-06 15:10:23 +02:00
cinap_lenrek 7bf5c61ea5 bcm64: bring pci code in line with the pc/pc64 2020-06-06 15:06:07 +02:00
cinap_lenrek 142bb6d5cf bcm64: use uvlong for ISAConf.port 2020-06-06 15:01:56 +02:00
cinap_lenrek c7d9da8f5a bcm64: use 64-bit uvlong physical address in vmap() 2020-06-06 15:01:20 +02:00
cinap_lenrek 3bcc34f276 pc, pc64: implement 64-bit pci membar support 2020-06-06 14:58:20 +02:00
cinap_lenrek 93f6ce24f4 pc, pc64: use 64-bit physical addresses for ISAConf.port 2020-06-06 14:52:16 +02:00
cinap_lenrek 21e4d88a51 pc, pc64: use 64-bit physical addresses for vmap() and upaalloc() 2020-06-06 14:43:24 +02:00
Ori Bernstein 702bb7a508 ape: add missing rerrstr.c 2020-06-05 18:52:22 -07:00
Ori Bernstein f08e95cd93 ape: make libplumb available under ape.
This adds the mkfiles and plumb.h to ape,
similar to how libdraw is made available.
This is used for ports such as netsurf.
2020-06-05 11:28:47 -07:00
Ori Bernstein 2327b48d77 aux/getflags: fix named rune arguments.
Flags can be runes. That means that we can't just
look at p[1] to decide if we have a named argument,
we need to look one rune forward. This change
does that.
2020-06-04 11:41:03 -07:00
cinap_lenrek 5f3e72eb84 merge 2020-06-01 00:07:01 +02:00
kvik 8918bd5981 acme: implement 'scratch' ctl command (thanks Drew DeVault)
The new command marks the target window as a scratch window -- a window
whose state cannot be "dirtied" by changes made to its body, therefore
avoiding warnings about unsaved changes when deleting the window or
exiting acme.

Existing examples of scratch windows are error, directory, and guide
windows, whose scratchness is set internally.

With the new command users and programs alike can create their own
scratch windows.  This is put to use in acme's own win(1).
2020-05-31 22:39:46 +02:00
cinap_lenrek 94916808dd kernel: remove unused segment argument in freepte() 2020-05-31 17:25:16 +02:00
cinap_lenrek 30bf1c45ca pc, xen: make PAT support optional (for xen) 2020-05-31 14:32:19 +02:00
Ori Bernstein 5cd7f7b0ec ape/libdraw: add missing eenter (thanks phil9) 2020-05-30 10:06:21 -07:00
cinap_lenrek 07a1df8c3a imap4d: reject invalid month in date2tm() 2020-05-30 13:03:05 +02:00
cinap_lenrek a48b462e44 rc: avoid forking for final command that has variable assignments (to get $apid right)
basically, we want the following commands to print
the same pid twice:

rc -c 'cat /dev/pid &;echo $apid'

vs:

rc -c 'a=1 cat /dev/pid &;echo $apid'

basically, Xsimple() calls exitnext() to determine if
a simple command should be promoted to exec, by peeking
ahead into the code and searching for Xexit instruction.

Xexit might not follow immediately after the Xsimple
instruction because of redirections, which exitnext()
would skip.

but it would not skip the Xunlocal instructions that
where added by the variable assignment.
2020-05-30 02:03:18 +02:00
cinap_lenrek 0e97c8d1d7 ip/cifsd: add FIND_FIRST2 SMB_FIND_FILE_FULL_DIRECTORY_INFO info level 2020-05-27 00:09:46 +02:00
cinap_lenrek b72af6a27d sshnet: prevent ssh process from keeping the mount alive 2020-05-26 21:37:25 +02:00
cinap_lenrek 153fcabb00 pc, pc64: fix wrong mtrr physmask() for machines without extended address size msr 2020-05-24 17:50:37 +02:00
cinap_lenrek 9960a125a3 awk: fix race condition with sub-mk in mkfile
the maketab helper program was generated in parallel, which
had a dependency to y.tab.h which lead to yacc running
twice in parallel.

this removes the dependency to y.tab.h in the virtual
maketab.$objtype target to prevent this race condition.

the dependency to y.tab.h is resolved in the main mk at the
$cputype.maketab target which serializes with the other
targets.
2020-05-24 16:00:45 +02:00
cinap_lenrek f59101231a usbehci: release ctlr ilock before calling pollcheck() 2020-05-24 02:43:21 +02:00
cinap_lenrek 9b28790494 merge 2020-05-24 02:12:47 +02:00
cinap_lenrek 3869d7a843 usbehci: avoid kproc() while holding poll lock 2020-05-24 02:11:37 +02:00
cinap_lenrek 81918373d2 merge 2020-05-23 23:32:24 +02:00
cinap_lenrek a54804ed24 ip/tinc: accept udp connection from any udp source port
the remote host might be behind a NAT which translates the
source port, so if no host could be found, lookup the ip
address only.
2020-05-23 23:31:11 +02:00
Sigrid a8e4b50cb2 paint: change colors in the palette with button 3 2020-05-23 20:41:20 +02:00
cinap_lenrek ec737b6a2e libaml: implement ToDecimalString and ToHexString operations 2020-05-23 17:44:30 +02:00
cinap_lenrek b86bb35c7d pc, pc64: do page attribute table (PAT) init early in cpuidentify()
the page attribute table was initialized in mmuinit(), which is
too late for bootscreen(). So now we check for PAT support and
insert the write-combine entry early in cpuidentify().

this might have been the cause of some slow EFI framebuffers on
machines with overlapping or insufficient MTRR entries.
2020-05-22 23:58:24 +02:00
cinap_lenrek 0002fd0cf7 libc/arm64: work arround linker bug for cas()
at the _cas0 label, the linker would generate spurious stack
adjustment before the return:

atexitdont+0x84 0x000000000003614c	CLREX	$0xf
atexitdont+0x88 0x0000000000036150	MOVW	R31,R0
atexitdont+0x8c 0x0000000000036154	MOV	(SP)16!,R30 <- ????????????
atexitdont+0x90 0x0000000000036158	RETURN

the work arround is to move the code into its own cas0
text symbol.

this fixes impossible cwfs crashes in srvi().
2020-05-17 23:46:09 +02:00
cinap_lenrek b599dc0e54 7l: handle dupok flag in TEXT/GLOBL data 2020-05-17 19:08:10 +02:00
cinap_lenrek 8550a2adb5 7l: fix mistake 2020-05-16 16:26:09 +02:00
Ori Bernstein bd4b6bda9b #pragma ref no longer exists
It appears to be an antiquated form of 'USED(x)'
2020-05-15 16:56:59 -07:00
Ori Bernstein 78aec6d5c6 Fix scans of more than one character in %[]
This got broken in d8e877a89dae, where we returned 0 on the
first mismatch; we want to return 0 only when we consumed no
characters.
2020-05-15 16:46:20 -07:00
Ori Bernstein ed4645979c stop fiddling with path construction.
There's fd2path, which gives back the full path directly.
This makes the code even simpler.
2020-05-13 18:50:01 -07:00
Ori Bernstein d332f8a9b5 fix yacc crash with absolute paths
When passing an absolute file path to yacc, we would skip
initializing inpath, leaving it null. This would cause Bopen
to die. We would similarly fail to report an error if we tried
to get the current working directory, and then die when
constructing inpath.

This fixes both cases.
2020-05-13 08:42:00 -07:00
cinap_lenrek 1c4c82277e ape: fix name clash, have to use _SLEEP syscall instead of ape sleep in plan9 code (thanks jamos)
this fixes etimer() from ape built libdraw as posix sleep() uses
seconds while plan9 uses miliseconds.
2020-05-13 00:17:07 +02:00
cinap_lenrek 8ca102d42e cc: dont export gethunk(), hunk, nhunk and thunk 2020-05-12 23:18:48 +02:00
cinap_lenrek 34cf2725d2 cc: get rid of hunk pointer fiddling and just use alloc() 2020-05-12 22:45:05 +02:00
cinap_lenrek ecdf3f921e ?l: remove direct hunk manipulation from linkers, just call malloc()
as with recent changes, cc's malloc() could make the hunk pointer
misaligned. in the the compilers, the hunk pointer is used directly
by the lexer with no effort to to keep the hunk pointer aligned.

alloc/malloc still return aligned pointers, but hunk itself can
be on a odd address after allocation of a odd sized amount of bytes.

however, in the linkers, this assumption appears to be differnet. as
most allocations mostly allocate padded structures. however, symbol
lookup allocates strings on byte-size ganularity and the cc's malloc
would misalign the hunk pointer after the malloc() call. while the
rest of the code assumed hunk pointer was always aligned.

this change removes all the hunk pointer fiddling from the linker,
and we just call malloc() (which will use the fast implmenentation
of cc, and should not really make much of a performance difference).
2020-05-12 22:04:30 +02:00
Ori Bernstein 73f38fc546 [ape] add missing conversion flags for scanf
We're missing type flags for:

	hh: char
	ll: vlong
	z:  size_t
	t:  ptrdiff_t
	j:  intmax_t

The lack of '%lld' was causing us to fail when parsing
timezone files. This brings us in line with the specifiers
in the C99 standard, section 7.19.6.2p11
2020-05-12 10:48:33 -07:00
cinap_lenrek 27fc79b04b devip: fix ifc recursive rlock() deadlock
ipiput4() and ipiput6() are called with the incoming interface rlocked
while ipoput4() and ipoput6() also rlock() the outgoing interface once
a route has been found. it is common that the incoming and outgoing
interfaces are the same recusive rlocking().

the deadlock happens when a reader holds the rlock for the incoming interface,
then ip/ipconfig tries to add a new address, trying to wlock the interface.
as there are still active readers on the ifc, ip/ipconfig process gets queued
on the inteface RWlock.

now the reader finds the outgoing route which has the same interface as the
incoming packet and tries to rlock the ifc again. but now theres a writer
queued, so we also go to sleep waiting four outselfs to release the lock.

the solution is to never wait for the outgoing interface rlock, but instead
use non-queueing canrlock() and if it cannot be acquired, discard the packet.
2020-05-10 22:51:40 +02:00
cinap_lenrek dbfec06bf1 kernel: fix checkpages() and segflush() on SG_PHYSICAL type segments
do not touch s->map on SG_PHYSICAL type segments as they do
not have a pte map (s->mapsize == 0 && s->map == nil).

also remove the SG_PHYSICAL switch in freepte(), this is never
reached.
2020-05-10 16:54:42 +02:00
kvik 0099db7b5b merge 2020-05-10 03:24:19 +02:00
kvik 1c3a6fc67e acme: add missed error checks 2020-05-10 03:18:57 +02:00
cinap_lenrek 662aff21a8 merge 2020-05-10 02:44:37 +02:00
cinap_lenrek c474179f9a usbxhci: fix wrong control endpoint 0 output device context address
the calculation for the control endpoint0 output device context
missed the context size scaling shift, resulting in botched
stall handling as we would not read the correct endpoint status
value.

note, this calculation only affected control endpoint 0, which
was handled separately from all other endpoints.
2020-05-10 02:43:39 +02:00
Ori Bernstein bfc8cdfff5 fix '%[]' specifiers and '%n' (thanks phil9)
When a match() fails, we need to unget the character we
tried to match against, rather than leaving it consumed.

Also, we can't break out of a conversion before we reach
the end of a format string, because things like the '%n'
conversion do not consume anything, and should still be
handled.
2020-05-09 15:10:39 -07:00
kvik 758edf2b14 nusb/kb: add quirks for Elecom HUGE trackball
As said in the code comment:

	Elecom trackball report descriptor lies by
	omission, failing to mention all its buttons.
	We patch the descriptor with a correct count
	which lets us parse full reports. Tested with:
		Elecom HUGE (M-HT1DRBK, M-HT1URBK)

The descriptor fixup is adapted from Linux kernel:
	drivers/hid/hid-elecom.c
in which a more detailed account of why and how this
works may be found.

A followup change to nusb/kb will be needed to expose
these additional events for potential remapping.
2020-05-08 20:49:11 +02:00
cinap_lenrek 2c3e60d95b merge 2020-05-07 23:28:55 +02:00
cinap_lenrek 04066fe973 bcm64: fix kernels cmpswap() function
spectacular bug. cmpswap() had a sign extension bug
using sign extending MOV to load the old compare
value and LDXRW using zero extension while the CMP
instruction compared 64 bit registers.

this caused cmpswap with negative old value always
to fail.

interestingly, libc's version of this function was
fine.
2020-05-07 23:27:27 +02:00
Ori Bernstein ec4011acf7 fix typo: mouse->xy, not w->mc.xy 2020-05-07 13:23:15 -07:00
kvik 6d25e194e2 aux/getflags: remove rogue debug print 2020-05-07 18:37:08 +02:00
kvik ccf5d3fb9d aux/getflags: improve flagfmt parser
This makes the flagfmt parser more robust and accepting
a looser input language — namely by allowing whitespace
around specifier fields and ignoring any empty fields.

Long flagfmts can thus be pleasingly displayed:

	flagfmt='
		a, b, c, C:cache,
		m:mtpt mountpoint,
		s:srvn srvname'
2020-05-07 00:10:09 +02:00
Ori Bernstein 0dc9c8d019 Reset click count on mouse motion. 2020-05-06 13:38:39 -07:00
cinap_lenrek ac88ce4f7f make bind(2) error handling consistent
The mount() and bind() syscalls return -1 on error,
and the mountid sequence number on success.

The manpage states that the mountid sequence number
is a positive integer, but the kernels implementation
currently uses a unsigned 32-bit integer and does not
guarantee that the mountid will not become negative.

Most code just cares about the error, so test for
the -1 error value only.
2020-05-02 17:32:01 +02:00
cinap_lenrek 7ff6ea0f70 libdraw: fix mount() error handling in newwindow() 2020-05-02 17:05:17 +02:00
cinap_lenrek 19cc46bc5e sed: accept and ignore -E and -r flags for unix compatibility 2020-05-02 16:56:52 +02:00
cinap_lenrek d0c87bada6 ip/cifsd: implement primitive per-share unix id mapping for wstat() 2020-05-02 16:53:52 +02:00
cinap_lenrek badbf50b0c merge 2020-05-02 15:34:00 +02:00
cinap_lenrek 8e2cfc0464 ether82543gc, ether82557, ethervirtio: do kproc() call ouside of spinlock 2020-05-02 15:32:19 +02:00
Ori Bernstein eb73718c25 merge 2020-04-28 20:51:19 -07:00
Ori Bernstein 9b8af27299 facelift for mothra: flat ui is in.
Remove false 3d, add borders for visual separation between
content area and navigation area.
2020-04-28 20:50:10 -07:00
Sigrid 3bdf242555 libsec/base58enc: null-terminate the result 2020-04-28 12:49:05 +02:00
Ori Bernstein dcf96a006d missing headers rate a FATAL. 2020-04-27 20:13:16 -07:00
cinap_lenrek 39c3fd117a lib9p: reject reads on closed fids and writes on directories
mischief provided the following test that shows the issue:

ramfs -S crash

aux/9pcon /srv/crash <<EOF
Tversion 8192 9P2000
Tattach 0 -1 $user ''
Tcreate 0 dir 020000000777 0
Tattach 5 -1 $user ''
Twalk 5 6 dir
Tread 6 0 512
EOF

the problem is that lib9p wrongly allowed reads on closed fids,
due to the permission check only considering the lower 2 bits.
a closed fid has fid->omode == -1 and it would pass on read for:

(-1 & 3) == 3 == OEXEC

the following change explicitely checks for for the closed case
and also rejects writes on directories (they are rejected on
open/create, but a broken 9p client could still issue the request).
2020-04-27 19:55:42 +02:00
cinap_lenrek 00bfe3ec2b merge 2020-04-26 19:55:53 +02:00
cinap_lenrek 61a062ee9f kernel: improve page reclaimation strategy and locking
when reclaiming pages from an image, always reclaim all
the hash chains equally. that way, we avoid being biased
towards the chains at the start of the Image.pghash[] array.

images can be in two states: active or inactive. inactive
images are the ones which are not used by program while
active ones aare.

when reclaiming pages, we should try to reclaim pages
from inactive images first and only if that set becomes
exhausted attempt to release text pages and attempt to
reclaim pages from active images.

when we run out of Image structures, it makes only sense
to reclaim pages from inactive images, as reclaiming pages
from active ones will never free any Image structures.

change putimage() to require a image already locked and
make it unlock the image. this avoids many pointless
unlock()/lock() sequences as all callers of putimage()
already had the image locked.
2020-04-26 19:54:46 +02:00
qwx 0fc1abc73d mothra: fix a few errors in previous patch
- nil check pl_blue allocation, and don't do it every time pl_rtdraw is called
- fix re-adding previously removed flushimage calls
- correct format for pointer
- sysfatal in pl_drawinit on error
2020-04-26 19:43:10 +02:00
Ori Bernstein c6f7989176 copy all the tokens from the tokenrows with a paste.
if we do 'CAT(foo bar, baz quux)', the resulting token row
should have 3 tokens: 'foo', 'barbaz', 'quux'.

tested by jonasa, rebuilding /sys/src, perl, netsurf, and nuklear.
2020-04-26 09:32:42 -07:00
Ori Bernstein d6598a2a31 Support for neo2 keyboard layout
Modify aux/kbdfs to work with neo2 layout.
- add new modifier, increase limit on layers.
- Add Kaltgr for mod3
- Add mod4

This change only implements the alphanumeric
block of the keyboard in the kbmap, as neo2
is mainly used for blind typing and is not
needed that much anywhere else, this leaves
the numpad like it is.

(Thanks, jstsmthrgk@jstsmthrgk.eu)
2020-04-25 20:46:45 -07:00
stanley lieber 2614fa02f7 mothra: make user interface monochrome 2020-04-25 21:55:43 -04:00
stanley lieber 9a7c5d5653 mothra: remove extraneous lines and decoration (fake 3d). patch extracted from my forked mess by Ori_B. 2020-04-25 21:53:54 -04:00
Ori Bernstein 60c34ebb2d tweak selection criteria
grow selection from point of click, not start of selection region.
starting at the beginning of the selection region causes the match
logic to kick in, which is confusing.
2020-04-25 15:18:04 -07:00
cinap_lenrek 7feab4dc59 cc: simplify macexpand() and off-by-one error
the caller of macexpand() needs one more byte in
the buffer to append peekc.

make macexpand() actually check for buffer overflow.

just use strdup() to duplicate include file name
instead of the hunk dance.

move GETC() macro in cc.h
2020-04-25 22:16:44 +02:00
Ori Bernstein 4adb1d68d1 fix typos in time calculation
the results of the time calculation were garbled -- and
apparently negative on my system when testing, so the
test passed when it shouldn't have.
2020-04-25 11:00:27 -07:00
Ori Bernstein d52d7bc121 Backed out changeset 2737b9af622b
not what I wanted to commit.
2020-04-25 10:57:17 -07:00
Ori Bernstein 2de164c51d fix typos in time calculation
the results of the time calculation were garbled -- and
apparently negative on my system when testing, so the
test passed when it shouldn't have.
2020-04-25 10:43:39 -07:00
Ori Bernstein 5d7e9bee3c Bump protocol version for Ttclick 2020-04-25 09:38:02 -07:00
Ori Bernstein 8bc290cc0f triple click selection in acme
see the last 2 commits.
2020-04-25 08:59:14 -07:00
Ori Bernstein 6f44393958 triple click selection in rio
same as sam and vt, three clicks selects a
whitespace-delimited line.
2020-04-25 08:58:24 -07:00
Ori Bernstein f616a0c1bd triple click selection in sam
three clicks selects a whitespace-delimited line.
2020-04-25 08:57:26 -07:00
cinap_lenrek 4fb7462bd5 pc, pc64: use softscreen double buffering for *bootscreen= framebuffer
it is probably almost always a good idea to use
double buffering with a unaccelerated framebuffer.
2020-04-24 20:26:38 +02:00
cinap_lenrek 759656ad4c bcm, bcm64: dancing to the drum of the linux clowns for device tree memory size detection (thanks kenji)
looks like linux changed the device tree names for
the memory node:

4b17654f51 (diff-ac03c9402b807c11d42edc9e8d03dfc7)

this fixes the memory size detection with latest firmware
on raspberry pi4-b (4GB) for kenji.
2020-04-22 19:57:25 +02:00
stanley lieber 27743b56d8 mothra.c: add Plumb menu item, and update man page. my original changes sanity-checked by Ori_B. 2020-04-21 21:12:32 -04:00
stanley lieber bd78cd2dd3 rdhtml.c: restore original fonts. dejavusans was my change, my fault. it never looked right outside of drawterm on osx (mea culpa). this is easy to change for anyone who prefers something else, but it's difficult to imagine native users preferring our very fuzzy dejavusans to anything else. 2020-04-21 21:09:12 -04:00
Ori Bernstein eb266ded8d remove unused macro from chan.c 2020-04-21 17:32:02 -07:00
cinap_lenrek 81c9ede53f samterm: don't scroll invisible (command) window (thanks umbraticus)
with scroll-wheel scrolling, this case can happen with the
command window:

umbraticus → cinap: create fullscreen file buffer by right-clicking in cmd window
2020-04-22 00:55:58 +02:00
cinap_lenrek 2c317dccea merge 2020-04-20 00:08:35 +02:00
cinap_lenrek 8499401ada ?a, ?c: fix macro debug prints 2020-04-19 23:57:33 +02:00
cinap_lenrek 313216e6fb ?c: get rid of sprint(), strcpy() and strcat()/strncat(), cleanup 2020-04-19 23:51:18 +02:00
cinap_lenrek b43720e3f7 [257]l: cleanup fmt routines, replace sprint() 2020-04-19 23:47:23 +02:00
cinap_lenrek c66b3739ac cc: cc.h changes needed by previous commit 2020-04-19 23:42:02 +02:00
cinap_lenrek 0d59a2358a ?a, cc: fix buffer overflows in built-in preprocessor (macbody)
add a buffer size argument to macexpand() and check for
overflow.

check for overflow when parsing #include directives.
2020-04-19 23:37:05 +02:00
cinap_lenrek e24bfa4941 ?a: catch symb[NSYMB] buffer overflow in lexer, cleanup, assume thechar is a rune 2020-04-19 22:59:21 +02:00
cinap_lenrek 3f87ffea44 cc: get rid of sprint() and temporary buffer for type conversion fuction
slookup() copies to symb, so use the symb[NSYMB] buffer directly
to declare type conversion functions and get rid of the arbitrary
sized local buffer. replace sprint() with snprint().
2020-04-19 20:44:19 +02:00
Ori Bernstein 260d1eaaa7 Make priority array max size explicit.
we were implicitly depending on UMINUS being the last entry
in the operator table -- that's fragile.
2020-04-19 11:26:31 -07:00
Ori Bernstein 15a32f0683 fix cpp operator associativity
We used to treat all operators as right associative,
which means that we would evaluate them incorrecty.
For example, '2 - 1 + 1' would evaluate as '2 - (1 + 2)',
instead of '(2 - 1) + 1'.

This adds an assoc parameter to struct pri, and then uses
it to decide how to evaluate operators.
2020-04-19 11:15:13 -07:00
Ori Bernstein 2c596d0021 merge 2020-04-19 09:03:35 -07:00
Ori Bernstein 21831527cb dont overflow the stack
when pushing expressions in cpp, particularly complex ones could
overflow the stack and silently corrupt our data structures. add
checks when we push, and bump the stack size up.
2020-04-19 09:02:21 -07:00
rgl 3a79916c9b libmemdraw: remove inexistent build targets 2020-04-19 15:30:58 +02:00
cinap_lenrek 34a1b1bb22 ?c: fix Bconv() misusage of strncat() 2020-04-19 04:33:07 +02:00
cinap_lenrek e6634fbd0c 6c: conserve registers for floating point operations
for floating point operations, reuse the return register
on the right hand side if it has higher complex number
than the left hand side to conserve registers.

this makes the following code compile, that was previously
run out of floating point register:

float
f(float r[15])
{
	return (r[0] + (r[1] * (r[2] + r[3] * (r[4] + r[5] * (r[6] + r[7] * (r[8] + r[9] * (r[10] + r[11] * (r[12] + r[13] * r[14]))))))));
}

the downside is that this produces extra move operations.
2020-04-19 01:25:35 +02:00
Ori Bernstein 380adf8b48 aux/getflags: support named flags
When using aux/getflags, it produces unnecessarily obscure
names for the flags. This allows the caller of aux/getflags
to support arbitrary names.
2020-04-18 15:38:38 -07:00
cinap_lenrek 8ae77554dd 7l, ql: dont assume . is in the path for running mkcname (thanks sam-d) 2020-04-18 19:07:06 +02:00
cinap_lenrek 94bd7700aa rc: fix code serialization for PIPEFD (thanks BurnZeZ)
BurnZeZ reported this the other day. It seems like if we have
a pipeline that looks like:

	fn foo{cat < <{echo hi}}

then the '<' will get merged in /env/'fn#foo'. This change
fixes pcmd to add a space. It looks to me like this is the
only token that can get merged this way by pcmd.
2020-04-18 18:20:34 +02:00
cinap_lenrek 0e96bbd073 merge 2020-04-12 16:12:41 +02:00
cinap_lenrek 1aa80c1d10 kernel: remove unused mem2bl() prototype 2020-04-12 16:11:41 +02:00
Ori Bernstein d68f4adeba merge 2020-04-11 14:20:53 -07:00
Ori Bernstein 2d1dac07f7 triple-click to select non-whitespace segment
The previous patch to plumb non-whitespace segments was
confusing due to lack of visual feedback. This removes
the empty selecton plumb behavior, and instead makes
triple clicking work to get a plumbable selection.
2020-04-11 14:19:46 -07:00
cinap_lenrek 3cdbbcd859 merge 2020-04-11 22:37:30 +02:00
cinap_lenrek 0c7da78f45 ip/ipconfig: ignore default routes targeting ourselfs
when running ndb configuration, we might inherit the ipgw=
attribute from the ipnet pointing to our own ip address
(we are the default gateway). ignore such entries.

do not add default routes with gateway equal to our own
local (ip4) or link-local ip address (ipv6).
2020-04-11 22:36:19 +02:00
Ori Bernstein ebb3e31118 vt plumbing: don't require selection
Plumbing text in vt requires selecting the text that you
want to plumb precisely. This patch makes plumbing behave
the same way that it does in rio.
2020-04-11 11:56:04 -07:00
cinap_lenrek a7dab2728b ip/ipconfig: resolve ipgw to an ip address as neccesary (thanks k0ga)
ndb(6) states that ipgw needs to be an ip address,
however, attempting to resolve ipgw is not difficult
and already done by ip/dhcpd.
2020-04-11 18:09:48 +02:00
cinap_lenrek d8545806fc vl: remove unused mysbrk() prototype 2020-04-11 14:20:41 +02:00
cinap_lenrek 550b6d1aad qa: remove ALLOC() and ALLOCN() macros 2020-04-11 14:20:13 +02:00
cinap_lenrek ca9d65e40b cc: remove mysbrk(), exponentially increase gethunk() allocation delta
mysbrk() was only used in gethunk() and should not be
called by anyone, so dont export the symbol.

simplify gethunk() using brk().

double allocation size on each call until we reach
1000*NHUNK.

use signed long for nhunk as alignment rountin might
make it negative and handle that case.
2020-04-11 14:19:35 +02:00
cinap_lenrek 49c159b50f 6c: remove mystery sys.c file 2020-04-11 05:19:11 +02:00
cinap_lenrek 1b8a569417 cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compat
for gethunk() to work, all allocators have to use it,
including allocations done by libc thru malloc(),
so the fake allocation functions are mandatory for
everyone.

to avoid duplication the code is moved to cc/compat
and prototypes provided in new cc/compat.h header.
2020-04-11 05:03:49 +02:00
cinap_lenrek 9d46360c9d backout the gethunk() again, as that breaks the assemblers
the assemblers share gethunk() cc/macbody but are compiled
without compat.c, so calls such as getenv() trigger malloc()
which does its own sbrk() calls, breaking the continuity
of the hunk.

so this change needs another revision. until then, this is
backed out.
2020-04-11 01:26:36 +02:00
cinap_lenrek 1d3644a168 cc, ?l: fix gethunk() to actually grow allocation
the compilers and linkers use ther own memory allocator.
free memory is between hunk and hunk+nhunk. allocation
works by checking if nhunk is bigger or equal to the
amount needed, and if not, repeatedly call gethunk()
until there is. after that, the allocated amount is added
from hunk and subtracted from nhunk by the user.

the problem was when the needed amount was bigger than
the default NHUNK size gethunk() allocates per call.
gethunk() would not actually grow nhunk, but instead
just set hunk and nhunk variables to the last allocated
block. this resulted in a infinite loop of calls to
gethunk() until sbrk() would hit the maximum size for
the BSS segment.

this change makes gethunk() actually grow the hunk space,
increasing nhunk, and only updating hunk when nhunk was
previously zero. we assume that mysbrk() retuns increasing
addresses and that the space between the previous hunk+nhunk
and the new block base returned by mysbrk() is usable.
2020-04-10 23:11:25 +02:00
cinap_lenrek e610ffaf1b merge 2020-04-10 22:26:37 +02:00
cinap_lenrek a39cc60c52 cc: backout gethunk() change
the real problem is that gethunk() does not grow the allocation
but just allocates a new hunk, so repeated calls to gethunk()
wont make nhunk grow to satisfy the allocation.

this will be fixed in a upcoming commit.
2020-04-10 22:25:29 +02:00
Sigrid 2cdf1a3c79 cc, ?a, ?l: change thunk type to uintptr 2020-04-10 20:38:45 +02:00
Sigrid 6018316eef cc: sbrk in bigger chunks as it grows, so it gets a chance to use the ram/swap available 2020-04-10 17:19:44 +02:00
cinap_lenrek 1fe3143e4c kernel: cleanup the software mouse cursor mess
The swcursor used a 32x32 image for saving/restoring
screen contents for no reason.

Add a doflush argument to swcursorhide(), so that
disabling software cursor with a double buffered
softscreen is properly hidden. The doflush parameter
should be set to 0 in all other cases as swcursordraw()
will flushes both (current and previours) locations.

Make sure swcursorinit() and swcursorhide() clear the
visibility flag, even when gscreen is nil.

Remove the cursor locking and just do everything within
the drawlock. All cursor functions such as curson(),
cursoff() and setcursor() will be called drawlock
locked. This also means &cursor can be read.

Fix devmouse cursor reads and writes. We now have the
global cursor variable that is only modified under
the drawlock. So copy under drawlock.

Move the pc software cursor implementation into vgasoft
driver, so screen.c does not need to handle it as
a special case.

Remove unused functions such as drawhasclients().
2020-04-10 17:12:51 +02:00
cinap_lenrek 7b309d2e28 pc, pc64: remove "got unassigned irq" prints
most pc's are multiprocessors these days, that use apic or
msi interrupts, then the irq does not matter anymore. and
uefi does not even assign irq to pci devices anymore. if
we have a problem enabling an interrupt, we will print.
2020-04-09 13:05:10 +02:00
cinap_lenrek 6041d2048c 9bootpxe: simplify 2020-04-08 23:48:09 +02:00
cinap_lenrek abc5a66c56 9bootpxe: continues the war against random DHCPv6 DUIDs
Some UEFI implementations use random UUID based DUID instead of
ethernet address, but use ethernet derived link-local addresses.
So extract the MAC from our IPv6 address.
2020-04-08 23:37:38 +02:00
cinap_lenrek 665b78da23 merge 2020-04-06 01:31:35 +02:00
cinap_lenrek 9e2344a5be pc64: remove rampage() nil check
rampage() never returns nil
2020-04-06 01:29:12 +02:00
cinap_lenrek a35cd0f861 pc: zero rampage() memory (thanks LordCreepity)
memory returned by rampage() is not zeroed, so we have to
zero it ourselfs. apparently, this bug didnt show up as we
where zeroing conventional low memory before the new memory
map code. also rampage() never returns nil.
2020-04-06 01:28:34 +02:00
Alex Musolino 80fdafd1d6 file: try ismp4() before ismp3()
It is possible to find the mp3 sync word near the start of an mp4
file.  As such, file(1) could incorrectly identify some mp4s as mp3s.
2020-04-05 23:26:52 +09:30
cinap_lenrek 0ba0820070 dossrv: fix falloc() for >31 bit sector numbers (thanks sl) 2020-04-05 03:46:47 +02:00
cinap_lenrek ecba7822e3 nusb/usbd: fix portreset error handling
error handling in portreset() was wrong. we called closedev()
on the device without changing the reference.

just call portdetach() when the reset fails.
2020-04-05 03:05:06 +02:00
cinap_lenrek 315f20b9f4 nusb/audio: set frequency only when supported
before setting the sampling rate, check bit D0
"Sampling Frequency" in the audio class specific
endpoint descriptor.
2020-04-05 00:59:47 +02:00
cinap_lenrek f5352eb501 merge 2020-04-04 17:17:15 +02:00
cinap_lenrek 339112abc3 mtx, ppc: use proctab() to index into process table 2020-04-04 16:52:08 +02:00
cinap_lenrek 30cbaa5c48 kernel: remove scheddump() comment for delay() in */fns.h 2020-04-04 16:50:37 +02:00
cinap_lenrek 5f1b70f437 pc, pc64: new memory map code
This replaces the memory map code for both pc and pc64
kernels with a unified implementation using the new
portable memory map code.

The main motivation is to be robust against broken
e820 memory maps by the bios and delay the Conf.mem[]
allocation after archinit(), so mp and acpi tables
can be reserved and excluded from user memory.

There are a few changes:

new memreserve() function has been added for archinit()
to reserve bios and acpi tables.

upareserve() has been replaced by upaalloc(), which now
has an address argument.

umbrwmalloc() and umbmalloc() have been replaced by
umballoc().

both upaalloc() and umballoc() return physical addresses
or -1 on error. the physical address -1 is now used as
a sentinel value instead of 0 when dealing with physical
addresses.

archmp and archacpi now always use vmap() to access
the bios tables and reserve the ranges. more overflow
checks have been added.

ramscan() has been rewritten using vmap().

to handle the population of kernel memory, pc and pc64
now have pmap() and punmap() functions to do permanent
mappings.
2020-04-04 16:48:37 +02:00
cinap_lenrek 8debb0736e kernel: add portable memory map code (port/memmap.c)
This is a generic memory map for physical addresses. Entries
can be added with memmapadd() giving a range and a type.
Ranges can be allocated and freed from the map. The code
automatically resolves overlapping ranges by type priority.
2020-04-04 16:04:27 +02:00
cinap_lenrek 7451bb405d ether8390: remove unused variables 2020-04-04 15:55:48 +02:00
cinap_lenrek 6498ce3bf2 ether8003: use physical addresses for ISAConfig ether->mem
Fix the inconsistent use of ether->mem. Always use physical
addresses. Let ether8390 convert to virtual addresses using
KADDR() when we have to copy data in/out.
2020-04-04 15:47:50 +02:00
Alex Musolino ad3da2fac2 merge 2020-04-01 22:57:15 +10:30
Alex Musolino c393806718 upas/fs: fix sending of "delete" plumb messages
Broken by changeset 2cc069392228.
2020-04-01 22:49:19 +10:30
Sigrid 4756cf549a devkbd: bits bad! revert repeat/delay, better patches welcome 2020-04-01 11:31:19 +02:00
cinap_lenrek d3512f60df ip/dhcp6d: work arround non-ethernet based client duid
in ndb, we use the ethernet mac to identify the client.
in dhcpv6, there is just a uniqueue device id that
might even be generated randomly. to find the ethernet
address of a client, check the duid type and only use
it when the dudid is of type 1 (link layer) or 3 (link
layer address + time) and the link layer address type
is 1 (ethernet). otherwise, assume the source ip is
a link local address and extract it from that.

this hack works for thinkpad t495, which uses random
uuid based client duid.
2020-03-31 21:57:53 +02:00
cinap_lenrek 480ce0314e audiohda: add pci vid/did for AMD Raven HD Audio Controller (T495) 2020-03-31 19:00:32 +02:00
cinap_lenrek 4dcb3ce2ab xen: fix rebootcode linkage
need to strip the a.out header, just like with the pc
kernel.
2020-03-29 22:47:42 +02:00
BurnZeZ 11025d6f4a lib9p: fix re-use of root Qid when using createfile(); remove unused dirqidgen 2020-03-29 17:39:30 +00:00
Sigrid f5f37ba5eb pc64: enable uartpci (thanks taw9 for testing) 2020-03-29 19:28:39 +02:00
cinap_lenrek 1b8d87555a pc, pc64: ignore the 64-bit bar flag when reserving membar
a bar with bit 3 set means the bar is the low half of
a 64-bit wide bar.
2020-03-29 00:49:07 +01:00
cinap_lenrek 3c36cadefd pc: fix mp boot regression due mistake in mkfile
the previous mkfile had a sneaky hack that would use
sed to delete the first 2 lines of hex output to strip
the 32 byte long a.out header for apbootstrap and rebootcode.

use 8l -H3 flag to strip the header from the output file.
2020-03-29 00:44:09 +01:00
Sigrid 9014360921 kbd: add "repeat" file to set typematic repeat rate/delay on PS/2 keyboards 2020-03-28 15:37:48 +01:00
Alex Musolino 47e3c088c9 grep: fix handling of -b flag
Output buffering is automatically disabled when reading from stdin.
In this case, supplying the -b flag ought to be redundant.  However,
since Bflag was being XORed into the flag set - rather than simply
ORed - supplying -b would actually enable output buffering.
2020-03-26 18:24:39 +10:30
Ori Bernstein 3fe2924287 evaluate #if expressions using vlong
#if expressions are expected to be evaluated using intmax_t,
according to the C99 spec, 6.10.1 p3. On plan9, intmax_t maps
to vlong.
2020-03-23 09:18:44 -07:00
BurnZeZ aa5e86a8ca kbdfs: fix kbmapread() not accounting for reads smaller than the size of the line 2020-03-20 18:08:34 +00:00
Ori Bernstein 37b86df09f Improve the posix preprocessor.
This fixes token pasting, making it expand when
it should expand, and paste before expansion when
it should paste before expanding.

	#define CAT(a, b) a ## b
	#define BAR	3
	#define FOO	CAT(BAR, 3)
	FOO

now produces 33, while

	#define CAT(a, b) a ## b
	#define EOF	(-1)
	#define NOP(x)	x
	NOP(CAT(foo, EOF))
	CAT(,EOF)
	CAT(,)

produces

	fooEOF
	(-1)
	<empty>

respectively.
2020-03-17 22:03:25 -07:00
Ori Bernstein 52dc943702 fix ccom idempotency
ccom may be called multiple times on the same
node, via 'goto loop' calls from the commute
label, OADD, and a few other places.

Casts to void could null out the LHS of the
node, which would cause the compiler to crash
if the cast was revisited due to one of these
cases, because we tried frobbing n->left.

Now, if n->left is nil, we just return.w
2020-03-15 15:08:04 -07:00
Ori Bernstein 5bc9b0c3ca improve usage messages (thanks henesy)
Fix inconsistencies between programs and their usage
messages,  correct instances where information seems
to be missing or lost. This  includes missing arguments,
making usage consistent with manuals, and so on.
2020-03-10 10:09:34 -07:00
Ori Bernstein fc90f7a666 fix heredoc crash
we emitted an error on heredoc tags, but we
continued on, and added a heredoc entry to
the list, with a tag that we couldn't handle.

when processing this heredoc, rc would segfault.

fix: don't add a heredoc to the list on error.
2020-03-09 14:24:02 -07:00
Ori Bernstein 698837e715 fix alignment in ape malloc
We used to have a padding int in the structure
after the next pointer, to align it to 16 bytes.
On 64 bit architectures, the pointer was already
8 bits, so the padding misaligned things to 20
bytes.

This fixes it so that we're explcit about the
data alignment we want, instead of hoping that
the various sizes line up.
2020-03-09 08:02:22 -07:00
Sigrid 446e454c5a sam: ^ does not need current file 2020-03-09 13:58:41 +01:00
Sigrid 27f36483d4 sam: add $%dot (thanks kvik) 2020-03-09 13:21:50 +01:00
Ori Bernstein 50791b8755 add usage messages to auth/(enable disable status).
print useful message when user invokes these commands incorrectly
(thanks henesy)
2020-03-08 16:31:30 -07:00
cinap_lenrek e9e55a21f6 lib9p: implement automatic remove-on-close cleanup in postsharesrv(), remove postfd() and sharefd() functions
with the latest changes to shr(3), we can use ORCLOSE on
the control file to get the mount in the share automatically
removed when the server exits or something goes wrong during
postsharesrv().

do not expose postfd() and sharefd() functions. they where
undocumented and leak the control file descriptors.
2020-03-08 22:00:23 +01:00
cinap_lenrek 28f3a3aad8 boorc, nusbrc: fix wrong redirections after &
the rc & operator changes stdin to /dev/null, so we
have to do the <[0=1] inside the {}

this never showed up as an issue because many
fileservers just read 9p messages from standard
output.
2020-03-08 20:53:30 +01:00
cinap_lenrek f99b9cae6a devshr: unmount service on #σc/share/mount removal
when the control mountpoint side gets removed, close
mount channel immediately. this is usefull for implementing
automatic cleanup with ORCLOSE create mode.
2020-03-08 18:23:07 +01:00
cinap_lenrek fe39388250 nusb/usbd: cleanup processes on unmount
this makes sure that when postsharesrv() fails (for
example because the shr file already exists), the
worker process gets killed and all file descriptors
to devusb get closed.
2020-03-08 16:06:37 +01:00
cinap_lenrek a609c1a2f8 devproc: return process id when reading /proc/n/ctl file
allow reading the control file of a process and return
its pid number. if the process has exited, return an error.

this can be usefull as a way to test if a process is
still alive. and also makes it behave similar to
network protocol directories.

another side effect is that processes who erroneously
open the ctl file ORDWR would be allowed todo so as
along as they have write permission and the process is
not a kernel process.
2020-03-08 14:11:23 +01:00
cinap_lenrek 57741d473f games/playlistfs: open /proc/n/ctl OWRITE, not ORDWR 2020-03-08 13:13:25 +01:00
cinap_lenrek 5826140ce3 lib9p: restore previous behaviour of fd group sharing
it appears that too many fileservers rely on the fileserver
process sharing the filedescriptors with children of the
caller to postmntsrv() or threadpostmntsrv().

restoring previous behaviour for now.
2020-03-08 05:52:23 +01:00
cinap_lenrek 59fdb3a12c sshnet: fix fork race conditions
sshreadproc() needs to be started after opening the sshfd file
descriptor.

fsnetproc() needs to run in the same filedescriptor group as
the fileserver.
2020-03-08 04:54:37 +01:00
cinap_lenrek 2c53dd32b5 aux/realemu: fix exit code 2020-03-08 03:34:55 +01:00
cinap_lenrek cea9e2267a aux/realemu: run cpuproc in same fd group as fileserver 2020-03-08 03:25:35 +01:00
cinap_lenrek 7aaa481f9f aux/timesync: open /proc/n/ctl with OWRITE, not ORDWR 2020-03-08 03:12:00 +01:00
cinap_lenrek a0879abae4 devproc: don't allow /proc/$pid/ctl to be opens for reading 2020-03-07 23:58:47 +01:00