Commit Graph

6606 Commits (master)

Author SHA1 Message Date
cinap_lenrek 999e98b9b8 usbehci: use 64-bit base address, remove resetlck, simplify scanpci() 2021-01-17 11:55:39 +01:00
cinap_lenrek 3240008dd1 usbuhci: remove resetlk, simplify scanpci() 2021-01-17 11:53:50 +01:00
cinap_lenrek 87b1d454ed usbohci: use 64-bit io base address, disable interrupts before reset, remove resetlck 2021-01-17 11:51:59 +01:00
Sigrid 0f3ef52fd7 tweak: support showdata plumb action (thanks sirjofri) 2021-01-16 18:30:50 +01:00
Sigrid 7b12e8084a cal: use Sa/Su in all cases, also simplify the code 2021-01-12 21:08:12 +01:00
Sigrid 72f7609106 cal: fix -s 7 2021-01-12 13:32:38 +01:00
Sigrid 806f97a47b cal: add -s option to specify the starting day of the week 2021-01-12 13:23:37 +01:00
Sigrid 6103d6ed2c audio/flacenc: missed an argument in fprintf() 2021-01-12 11:15:18 +01:00
Sigrid b9f2050d59 libFLAC/mkfile: update version and build with -DNDEBUG 2021-01-11 16:58:04 +01:00
Sigrid c789c05480 libvorbis: fix free() called on a wrong pointer 2021-01-11 16:17:48 +01:00
Sigrid ce82f6750c audio/flacenc 2021-01-11 15:45:12 +01:00
cinap_lenrek 10237a22f1 merge 2021-01-10 20:46:07 +01:00
cinap_lenrek 069d27ba1d pc, pc64: revert addition of pcireset() call to pcicfginit()
Revert the change, as it causes system lockups on bootup
on some systems with USB OHCI controllers, suspected to be
caused by BIOS/SMM accessing the device as BIOS handover
has not been executed yet.

