Commit Graph

6606 Commits (master)

Author SHA1 Message Date
cinap_lenrek 3841a46421 kernel: remove ucalloc.c duplicates 2021-03-13 14:57:53 +01:00
cinap_lenrek 7c62c12701 kernel: use 64-bit mask to avoid compiler warning in port/pci.c 2021-03-13 14:20:00 +01:00
cinap_lenrek 9de5aac7a2 5c, 6c, 7c, 8c, kc, qc, vc: use explicit gmove(... , nn) in cgen() for result of OAS*, OPREINC, OPOSTINC
The expression value of the assignment operation was
returned implicitely by relying on regalloc() on the
right hand side "nod" borrowing the register from nn.

But this only works if nn is a register.

In case of 6c, it can also be a ONAME from a .safe
rathole returned by regsalloc().

This change adds explicit gmove() calls to assign the
expression value. Note that gmove() checks if source
and destination are the same register so it wont emit
redundant move operations in the common case.

The same is applied also to OPREINC and OPOSTINC operations.
2021-03-13 13:56:40 +01:00
rgl 2fc22d067d correct off-by-one nul termination. 2021-03-11 19:37:44 +01:00
Ori Bernstein 9162533526 Mail: separate deletion from relinking messages
Mutating lists that are being iterated is needlessly error
prone, and we were removing the wrong message in some cases
if it the dummy got inserted in the right place.

Separating deletion into a redraw/relink and zap phase
simplifies the problem.
2021-03-10 16:49:17 -08:00
cinap_lenrek b5783b1e39 rio: make window focus changes deterministic, cleanup wind.c
Switching window focus used to be non deterministic
as the current window in focus (Window *input) was set
concurrently while processing window messages such as
Resized and Topped.

This implements a new approach where wcurrent() and
wuncurrent() are responsible for the synchronization
and switch of the input.

It is implemented by sending a Repaint message to the
old input window first, neccesarily waiting until that
window releases the focus and then input is updated
and then a Topped or Reshaped message is send to the
new input window.

Note, that when the whole screen is resized that no
input changes need to happening anymore.
2021-03-07 20:26:30 +01:00
Sigrid 5ac3fa0257 mothra: "d": use lite version, disable redirect 2021-03-02 08:41:02 +01:00
Sigrid 2aba7615af mothra: add "d" command to search for a text on the internet (using duckduckgo) 2021-03-02 08:21:56 +01:00
Ori Bernstein f234b29c7f Mail: revert 096538d64724 2021-03-01 19:23:13 -08:00
cinap_lenrek a0404ff582 devpccard, pci: fix pccard support and handle pci expansion roms
let pci.c deal with the special cardbus controller bar0 and
expansion roms.

handle apic interrupt routing for devices behind a cardbus slot.

do not free the pcidev on card removal, as the drivers
most certanly are not prepared to handle this yet.
instead, we provide a pcidevfree() function that just unlinks
the device from pcilist and the parent bridge.
2021-03-01 17:24:54 +01:00
Ori Bernstein 3555843110 Mail: fix infinite deletion loop
When deleting messages that came in just
the right order, we would end up stuck in
a loop deleting and reinserting a dummy
parent, rather than the messages we wanted
to remove.
2021-02-28 16:36:42 -08:00
cinap_lenrek be782ef435 bcm: change color chan to RGB24 (thanks p.kosyh)
p.kosyh writes:

Hello!  I finally bought rpi4 4Gb specially for 9front. It seems,
that default bpp of framebuffer is 16.  I changed it to 24 (via
cmdline.txt and config.txt) and found, that rendering is much faster!
(May be due removing overheads in 16->24 conversions?)

But on rpi4 r and b channels are swapped.  So, i changed BGR24 to
RGB24 in bcm/screen.c and now it works fine!
2021-02-28 13:31:49 +01:00
cinap_lenrek 51f4f46ae0 ramfs: fix truncfile() for non multiple of extend size (64k)
The calculation of the last block size is wrong and we can
only shrink the size of the last data block, not extend it.
2021-02-27 15:08:34 +01:00
Sigrid 692919521c vmx: reduce cpu load by eliminating nop-loop
Sacrifice some of the sub-millisecond timer precision in favor of less
cpu load when the timer is about to be kicked a bit early.  Result is
visible *especially* when the guest idling.

Timer proc *still* has to send to the channel (in order to kick PIT
and RTC logic), which takes time, and compensates a bit for possibly
early runs.
2021-02-23 15:54:09 +01:00
Sigrid 007d42e741 html2ms: 0xFFFD → Runeerror 2021-02-23 08:52:59 +01:00
cinap_lenrek 27ad886c95 ip/tftpd: add -n namespace-file flag (thanks sam-d)
tftpd currently unconditionally sets its namespace via /lib/namespace
(newns("none", nil)), which stymied my attempts to pxe boot the
openbsd installer without creating a real /etc dir on 9front, which
would've been gross.

I tried working around this with -h (and -r for good measure), but
again hit issues because the namespace is rebuilt from scratch -- any
binds of /386, /amd64, /cfg/pxe, etc. into the tftp-specific directory
disappeared from tftpd's namespace and rendered my *9front* boxes
unable to boot. I could maintain copies of the needed files in the
tftp-specific directory, but that'd be kind of a drag.

The following patch adds a -n flag to allow the specification of a
namespace file in place of /lib/namespace; similar to ip/ftpd.

I thought about setting up a /lib/namespace.tftp to act as a default
rather than continuing to use /lib/namespace by default (which
security-wise is about the same as allowing 9p mounts by user none,
which I also have disabled), but I had trouble coming up with a sane
default. Maybe someone more experienced would like to try that out.

- sam-d
2021-02-23 01:47:33 +01:00
cinap_lenrek a96cf495fa ip/tftpd: use procsetuser() instead of writing #c/user 2021-02-23 01:41:09 +01:00
cinap_lenrek 5347bb9c96 boot/bcm: download dtb files for rpi-400 and rpi-cm4 2021-02-22 23:44:28 +01:00
cinap_lenrek e77fa31516 libaml: fix IndexField and BankField implementations (thanks Michael Forney)
IndexField is supposed to increment the index value when an
access is done with a bigger size than the data field.
The index value is always a byte offset.

Now that we always calculate the offset for each field unit
access for IndexField, rename the indexv to bank (the bank
value), as it is only used for that. Also, do not compare
it with nil, as it is a integer constant which can be
encoded as nil to mean zero.

For BankField, the banking field was written using store(),
which does nothing when the destination is a Field*.
Use rwfield() to fix it in the new rwfieldunit().

Resolve all the Name*'s when IndexField, BankField and
Field are created. Now, Field.reg points to eigther
Buffer object, Region or Field (data Field of an IndexField).

PS: initial bug report by Michael Forney follows below:

In /dev/kmesg on my T14, I saw a message

	amlmapio: [0xffffff18-0x100000018] overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

Here is the relevant snippet from my DSDT:

    Scope (_SB)
    {
        ...

        OperationRegion (ECMC, SystemIO, 0x72, 0x02)
        Field (ECMC, AnyAcc, NoLock, Preserve)
        {
            ECMI,   8,
            ECMD,   8
        }

        IndexField (ECMI, ECMD, ByteAcc, NoLock, Preserve)
        {
            Offset (0x08),
            FRTB,   32
        }

        OperationRegion (FRTP, SystemMemory, FRTB, 0x0100)
        Field (FRTP, AnyAcc, NoLock, Preserve)
        {
		...
        }
    }

With some debugging output:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	amlmapio(\_SB.FRTP): Mem      ffffff18 - 100000018
	amlmapio: [0xffffff18-0x100000018) overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

It seems that libaml does not handle IndexField correctly and just did
a single read from ECMD after setting ECMI to 8, causing the FRTP
region to be evaluated as 0xffffff18-0x100000018. Instead, it should
be reading 4 bytes [18 c0 22 cc], evaluating it as
0xcc22c018-0xcc22118:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 9
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> c0
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- a
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 22
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- b
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> cc
	amlmapio(\_SB.FRTP): Mem      cc22c018 - cc22c118

I wrote a patch (attached) to fix this, and it seems to work. Though,
it's not clear to me when things should be dereferenced. Previously,
the data field was dereferenced at evalfield, but the region and index
field were not until rwfield. After the patch, the index field is
also dereferenced in evalfield.

For BankField, the index *is* dereferenced in evalfield. I'm pretty
sure that this means that BankField does not work currently, since
store() just returns nil for 'f' objects. The bank selector will
never get set.