We might bring that back when the problem has is better
understood.
2021-01-10 20:44:58 +01:00
Ori Bernstein c207b78d07 libdraw: add bezierpts
This patch exposes the bezierpts function,
providing a way to get the points on a path,
similar how bezsplinepts gives them for b
splines.
2021-01-09 12:20:49 -08:00
Ori Bernstein 888c59c07e merge 2021-01-05 19:48:26 -08:00
Ori Bernstein 1787a8b990 acid: increase hash size (thanks jonas.amoson)
when loading large binaries such as netsurf, with many
symbols, our hash table fills up with collisions and
loading the symbol table gets very slow. Bumping it up
drops the time to lstk() in acid on netsurf from 4 minutes
to 8 seconds.
2021-01-05 19:37:26 -08:00
Alex Musolino 95b9b8863d qr: fix exit status
Call exits(0) instead of returning from main.  Also call sysfatal if
writing of image data fails.  Previously, qr(1) would exit with
default non-nil status "main" unconditionally as a result of returning
from main.
2021-01-05 22:36:03 +10:30
Sigrid 5991e01ed7 file: ftyp mp4* is video/mp4 as well 2021-01-01 22:58:05 +01:00
Ori Bernstein c3b30544e1 sort: fix memory leak (thanks Igor Boehm)
Free the last line that we examine when looping
through the lines in a file.
2021-01-01 11:48:39 -08:00
BurnZeZ fd1db35c4d cc: add a couple notes to the comments regarding flags 2020-12-29 19:38:59 +00:00
cinap_lenrek 97a55e03a7 libc/arm: open #c/sysstat file with OCEXEC (internal file descriptor) 2020-12-29 19:08:08 +01:00
cinap_lenrek fb08e3655e plumber: open rule files as OCEXEC, to avoid leaking them to sub commands 2020-12-29 18:45:42 +01:00
Sigrid b7b740a04c text2post: check font index for out of range 2020-12-28 21:21:22 +01:00
cinap_lenrek ceeb701a2b plumber: don't leak srvfd file descriptor into sub processes
Put OCEXEC flag on the srvfd so it wont be leaked
on sub-processes we spawn from plumb rules.
2020-12-28 21:00:15 +01:00
Sigrid 67672ffdc9 plumb: fix wrong click attribute offset (thanks umbraticus) 2020-12-28 12:24:47 +01:00
cinap_lenrek 0596178dd6 kbmap: avoid division by zero when window becomes too small 2020-12-27 23:39:28 +01:00
cinap_lenrek 0e632454e2 aux/vga: remove panning, add screen tilting support 2020-12-27 23:10:39 +01:00
cinap_lenrek 806353ec9e devvga: implement screen tilting, remove panning and overlays
Tilting allows using left/right rotated or invetrted display orientation.
This can be changed at runtime such as: echo tilt right > /dev/vgactl
This removes the old panning and vga overlays as they are only implemented
with some ancient vga controllers.
2020-12-27 23:08:59 +01:00
cinap_lenrek 874e71c8dc libauth: re-implement procsetuser() to use /proc instead of #c/user 2020-12-23 13:10:30 +01:00
cinap_lenrek ab103ba349 devproc: allow anyone to change user of its own processes to "none" 2020-12-23 13:09:31 +01:00
Sigrid 7bcdd1b5d8 libvorbis: 1.3.5 → 1.3.7 (fixes a bunch of CVE and other small issues) 2020-12-23 12:18:07 +01:00
cinap_lenrek a7a08647b6 ape: re-implement getlogin() by stating /proc/$pid/status 2020-12-23 02:32:13 +01:00
cinap_lenrek dced7255ec libc: re-implement getuser() by stating /proc/$pid/status
The idea is to avoid the magic files that contain
per process information in devcons when possible.
It will make it easier to deprecate them in the future.
2020-12-23 02:31:28 +01:00
cinap_lenrek f11526708e kw: use ethermii.c from port/ (thanks stuart) 2020-12-22 22:17:44 +01:00
cinap_lenrek 809a7402fc aout2uimage: fix missing \n in usage print (thanks james) 2020-12-22 19:33:49 +01:00
cinap_lenrek 157166d4fc kbdfs: fix mistake, remove leftover static user variable (thanks umbraticus and igor) 2020-12-22 16:36:45 +01:00
cinap_lenrek 29f60cace1 kernel: avoid palloc lock during mmurelease()
Previously, mmurelease() was always called with
palloc spinlock held.

This is unneccesary for some mmurelease()
implementations as they wont release pages
to the palloc pool.

This change removes pagechainhead() and
pagechaindone() and replaces them with just
freepages() call, which aquires the palloc
lock internally as needed.

freepages() avoids holding the palloc lock
while walking the linked list of pages,
avoding some lock contention.
2020-12-22 16:29:55 +01:00
cinap_lenrek 0ad4ceb8d0 kernel: make addbroken() static, remove misleading Proc* argument 2020-12-21 22:03:46 +01:00
cinap_lenrek 5a059477f8 pc, xen: move fpu setup/fork/save/restore handlers to pc/fpu.c 2020-12-21 15:04:48 +01:00
cinap_lenrek 932995bb27 kernel: update procsave() comment, we'r not holding up->rlock anymore 2020-12-21 14:41:10 +01:00
cinap_lenrek 41c60689b3 ndb/dns: handle dnskey RR's (thanks moody)
On 12/18/20, Jacob Moody wrote:
> Hello,
>
> I recently ran in to some issues with pointing an unbound server towards a
> 9front dns server as its upstream.
> The parsing seemed to fail when ndb/dns received a DNSKEY RR from it's own
> upstream source on behalf of unbound.
> This patch catches and stores the DNSKEY from the upstream server to prevent
> this.
2020-12-20 23:08:11 +01:00
cinap_lenrek e4ce6aadac kernel: handle tos and per process pcycle counters in port/
we might as well handle the per process cycle
counter in the portable part instead of duplicating the code
in every arch and have inconsistent implementations.