Anyway, I don't know if this solves any real problems; it's just
something I noticed and thought I'd try to fix.
2021-02-22 19:27:49 +01:00
Michael Forney 472958e3e7 games/snes: use 4-point hermite interpolation to resample
This is noticeably better than nearest-neighbor.
2021-02-22 16:12:24 +01:00
Ori Bernstein 6445a14f63 ape/lib9: expose fd2path (thanks phil9)
Fd2path is a useful call for the netsurf plan9 frontend,
so we should expose it.
2021-02-20 21:02:07 -08:00
Ori Bernstein f3a05b16ad upas/send: add \n to error in refuse() (thanks josuah) 2021-02-20 15:25:25 -08:00
Ori Bernstein 2d13ac5d39 marshal: remove debug junk.
Oops.
2021-02-20 13:03:35 -08:00
Ori Bernstein fb88cab9ff upas/marshal: use login instead of user (thanks sirjofri)
User is the upasname, and is unlikely to exist when we save
the message to the outbox. We should use the login name instead.
2021-02-20 13:01:48 -08:00
Ori Bernstein 245264e371 upas/marshal: handle nonexistent save folder correctly (thanks sirjofri)
When the save folder did not exist, and we could not create
it, we would handle up to one Biobuf worth of message, and
then fail, due to a failed tee. The sequence of events leading
up to this was:

	openfolder() -> error
	tee(0, fd, -1) -> wait for read
	write(0, data) ->
		write(fd, data) -> ok
		write(-1, data) -> error, tee terminates
	write(0, attachment) -> error

This change prevents us from writing to a closed fd, and
therefore from erroring out when sending.

We also warn the user.
2021-02-20 12:49:03 -08:00
cinap_lenrek dab168e6bd ether82563: add pci id for i219-LM on thinkcenter (easypeasy, thanks hiro) 2021-02-20 19:06:59 +01:00
cinap_lenrek 8b817fd6c0 pc/devarch: use m->cpumhz instead of recalculatin it 2021-02-20 13:08:59 +01:00
cinap_lenrek 48e795005d 9boot: handle automatic length for 64-bit values in hexfmt() for framebuffer address (thanks Michael Forney) 2021-02-20 12:55:42 +01:00
sl 4bbb3b0b21 /sys/src/cmd/ndb/dns.h:
---

To: 9front@9front.org
Date: Sun, 07 Feb 2021 14:56:39 +0100
From: kvik@a-b.xyz
Subject: Re: [9front] transient dns errors cause smtp failure
Reply-To: 9front@9front.org

I think I found a reason for DNS failing on known good domains.

/sys/src/cmd/ndb/dns.h:156,157
	/* tune; was 60*1000; keep it short */
	Maxreqtm=	8*1000,	/* max. ms to process a request */

So, 8 seconds is how much the resolver will bother with a request it
has been handed, before dropping it on the floor with little
explanation.

It seems quite possible that this is too short a timeout on a machine
during a spam queue run, which predictably stresses the compute and
network resources.

In turn, negative response caching might explain why a particular
unlucky domain would basically stop receiveing any mail for a while.

I'm dying to know if bumping this limit would clear up the queue of
such DNS errors.

---

[narrator: it did.]
2021-02-19 21:29:55 -05:00
sl 29e8ea26f2 sam/{address.c, sam.h}: bump STRSIZE to 512MB (thanks, Ori_B) 2021-02-19 21:15:15 -05:00
kvik bc1cc79225 libstdio: sync bits of vfprintf from APE
* Add the %ll length modifier,
* Convert nil to "<nil>" under %s (not in APE),
* Cast void* to uintptr under %p,
* Use "0x" hex prefix under %p,
* Fix manual page mentions of %P to %p,
* Fix empty result for fp conversions,
* Fix zero padding of left-aligned fp conversions,
* Remove deprecated #pragma ref uses.

Most of these were introduced in APE prior to 9front.

I've omitted the %z conversion specifier since Plan 9 code
rarely uses the usize type. This may need to be added later
for the benefit of native ports of alien code.
2021-02-19 23:04:09 +01:00
Sigrid ca1542a199 audio/flacenc: fix usage 2021-02-18 15:13:25 +01:00
Michael Forney 8aff377698 games/snes: use enum constants KON and ENDX instead of their values 2021-02-17 11:20:13 +01:00
Michael Forney 03eeebb97f games/snes: implement DSP echo 2021-02-17 11:20:05 +01:00
Michael Forney f1d29a9d12 games/snes: implement DSP noise
I'm not sure if this LFSR is the same one used by the hardware or is
arbitrary, but it matches the noise sequence used by all other snes
emulators I looked at.
2021-02-17 11:19:50 +01:00
Michael Forney 52b54097bf games/snes: fix BRR decoding with filters 2 and 3
s1 and s2 should store the last and next to last output, but were set
in the wrong order, causing them both to be the last output. This
breaks filters 2 and 3, which both utilize s2.
2021-02-17 11:19:39 +01:00
Sigrid 79cf39c53a mothra: tune up entry control logic for easier text editing 2021-02-16 22:04:50 +01:00
cinap_lenrek 04bf70d344 9boot: mark efi boot and runtime service regions as reserved
despite the kernel never doing any efi runtime service calls,
overriding the runtime service regions makes some machines
lock up. so consider them reserved.

the boot service regions should also, in theory, be usable
by the os, but linux says otherwise...
2021-02-15 01:49:30 +01:00
cinap_lenrek b5690a5ae7 ndb/dns: implement RFC6844 certificate authority authorization record type 2021-02-14 14:25:41 +01:00
Michael Forney 5fd4fa912e [9front] audio/flacenc: fix error check for fseeko
fseeko returns 0 on success, not the new stream position.

This allows flacenc to update the streaminfo block when it is finished
(for example to set the number of samples and checksum).
2021-02-11 09:37:36 +01:00
cinap_lenrek 2f28aaac65 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 20:08:13 +01:00
cinap_lenrek d7ade692c8 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 19:52:00 +01:00
Ori Bernstein 8606fc8f29 merge 2021-02-10 10:21:06 -08:00
Ori Bernstein 0719ce2aa7 stdio: remove erronous assert in dtoa
The value of `k` in dtoa() is an estimate of
floor(log10(d)), where `d` is the number being
converted. The code was asserting that 'k' was
less than 100, but the full range of a double
goes to 10^308 or so.

This means that the majority of the range of
a double would trigger that assert.
2021-02-09 13:57:38 -08:00
Michael Forney 29fbba7b6d [9front] upas/vf: exclude mime boundary from temporary attachment files
validateattachment has no business with the mime boundary; it is not
part of the attachment itself.

Also, it causes the boundary to be dropped in the message output from
upas/vf, effectively dropping the following attachment (though the
content is still present after the last boundary of the wrapped first
attachment part).

Consider the following sequence of events:
1. upas/vf is run on a message containing two attachments.
2. The first attachment does not have a known extension, so is saved
   to a temporary file *including* the following mime boundary.
3. This file is opened as p->tmpbuf, which is used for subsequent
   reads until switching back to stdin.
4. The attachment fails validateattachment, so upas/vf wraps it in a
   multipart with a warning message.
5. problemchild() calls passbody(p, 0), which copies from p->tmpbuf
   until it hits the outer boundary line, which it excludes, seeks
   back one line, then returns the outer multipart.
6. problemchild() then writes its own boundary, and then copies one
   line from *stdin* to stdout, expecting the outer boundary.
   However, this boundary was already read from stdin in 2, so it ends
   up reading the first line of the subsequent part instead.

To fix this, pass 0 to passbody() in save() to exclude it from the
attachment file and make it available in stdin when expected.
2021-02-08 20:59:01 -08:00
Ori Bernstein 2d8adc7b88 ape/lib9: sync arm getfcr.s implementation
The arm assembler supports movw to handle
getfcr and setfcr now, no need to hack it
with macros; sync from plan9 libc.
2021-02-08 16:07:09 -08:00
Ori Bernstein 491fe25158 Mail: correct rendering of nested multipart messages
Reading nested subparts of messages into the root
message array allows deeply nested multipart trees
of messages to show correctly in the message view.
2021-02-07 20:30:04 -08:00
Michael Forney e20dcb151a [9front] upas/vf: remove debugging print statements
These messages aren't useful and were presumably left over from
someone debugging this code.
2021-02-07 20:17:06 -08:00
Michael Forney 415c110b28 games/gb: fix reversed audio channels
The high bits correspond to the left channel, and the low bits to the
right channel.

Reference: https://gbdev.io/pandocs/#sound-control-registers

Tested with pokemon crystal.
2021-02-08 04:58:49 +01:00
Michael Forney e502abe001 games/gb: various HDMA fixes
H-blank DMA should only transfer 16 bytes per h-blank, rather than
waiting for the first h-blank and then transferring the whole size.