we now have a portable kenter() and kexit() function,
that is ment to be used in trap/syscall from user,
which updates the counters.

some kernels missed initializing Mach.cyclefreq.
2020-12-20 22:34:41 +01:00
cinap_lenrek 08c1622b0d [12kq]l: remove unix compat code for cputime() 2020-12-19 19:15:02 +01:00
cinap_lenrek 0527345e0a libthread: remove unused _times() function 2020-12-19 18:47:17 +01:00
cinap_lenrek 58e6750401 kernel: remove Proc* argument from procsetuser() function 2020-12-19 18:07:12 +01:00
cinap_lenrek eb1dfed9ab libauth: change programs to use the new procsetuser() function 2020-12-19 18:02:37 +01:00
cinap_lenrek fc5070c600 libauth: add procsetuser() function to change user id of the calling process
Provide a central function to change the user id
of the calling process.

This is mostly used by programs to become the none
user, followed by a call to newns().
2020-12-19 17:46:55 +01:00
cinap_lenrek daccd2b226 aux/kbdfs: use getuser() from libc 2020-12-19 15:52:41 +01:00
cinap_lenrek ba20914d01 acme: use global user string variable instead of getuser() 2020-12-19 15:50:30 +01:00
cinap_lenrek c7fc69bd6a acme: use getuser() in fsinit() 2020-12-19 15:36:07 +01:00
cinap_lenrek 672cf179a1 libc: implement getppid() reading /proc/$pid/ppid instead of /dev/ppid
The devcons driver is really the wrong place to
serve per process information.
2020-12-19 15:15:38 +01:00
cinap_lenrek d919ad3b5e devsons: remove #c/pgrpid
The process group id is essentially a unique id
of the namespace but it was never well documented
nor is it used by any program.
2020-12-19 14:59:19 +01:00
Ori Bernstein 4dc437c076 vt: rfork environment varibles (thanks fshahriar)
vt sets several environment variables ($TERM, $COLS, $LINES)
after exiting. This change rforks the environment so that this
detritus doesn't get left behind.
2020-12-18 19:23:48 -08:00
Ori Bernstein 2db3642b8d strndup: don't assume buffer is terminated
Using strlen in strndup will walk past the first
n bytes up to the terminator, which may not be
present. This is not what we want.

While we're here, do some cleanups.
2020-12-18 07:16:29 -08:00
Ori Bernstein 658c1b9f68 libap: add strndup
strndup is part of POSIX.1, so APE should provide it.
This patch adds it, so need to patch it out of fewer
programs going forward.
2020-12-17 19:20:04 -08:00
cinap_lenrek 646c502b15 ether2114x: make sure pci bar0 is I/O 2020-12-17 21:02:11 +01:00
cinap_lenrek 318fe6a702 ether2114x: vetting the driver for pc64
the tulip driver is used in microsofts hypver-v
as the legacy ethernet adapter for pxe booting.

to make the driver work on pc64, we need to
store the Block* pointers in a separate array
instead of stuffing them into buffer address 2
of the hardware descriptor.

also, enable the driver in the pc64 kernel.
2020-12-17 20:55:59 +01:00
Sigrid 5016ac0c63 pc: set exit status depending on errors 2020-12-15 14:37:36 +01:00
Sigrid d0c6ade53d pc: treat EOF gracefully, allowing easier use within sam command language 2020-12-15 14:25:59 +01:00
Alex Musolino 3749e92cdb merge 2020-12-15 20:55:41 +10:30
Alex Musolino 404c901f29 ico: avoid potential nil pointer dereferences
Bgeticon can fail, leaving the Icon img pointers nil.
2020-12-15 20:45:26 +10:30
Alex Musolino 81647c2025 ico: fix interpretation of 0 widths/heights 2020-12-15 20:44:11 +10:30
cinap_lenrek 32291b52bc iostats: dup 9p pipe to both fd 0 and fd 1 for exportfs 2020-12-13 20:23:03 +01:00
cinap_lenrek 27a83106f4 oexportfs: move legacy code for cpu and import to separate program
The initial protocol handling in exportfs for
cpu and import services is a huge mess.