HDMAC should read 0xff when the transfer is finished, and 0 in the
high bit when the transfer is ongoing. Also, if 0 is written in the
high bit, the current transfer should be aborted.

Introduce two flags, DMAREADY and DMAHBLANK rather than special
constants 1 and -1. If dma is non-zero, there is an ongoing DMA. If
DMAREADY is set, the next chunk is ready to transfer.

Reference: https://gbdev.io/pandocs/#ff55-hdma5-cgb-mode-only-new-dma-length-mode-start

Tested with pokemon crystal.

What was happening is that when the game was loading N background tiles
into vram (each 16 bytes, so one per h-blank), it did something like
this:
- start an hdma transfer for N+1 tiles
- after the Nth tile is transferred, it would read HDMA5, clear the
high bit, then write it back to abort the transfer.

games/gb would instead transfer all N+1 tiles at once, overwriting one
extra tile with whatever was 1 past the end of the source array, and
then would interpret the cancel request as the start of a new transfer
of 16 bytes, which would copy an additional tile past the end. The end
result is that every transfer would end up copying N+2 tiles instead
of just N, overwriting certain tiles with whatever was after the end
of the source data.
2021-02-08 04:58:41 +01:00
Michael Forney 655170c873 games/gb: fix timer divider for input clock 0
According to [0], input clock 0 should divide by 1024=2¹⁰, not 2¹².
This caused audio to run at quarter-speed in one game I tried.

[0] https://gbdev.io/pandocs/#ff07-tac-timer-control-r-w

Tested with zelda: oracle of seasons, and dr. mario
---
2021-02-08 04:58:02 +01:00
Michael Forney 827bf1b7da [9front] upas/vf: install %τ format specifier
upas/vf was converted to use tmdate, but the formatter was never
installed.  This caused it to send attachments to validateattachment
with header `From virusfilter %τ%`, which always failed since upas/fs
would just skip over the message.
2021-02-07 08:02:36 -08:00
cinap_lenrek d5f9514304 merge 2021-02-06 13:50:06 +01:00
cinap_lenrek efcfdd23d7 bcm64: get inbound and outbound pci window base address from device tree
On the pi400, the xhci reset firmware mailbox request
assumes that the pci windows match the ones specified
in the device tree. The inbound window (pcidmawin)
also varies now depending on the amount of memory
installed.

It is all pretty ridiculous, as the firmware could as
well just read the pci controllers hardware register
to determine the window configuration and the os could
keep a nice simple 1:1 mapping (with pci dma addresses
== physical addresses).
2021-02-06 13:47:45 +01:00
cinap_lenrek 0e381493bf pc: increase number of Conf.mem[] entries from 4 to 16 2021-02-06 13:33:58 +01:00
cinap_lenrek e9af397dc7 pc, pc64: warn when running out of conf.mem[] entries in meminit() 2021-02-06 13:33:27 +01:00
Alex Musolino b562b269ce test: fix expression parser
The old parser code was rubbish and only worked for trivial
expressions.  The new code properly handles complex expressions,
including short circuit evaluation.

As such, the BUGS section has been removed from the test(1) man page.
The description of an unimplemented feature has also been removed.
2021-02-06 15:51:09 +10:30
Sigrid 4ec97f73ee libdraw: enter/eenter: fix ^W removing the text on the right side of the tick 2021-02-04 10:57:37 +01:00
Sigrid e0bfd148e2 libdraw: enter/eenter: fix Kleft for non-ascii text 2021-02-04 10:45:52 +01:00
Michael Forney 49220af76e [9front] [PATCH] audiohda: add PCI ID for Intel C610/X99
---
Tested and seems to work fine.
2021-02-03 16:19:57 -08:00
Ori Bernstein 101312c1d7 mklib, upas/common: clean up libcommon properly (thanks mikan)
Despite pervious efforts, mk clean still doesn't remove libcommon.a*
files from cmd/upas/common/. To fix this, let's tell cmd/mklib to do
the job instead.
2021-02-03 08:10:11 -08:00
cinap_lenrek 01ab07ef72 acme: fix use after free in warning() call (thanks igor) 2021-02-03 01:19:19 +01:00
Ori Bernstein 3c1022a3de merge 2021-02-02 07:21:47 -08:00
Ori Bernstein 49d7ca8d92 runq: clean up code, fix error handling.
Runq spawns a number of processes, and wait()s for them
in 2 different places. Because of the way that the exit
handling is done, the wait can get the wrong message.