Saparate the code out into its own program with
its own oexportfs(4) manpage.
2020-12-13 20:09:03 +01:00
cinap_lenrek 0b33b3b8ad kernel: implement per file descriptor OCEXEC flag, reject ORCLOSE when opening /fd, /srv and /shr
The OCEXEC flag used to be maintained per channel,
making it shared between all the file desciptors.

This has a unexpected side effects with regard to
channel passing drivers such as devdup (/fd),
devsrv (/srv) and devshr (/shr).

For example, opening a /srv file with OCEXEC
makes it impossible to be remounted by exportfs
as it internally does a exec() to mount and
re-export it. There is no way to reset the flag.

This change makes the OCEXEC flag per file descriptor,
so a open with the OCEXEC flag only affects the fd
group of the calling process, and not the channel
itself.

On rfork(RFFDG), the per file descriptor flags get
copied.

On dup(), the per file descriptor flags are reset.

The second modification is that /fd, /srv and /shr
should reject the ORCLOSE flag, as the files that
are returned have already been opend.
2020-12-13 16:04:09 +01:00
cinap_lenrek b2b2d2cb4c sdiahci: assume 64-bit PCIWADDR() 2020-12-12 18:16:06 +01:00
cinap_lenrek 5ea540e75d sdiahci: enable pci busmaster before ahciconfigdrive() (fix qemu crash)
enable pci busmaster before set the fis-receive-enable
bit in the port command register.

not doing so triggers a crash in qemu like:

address_space_unmap: Assertion `mr != NULL' failed.

as qemu tries to process the dma command list as soon
as we set that flag and busmaster dma needs to be enabled
at this point.
2020-12-12 18:00:41 +01:00
cinap_lenrek fc0f08c651 pc, pc64: make sure write combining is supported in MTRR's before setting it 2020-12-11 15:23:03 +01:00
cinap_lenrek 658c994cff pc, pc64: ignore MTRR's when MTRRCap.vcnt and MTRRCap.fix are zero
Bhyve returns 0 in MTRRCap register, so we
can use that instead on relying on cpuid only
to see if MTRR's are supported.

That way we can get rid of the sanity check
in memory.c.
2020-12-11 15:21:44 +01:00
Sigrid f5d1fce9b5 vmx: clean up mksegment, memset only if segment existed (devsegment clears new ones) 2020-12-10 12:19:45 +01:00
cinap_lenrek cef91f23e7 pc, pc64: work around bhyve all uncached MTRR's 2020-12-10 01:47:19 +01:00
cinap_lenrek eb3d055eb3 backout OCEXEC changes when potentially opening /srv files
Opening a /srv file sets the close-on-exec flag on the
shared channel breaking the exportfs openmount() hack.

The devsrv tries to prevent posting a channel with the
close-on-exec or remove-on-close flags. but nothing
currently prevents this poisoning on open.

Until this gets fixed in eigther exportfs or devsrv,
i'll back out the changes that could have potential side
effects like this.
2020-12-09 01:04:03 +01:00
cinap_lenrek 8efbd243e1 pc, pc64: cleanup cpuidentify() and some comments 2020-12-08 16:58:41 +01:00
cinap_lenrek b2ffb6ccc5 pc, pc64: add *nomtrr= kernel parameter 2020-12-08 16:34:36 +01:00
cinap_lenrek 263dc8093d pc64: preserve reserved bits in CR0/CR4 for amd64 in mtrr setstate()
On AMD64, CR0/CR4 are 64-bit registers, with
the upper half reserved. So use uintptr type
to store the register values to get 32 bit on 386
and 64 bit on AMD64.
2020-12-08 16:00:57 +01:00
cinap_lenrek 4db8a82f5a vncv: backing out previous change, this needs another revision 2020-12-08 15:15:13 +01:00
Sigrid b1da2bb10b vncv: do NOT map Kaltgr to meta, introduce Mod4 (Super) as an extra key to use instead 2020-12-08 14:32:28 +01:00
Sigrid 93c6f8cb0d vmx(1): build vmxgdb by default, clean it up as well 2020-12-08 13:18:10 +01:00
cinap_lenrek 4ba5cb6c6a vmx: nanosec(): fix non-interruptable temporary, assign fasthz only once after xstart 2020-12-08 13:04:52 +01:00
cinap_lenrek 01eb04060b pc: move ldmxcsr() prototype to fpu.c 2020-12-08 12:42:36 +01:00
cinap_lenrek de5770c352 vmx: add fmt checking, fix fmt errors, remove duplication for vmdebug 2020-12-08 12:40:28 +01:00
Sigrid 07805ac892 nusb/kb: update button state if event was actually received, fix typos (thanks umbraticus) 2020-12-08 11:47:15 +01:00
Sigrid 3d9abd96ae devmouse: remove redundant check 2020-12-08 11:21:18 +01:00
Sigrid 8f9d4d7c27 vesa: make unsupported function not an error, set return status 2020-12-08 10:08:49 +01:00
Sigrid 96850d8bb4 vmx: add -D option to enable debug messages, use vmdebug for non-fatal "errors" 2020-12-08 10:01:44 +01:00
cinap_lenrek c74458c98b vmx: add -v|-w flag to control window creation behaviour
The -v flag now does not create a new rio window,
while -w flag does (restores the old behaviour).

This allows vmx to run under vncs and is in general
mode aligned to other emulators and programs.
2020-12-07 18:59:54 +01:00
cinap_lenrek 1bb96d542c libcomplete: open internal file-descriptor with OCEXEC flag 2020-12-07 17:18:33 +01:00
cinap_lenrek 383a2ca79b libsec: open internal file-descriptors with OCEXEC flag 2020-12-07 17:14:34 +01:00
cinap_lenrek d5928fb515 merge 2020-12-07 16:48:19 +01:00
cinap_lenrek f7e21d7692 libauthsrv: open internal file-descriptors with OCEXEC flag 2020-12-07 16:47:06 +01:00
cinap_lenrek f433f1426b libauth: open internal file-descriptors with OCEXEC flag 2020-12-07 16:46:34 +01:00
Sigrid 6c29cf79f0 aux/kbdfs, kbmaps: enable Kmod4 for other layouts, not just neo2 2020-12-07 16:42:56 +01:00
cinap_lenrek f341ae8c77 libdraw: open file-descriptor with OCEXEC flag in readcolmap() 2020-12-07 16:30:27 +01:00
cinap_lenrek 1a900513fb libndb: open internal file-descriptors with OCEXEC flag 2020-12-07 15:15:02 +01:00
cinap_lenrek 5e59c57bb1 lib9p: open internal file-descriptor with OCEXEC flag in getremotesys() 2020-12-07 14:54:27 +01:00
cinap_lenrek 4d4b6a19de lib9p: open /mnt/factotum/rpc with OCEXEC flag in auth9p() 2020-12-07 14:51:53 +01:00
cinap_lenrek d570229e82 lib9p: improve reqqueuecreate()
- open /proc/n/ctl with OCEXEC flag
- format pid as ulong
- don't leak the fd
2020-12-07 14:49:12 +01:00
cinap_lenrek b3c9249500 merge 2020-12-07 14:33:51 +01:00
cinap_lenrek 4d22dbb0f5 libdraw: open internal file-descriptors with OCEXEC flag 2020-12-07 14:32:34 +01:00
cinap_lenrek e8b871ef5a libdraw: remove unused Error label in freescreen() 2020-12-07 14:32:12 +01:00
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