It turns out that only one place in the code needs to
wait for the child, and in all other cases, it's just
muddling the problem.

This change adds the RFNOWAIT call to all the processes
we don't need to wait for, so that the places that do
need wait will always get the correct child.
2021-02-02 06:52:00 -08:00
Sigrid bd78bad3c7 winwatch: always reflow when possible (thanks telephil9) 2021-02-02 11:56:45 +01:00
Ori Bernstein 34ed7f7aa2 Mail: only clear upas-maintained flags on change (thanks deuteron)
When message flags change, Mail would clear all the flags and
recompute them. This would clobber internal flags like Ftodel.
So, don't do that.
2021-02-01 20:38:40 -08:00
Ori Bernstein c20f68f801 mothra: don't insert newline after div (thanks phil9) 2021-01-31 12:25:03 -08:00
Ori Bernstein bb250c4c3b ape/libm: implement log2 in libc 2021-01-30 09:19:57 -08:00
Ori Bernstein 273c4bff7a Mail: fix inverted reply-all condition 2021-01-29 18:29:01 -08:00
Ori Bernstein bee6271ae1 Mail: rewrite.
Acme mail made it hard to do threading, so I wrote a new one.
2021-01-29 17:34:47 -08:00
Ori Bernstein 319e625be0 screenlock: use initdisplay(2), top the window (thanks stuart morrow)
Screenlock should use libdraw(2) to init the display
and create the window, instead of looking at the screen
file directly. Also, to prevent new windows from popping
up over screenlock, bring it to the top periodically.
2021-01-28 18:07:48 -08:00
Ori Bernstein a5517fca5f news: make -a and -n get along (thanks lyndon)
currently, -a and -n are mutually exclusive.
this change allows them to be used together.
2021-01-26 18:07:04 -08:00
Ori Bernstein 21e5726f43 cc: mk clean should delete cc.a$O
It's surprising when 'mk clean' doesn't actually
do a clean build in cc -- fix this.
2021-01-24 09:58:39 -08:00
Ori Bernstein 5b8b5884f4 5l: fix shifts by zero
on arm32, we can do one of 4 shifts
by a constant:

	reg<<(0..31)
	reg>>(1..32)
	((u32int)reg)>>(1..32)
	reg ROT (0..31)

There's no way to encode a 0 bit right
shift,  so when encoding reg>>0, flip
it to the equivalent nop reg<<0, which
can be encoded.
2021-01-23 20:36:09 -08:00
Ori Bernstein f76e28cb71 ape/libm: add back fmod, remove modf
We removed the wrong file. Put it back.
2021-01-23 20:03:07 -08:00
Michael Forney 988bdd05a3 [9front] ape: remove _SUSV2_SOURCE guard from inttypes.h
inttypes.h was added to C99, and this is the only header that used
_SUSV2_SOURCE.

Also, remove now unneeded _SUSV2_SOURCE from python mkfile.
2021-01-23 19:47:12 -08:00
Michael Forney e8b8cec9c7 [9front] cc: fix comparison warning with constant LHS
This prevents an incorrect warning for a comparison such as `0 < x`,
where x is an unsigned type.  Previously, this would get normalized as
`x >= 0` rather than `x > 0` when checking the comparison.
2021-01-23 18:28:08 -08:00
Michael Forney a8834acf73 [9front] cc: remove unnecessary 128-bit add function
Instead, just change the comparisons from <=/>= to </>.
2021-01-23 18:26:34 -08:00
Ori Bernstein ed2b1d5c61 upas/fs: fix swapped argument, dead code
With ntlm auth, we were trying to set 0 bytes of
the auth struct to its size. The args were clearly
swapped. Fix it.

While we're here, remove some dead code.
2021-01-23 18:02:46 -08:00
Ori Bernstein f164ee6dd9 upas/runq: fix typo
one slipped in to the last commit.
2021-01-23 16:38:32 -08:00
Ori Bernstein 51319cc5b5 upas/runq: bring back -a
Turns out -a is useful in crontab, so bring
back a simplified version of it. This only
iterates through directories one at a time.
2021-01-23 16:05:21 -08:00
qwx 41f85d46f8 ape: update mkfile for removed fmod.c 2021-01-24 00:58:47 +01:00
Ori Bernstein bd5af0df5d vnc: I don't like your face.
Cosmetic improvements to vnc auth code.
Should not have user-visible changes.
2021-01-23 13:20:09 -08:00
Ori Bernstein f321298c55 upas/runq: support parallel queue processing, drop -a
When running a mail queue, it's useful to run it with limited
parallelism. This helps mailing lists process messages in a
reasonable time.

At the same time, we can remove the load balancing from runq,
since the kinds of systems that this matters on no longer
exist, and running multiple queues at once can be better
done through xargs.
2021-01-23 11:03:05 -08:00
cinap_lenrek 6d012d2df0 ape: apply infinite recursion in fmod() fix (thanks jxy and ality)
Apply changeset 2880:cab2b9d13a73 to ape's fmod() implementation.

Remove the unused math/fmod.c copy.
2021-01-23 15:53:56 +01:00
cinap_lenrek b5c7158f39 syscall: don't rely on . being in $path (thanks Silas) 2021-01-23 15:06:30 +01:00
Sigrid a9e70446a0 nusb/kb: correct Mod4 scancode (125 → 91, to match what kbdfs has) 2021-01-22 17:48:41 +01:00
Sigrid 9025176193 aux/acpi: do not expose empty files 2021-01-22 10:57:43 +01:00
Sigrid 6a78bb2e4f stats: don't query battery and temp as often when using acpi
Querying battery (or temperature) using ACPI takes quite some
resources, which makes the battery discharge faster.  It doesn't make
much sense to have it queried as often either.  So, when using ACPI:

1) set battery query period to 10s minimum
2) set temperature query period to 5s minimum
2021-01-22 10:15:36 +01:00
Ori Bernstein 1047b53efc ape/libap: fix _startbuf, check rfork return (thanks pixelherodev)
When _startbuf is invoked, it would crash on the second invocation
if creating a mux segment failed. This is because the first attempt
would assign the return value -1 to the global mux variable, and
the second attempt would notice that the global mux was not nil,
and would attempt to use it.

This change only assigns to the global variable if the allocation
of the segment was a success.

While we're here, we should also check the return of the rfork call.
2021-01-19 19:56:38 -08:00
Ori Bernstein 50efe18550 webcookies: remove straggling custom date parser
One place missed in the tmdate purge.
2021-01-19 18:14:53 -08:00
Ori Bernstein 417dc79cff upas/ml: touch the artwork
Global variables deserve more greppable names,
since I'm likely to know where they're used.
2021-01-19 18:12:30 -08:00
Ori Bernstein cb7ba0e640 dd: error with invalid size suffixes, add 'm'
When invoking with dd with an invalid size suffix, we
silently accept the suffix. This can lead to confusion,
because lines like:

	dd -bs 1K
	dd -bs 1m

will silently copy in 1-byte increments. This has caught
people by surprise. While we're at it, megabytes are
convenient, so let's have them too.
2021-01-19 15:15:12 -08:00
Sigrid 67c15c1e47 mothra: linkify text starting with gemini:// and ftp:// 2021-01-19 15:04:40 +01:00
Sigrid 8781283fbd mothra: resolve urls on middle click. helps with snarfing of relative urls 2021-01-19 14:14:28 +01:00
Ori Bernstein 8c9cbbb142 passwd: make legacy mode explicit
Passwd used to produce a very confusing error
about DES not being enabled whenever the password
was mistyped. This happened because we attempted
to guess what authentication method to use, and
preseneted the error from the wrong one on failure.

This puts the legacy mode behind a flag, so that
we don't even try the old method unless it's
explicitly requested.
2021-01-17 18:01:53 -08:00
cinap_lenrek 081f98de6c audiohda: Add AMD Starship/Matisse HD Audio Controller (thanks uramekus) 2021-01-18 00:51:20 +01:00
cinap_lenrek f8787d5815 merge 2021-01-17 21:22:23 +01:00
cinap_lenrek a05bab362f pc, pc64: add minimal HPET driver to measure LAPIC and TSC frequencies
This adds the new function pointer PCArch.clockinit(),
which is a timer dependent initialization routine.
It also takes over the job of guesscpuhz(). This way, the
architecture ident code can switch between different
timers (i8253, HPET and XEN timer).
2021-01-17 21:21:12 +01:00
Ori Bernstein bf7e0791e1 seconds: remove junk from usage 2021-01-17 11:12:18 -08:00
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