6 years agoAdds KFS symlinks for bash and sh
Barret Rhoden [Tue, 8 Apr 2014 02:54:28 +0000 (19:54 -0700)]
Adds KFS symlinks for bash and sh

Symlinks to busybox; needed for running scripts as programs from
busybox (./script, ./etc).

If someone wants to put together some busybox patching, configuring,
building, and installing scripts, then go for it.

6 years agoFixes tcpackproc name's memory
Barret Rhoden [Tue, 8 Apr 2014 02:52:29 +0000 (19:52 -0700)]
Fixes tcpackproc name's memory

Our ktasks (possibly foolishly) don't make a copy of the name for the
caller.  So the caller (or rather the ktask itself) needs to free the
memory for the kname when it is done.

Probably should change this.

6 years agoAdd check for is_valid_elf() before loading in exec
Kevin Klues [Mon, 7 Apr 2014 19:22:46 +0000 (12:22 -0700)]
Add check for is_valid_elf() before loading in exec

If the program is not a valid elf file, then set errno to ENOEXEC.
Busybox and other shells recognize this and try to re-exec the program
through the shell itself (i.e. bash ifconfig instead of just

To support this, sh and bash symlinks have been set up to point to ash
in busybox

6 years agoMSI-X fixes
Barret Rhoden [Mon, 7 Apr 2014 20:22:36 +0000 (13:22 -0700)]
MSI-X fixes

Allows unaligned table/pba addresses and zeros out the data entries in
the table.  Some hardware (i350 on c89) already has them zeroed, while
other (rtl8169) doesn't.

6 years agoCan vmap unaligned paddrs
Barret Rhoden [Mon, 7 Apr 2014 20:18:29 +0000 (13:18 -0700)]
Can vmap unaligned paddrs

The main idea is to implicitly map the phys memory below paddr, down to
its nearest page boundary.

6 years agoMSI: Fix for MSI to work when MSI-X fails
Barret Rhoden [Mon, 7 Apr 2014 19:24:59 +0000 (12:24 -0700)]
MSI: Fix for MSI to work when MSI-X fails

Need to turn off the MSI-X enable bit.  You can only have either MSI or
MSI-X turned on at a time.

6 years agoAdd ability to set alarms at an absolute unix time
Kevin Klues [Sat, 5 Apr 2014 04:12:51 +0000 (21:12 -0700)]
Add ability to set alarms at an absolute unix time

6 years agoPCI device locking and synchronization
Barret Rhoden [Fri, 4 Apr 2014 23:14:24 +0000 (16:14 -0700)]
PCI device locking and synchronization

Adds some limited concurrency support to PCI operations.  The main list
of PCI devices is built at boot and is read-only, so we don't
(currently) need to worry much.

6 years agoPCI: handles BARs for PCI2PCI devices
Barret Rhoden [Fri, 4 Apr 2014 20:32:04 +0000 (13:32 -0700)]
PCI: handles BARs for PCI2PCI devices

Though it turns out my hardware doesn't have any of these, so it hasn't
turned up as an issue.

6 years agoIRQ routing
Barret Rhoden [Fri, 4 Apr 2014 20:20:39 +0000 (13:20 -0700)]
IRQ routing

Call route_irqs() to reroute a all IRQs for a particular vector to an os
coreid.  We don't support routing to multiple cores yet.

6 years agoRefactors MSI code slightly
Barret Rhoden [Fri, 4 Apr 2014 19:40:41 +0000 (12:40 -0700)]
Refactors MSI code slightly

PCI/MSI code doesn't need to know about irq_h, which makes all of the
interfaces a little cleaner.

Also puts in some checks to prevent us from trying to turn on MSI and
MSI-X at the same time.

6 years agoUses channame() in sys_fd2path()
Barret Rhoden [Thu, 3 Apr 2014 23:11:30 +0000 (16:11 -0700)]
Uses channame() in sys_fd2path()

channame() should do the trick, instead of the old chanpath() which was
removed in commit 011ab2.  If not, we should fix channame().  chanpath()
was a nxm thing; Inferno has different structs to track the name.
"chanpath(ch)" might have been put in quotes during the 9ns->inferno

Using snprintf() and channame() helps with a couple things.  Previously,
fd2path() didn't check ch != 0 and could copy more than the user requested
(i.e. the full channame len instead of MIN(len, ch->name->len)).

6 years agoMSI-X support
Barret Rhoden [Thu, 3 Apr 2014 22:53:13 +0000 (15:53 -0700)]
MSI-X support

Adds support for MSI-X interrupts, including routing of individual
vectors to cores, via the irq_handler.

Cleaned up MSI a bit too, extracting common code (they use the same
MSI addr and data format).

Still needs a little cleanup and synchronization support.

6 years agovmap_pmem_nocache()
Barret Rhoden [Thu, 3 Apr 2014 21:37:04 +0000 (14:37 -0700)]

Maps in physical memory to the kernel's VA space, but with caching
disabled (if available).  We'll need to use this for device MMIO.

6 years agoActually do an fd2path instead of hardcoded path
Kevin Klues [Thu, 3 Apr 2014 01:01:10 +0000 (18:01 -0700)]
Actually do an fd2path instead of hardcoded path

6 years agoMSI cleanup and IRQ routing
Barret Rhoden [Wed, 2 Apr 2014 23:50:02 +0000 (16:50 -0700)]
MSI cleanup and IRQ routing

Not sure what the deal is with the Msiaedest.  Perhaps those bits are
used for extended APIC id bits (like with an x2APIC?).  Though I heard
the x2APICs use IO redirection/virtualization hardware, or something
similarly ridiculous/painful.

6 years agosys_fd2path needs to return an intreg_t
Kevin Klues [Wed, 2 Apr 2014 21:56:51 +0000 (14:56 -0700)]
sys_fd2path needs to return an intreg_t

Otherwise a comparison with -1 on the user side will not be valid if it
treats the return value as a 64 bit integer.

6 years agoPCI: Fixes capability detection
Barret Rhoden [Wed, 2 Apr 2014 19:42:33 +0000 (12:42 -0700)]
PCI: Fixes capability detection

Caps are a linked list; the old code seemed to just incrementally scan,
which was checking arbitrary spots in the PCI/cap space.

If someone wants to make fancy cap_id-to-strings for the output, be my

6 years agoPull all ndb files from the plan9 source tree
Kevin Klues [Wed, 2 Apr 2014 19:38:41 +0000 (12:38 -0700)]
Pull all ndb files from the plan9 source tree

6 years agoFix offset bug in qreply in cs
Kevin Klues [Wed, 2 Apr 2014 19:37:29 +0000 (12:37 -0700)]
Fix offset bug in qreply in cs

6 years agoMSI-X: Minor changes
Barret Rhoden [Wed, 2 Apr 2014 00:25:22 +0000 (17:25 -0700)]
MSI-X: Minor changes

Minor changes; one bar, some printing, etc.

You'll need to call this from ioapic.c instead of the regular MSI enable.

6 years agox86: Handles some bad keyboard data
Barret Rhoden [Wed, 2 Apr 2014 00:16:20 +0000 (17:16 -0700)]
x86: Handles some bad keyboard data

Some of our boards return 0xff when polling the KB, which isn't a proper scan
code (AFAIK).  Ideally, we'd check that the keyboard being released is a valid
scan code.

6 years agoRoundup the length on munmap().
Kevin Klues [Tue, 1 Apr 2014 23:31:00 +0000 (16:31 -0700)]
Roundup the length on munmap().

do_mmap() rounds the length up before mmapping, but we have no way of
notifying the user that this has happened.  When they do an unmap, the
length passed in needs to be rounded again, or bad things will happen.

6 years agoAdd ability for vfs fd_set/fd_array to grow on demand
Kevin Klues [Tue, 1 Apr 2014 22:08:31 +0000 (15:08 -0700)]
Add ability for vfs fd_set/fd_array to grow on demand

6 years agoGrow the 9ns fd array when necessary
Kevin Klues [Tue, 1 Apr 2014 19:41:51 +0000 (12:41 -0700)]
Grow the 9ns fd array when necessary

6 years agoFix ACPI FADT processing on qemu
Barret Rhoden [Tue, 1 Apr 2014 18:43:59 +0000 (11:43 -0700)]
Fix ACPI FADT processing on qemu

With 4GB of RAM, processing the FADT would cause a reboot...

6 years agox86: console polling ktasks
Barret Rhoden [Tue, 1 Apr 2014 17:57:05 +0000 (10:57 -0700)]
x86: console polling ktasks

For the AMD boards from which we can't get IRQs.  Turn on via Kconfig.

6 years agoInitializes rendez in devmnt
Barret Rhoden [Tue, 1 Apr 2014 01:16:38 +0000 (18:16 -0700)]
Initializes rendez in devmnt

Can't just memset rendezes to 0.  If so, you'll PF at 0x14, since the
cv->lock is 0.

6 years agomsi-x: allocate the proper number of pages.
Ronald G. Minnich [Tue, 1 Apr 2014 01:00:57 +0000 (18:00 -0700)]
msi-x: allocate the proper number of pages.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agomsi-x: read is a per-function property
Ronald G. Minnich [Tue, 1 Apr 2014 00:54:21 +0000 (17:54 -0700)]
msi-x: read is a per-function property

Add a pci_device struct member so we know if msix is working.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFixes listen/TCP bug
Barret Rhoden [Tue, 1 Apr 2014 00:15:33 +0000 (17:15 -0700)]
Fixes listen/TCP bug

Listeners wouldn't wake, at least for TCP, when the connection hung up.

6 years agoFixes TCP hangup bug
Barret Rhoden [Mon, 31 Mar 2014 23:29:19 +0000 (16:29 -0700)]
Fixes TCP hangup bug

The old check is always true, since raddr is an array.  This would break
when you try to hangup an announced, but unconnected conversation.

6 years agoMSI-X: first cut
Ronald G. Minnich [Mon, 31 Mar 2014 21:19:38 +0000 (14:19 -0700)]
MSI-X: first cut

The pieces here may be right, but I doubt they are completely right.
Please look hard at the addrhi, vector, and data variables.
Also, not sure I'm allocating enough contig pages.
There can be up to 2^10 entries, each entry is 16 bytes. That's
2^14 bytes I think?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAtomic PCI-space accesses
Barret Rhoden [Mon, 31 Mar 2014 18:02:22 +0000 (11:02 -0700)]
Atomic PCI-space accesses

These bugs would be very difficult to debug.  If the lock turns out to
be too expensive for bulk PCI ops, we can expose the lock and make some
__pci* versions.

6 years agoInitial code for msi-x
Ronald G. Minnich [Sat, 29 Mar 2014 21:36:40 +0000 (14:36 -0700)]
Initial code for msi-x

msi-x is pronounced "M SIX" btw, or M6. Not EMM ESS EYE EXX. Just

This is a template which I will be filling it.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFixes ping include
Barret Rhoden [Sat, 29 Mar 2014 04:53:37 +0000 (21:53 -0700)]
Fixes ping include

It worked on other machines that still had nixip.h in the toolchain

Also removed the old dead glibc link.

6 years agoSkip the shitty e1000s on c89
Barret Rhoden [Sat, 29 Mar 2014 01:54:41 +0000 (18:54 -0700)]
Skip the shitty e1000s on c89

The e1000s don't work with MSI.  One doesn't support it, and the other
flips out when MSI is used.  Those happen to be NICs l0 and l1.  Could
be more robust and fallback to l0 or something, etc.

6 years agoping.c
Barret Rhoden [Sat, 29 Mar 2014 01:52:40 +0000 (18:52 -0700)]

From NxM, ported to Akaros.

6 years agoFix genbuf/attach issue with specs
Barret Rhoden [Sat, 29 Mar 2014 01:52:06 +0000 (18:52 -0700)]
Fix genbuf/attach issue with specs

We were dropping off the spec for things like #l0.

6 years agoSets pthread to depend on benchutil
Barret Rhoden [Sat, 29 Mar 2014 01:20:32 +0000 (18:20 -0700)]
Sets pthread to depend on benchutil

Needed since futexes use the alarms.

6 years agoIncrease max nr NICs
Barret Rhoden [Sat, 29 Mar 2014 00:55:22 +0000 (17:55 -0700)]
Increase max nr NICs

c89 has more than 4.  But who could ever need more than 32?!?

6 years agoigbe: abort MSI for a shitty NIC
Barret Rhoden [Sat, 29 Mar 2014 00:53:42 +0000 (17:53 -0700)]
igbe: abort MSI for a shitty NIC

Not sure if it is HW or us, but MSI works on two other NICs.  On the
82545EM, once we use MSI, the NIC clobbers the RD buffer area with

6 years agoPCI: properly read the BARs
Barret Rhoden [Sat, 29 Mar 2014 00:52:07 +0000 (17:52 -0700)]
PCI: properly read the BARs

Was not stripping the MF bit, so multi-func BARs were coming back 0.

6 years agox86: Fixes PCI 8 and 16 byte accesses
Barret Rhoden [Sat, 29 Mar 2014 00:05:41 +0000 (17:05 -0700)]
x86: Fixes PCI 8 and 16 byte accesses

Instead of reading and writing on 32 byte boundaries, you are supposed
to access on the 32 byte boundary, but then do the data read/write from
an offsetted *IO port*.  There are a few of them, which sort of read
from the space directly.  Ugh.

Also, the offset into the config space will need to be up to 4KB, not
256, for PCI-E.  Ugh.

6 years agoigbe: use safer MMIO register access
Barret Rhoden [Fri, 28 Mar 2014 21:39:24 +0000 (14:39 -0700)]
igbe: use safer MMIO register access

Gcc might optimize the register accesses, so we need to use the
volatile* helpers.

6 years agoFix up mac printing for /net/arp
Ronald G. Minnich [Fri, 28 Mar 2014 18:52:19 +0000 (11:52 -0700)]
Fix up mac printing for /net/arp

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd function for finding unused BARs
Ronald G. Minnich [Fri, 28 Mar 2014 17:11:44 +0000 (10:11 -0700)]
Add function for finding unused BARs

MSI-X will need up to two unused BARs, and at least one.
Next step is code to find the MSI-X capability and fill in the

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdds the e1000, rtl8169, and ethermii drivers
Barret Rhoden [Fri, 28 Mar 2014 01:27:25 +0000 (18:27 -0700)]
Adds the e1000, rtl8169, and ethermii drivers

Ported to Akaros already, from the old 9namespace tree and
external-devices repo.

6 years agox86: Stop guessing IOAPIC routes
Barret Rhoden [Fri, 28 Mar 2014 00:49:12 +0000 (17:49 -0700)]
x86: Stop guessing IOAPIC routes

That hasn't worked on hardware yet.

Also fixes dumb bug in msi_mask_irq(): it could be called without the
MSI cap.

6 years agox86: MSI enabling and cleanup
Barret Rhoden [Fri, 28 Mar 2014 00:16:53 +0000 (17:16 -0700)]
x86: MSI enabling and cleanup

MSI has the irq_h style function pointers and fits in to the x86 irq
handling system.  The global MSI funcs fall under pci.h too.

Also, this takes MSI out of the business of messing with PCI bus

6 years agoIRQ func pointers param change
Barret Rhoden [Thu, 27 Mar 2014 23:29:50 +0000 (16:29 -0700)]
IRQ func pointers param change

MSI will need more info than just the vector.

6 years agox86: Fix pci_match_tbdf()
Barret Rhoden [Thu, 27 Mar 2014 22:37:04 +0000 (15:37 -0700)]
x86: Fix pci_match_tbdf()

And made it a PCI helper.  Also, bails out for all PCI devices when
match_tbdf fails.

Right now, the MSI enable mucks with my rtl8169 and attempting to
msi_enable() breaks the IRQ routing.

6 years agoRe enable MSI (does not crash anything that we can tell) and add prints
root [Thu, 27 Mar 2014 22:17:47 +0000 (15:17 -0700)]
Re enable MSI (does not crash anything that we can tell) and add prints

It will always act like it failed to enable, but it will go through the motions.

Signed-off-by: root <root@localhost.localdomain>
6 years agox86: LAPIC error handling
Barret Rhoden [Thu, 27 Mar 2014 21:46:42 +0000 (14:46 -0700)]
x86: LAPIC error handling

We were unmasking the error handler, but didn't have one registered.
We'd take an error, but then fail to send_eoi(), and then never received
further LAPIC IRQs (like the timer).

6 years agox86: fixes LAPIC unmasking
Barret Rhoden [Thu, 27 Mar 2014 21:44:24 +0000 (14:44 -0700)]
x86: fixes LAPIC unmasking

Was off by 0x320, not that it really had an effect.

6 years agoAdd comments to msi code; add new pci_clr_bus_master function
Ronald G. Minnich [Thu, 27 Mar 2014 21:03:35 +0000 (14:03 -0700)]
Add comments to msi code; add new pci_clr_bus_master function

The code is actually quite sensible. I'm wondering if we shouldn't
just bypass acpi ...

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agox86: misc MP/ACPI fixes
Barret Rhoden [Thu, 27 Mar 2014 19:47:25 +0000 (12:47 -0700)]
x86: misc MP/ACPI fixes

Needed more LVTs on some hardware, needed to scan all xioapics (the
array can be sparse), and when we don't have an IOAPIC, we need to treat
IPIs like the LAPIC.


6 years agoBring in msi support
Ronald G. Minnich [Tue, 18 Mar 2014 21:58:50 +0000 (14:58 -0700)]
Bring in msi support

We're going to have to have it.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agox86: APIC cleanup
Barret Rhoden [Mon, 17 Mar 2014 20:56:30 +0000 (13:56 -0700)]
x86: APIC cleanup

Cleanup of debug info, some dead code removal, better header work, etc.

Things work on qemu, though c89 is unhappy about of a bunch of things.
(bigger apics (nlvt > max), multiple botched buses, and a bus_irq_init
with a 0'd TBDF.

6 years agox86: LAPIC vector masking
Barret Rhoden [Mon, 17 Mar 2014 04:11:32 +0000 (21:11 -0700)]
x86: LAPIC vector masking

With another fake bus for IPIs (APIC messages), that can't be masked.

6 years agox86: IRQ routing and IOAPIC mask/unmasking
Barret Rhoden [Sun, 16 Mar 2014 19:55:39 +0000 (12:55 -0700)]
x86: IRQ routing and IOAPIC mask/unmasking

The distinction btw enabling, masking, and unmasking is a bit murky.
Right now, you can set up a bus IRQ, and separately mask and unmask it.
But we don't tear down the routes completely yet.

6 years agox86: can use the IOAPIC even without MP tables
Barret Rhoden [Thu, 13 Mar 2014 04:33:55 +0000 (21:33 -0700)]
x86: can use the IOAPIC even without MP tables

mpparse() usually builds the RDT structs.  If the mptables are missing
or o/w incomplete, we'll need to check with ACPI to fill in the holes.

Checks the ACPI MADT for intovrs or just guesses (which isn't wrong for
ISA) to build an RDT route.

Qemu, at least, has ACPI intovr entries for its PCI NIC.  If we have
hardware with no MP tables and without intovr entries, then we might be
out of luck.  I try guessing, just in case that works.  With MSI, it
should be less of an issue.

6 years agox86: MP table cleanup, multiple IOAPICs
Barret Rhoden [Thu, 13 Mar 2014 04:30:36 +0000 (21:30 -0700)]
x86: MP table cleanup, multiple IOAPICs

Shuts up the MP table a little, and allows us to handle multiple IOAPICs
without panicing.

6 years agox86: bus_irq_enable()
Barret Rhoden [Thu, 13 Mar 2014 01:13:06 +0000 (18:13 -0700)]
x86: bus_irq_enable()

All IRQs, regardless of acpi/mptable/etc or bus type call the same funcs
to register IRQs.  If we didn't parse MP/ACPI or o/w don't have an
IOAPIC, we'll fall back to using the PIC.

6 years agox86: one register_irq() for all types of buses
Barret Rhoden [Wed, 12 Mar 2014 23:31:41 +0000 (16:31 -0700)]
x86: one register_irq() for all types of buses

The 'raw' vectors are just the BusLAPIC type.  I didn't like the nxm way
of relying on BUSUNKNOWN to detect if it was potentially LAPIC.  That
meant you'd always need a bus (like BusPCI) and not just the IRQ for any
external IRQ numbers that were within the LAPIC vector range.

Another way to put it: the LAPIC 'irq' and the global system irq
(devices/acpi) share a different domain, so we need to differentiate on
the bus.

6 years agox86: IDT vector realignment (XCC)
Barret Rhoden [Wed, 12 Mar 2014 21:49:05 +0000 (14:49 -0700)]
x86: IDT vector realignment (XCC)

Lays out what each IDT vector is used for, somewhat merging with the
Plan 9 stuff.  These are the vectors that the processor/LAPIC sees, not
the external IRQs.

This also changes the trap syscall vector to 0x40 (64), and the LAPIC
timer vector.

You need to reinstall your kernel headers and rebuild anything that made
trap based syscalls (parlib and all MCPs).  Not sure if you need to
rebuild the toolchain (probably not).

6 years agox86: MP table-detected ISA IRQs can be enabled
Barret Rhoden [Wed, 12 Mar 2014 04:00:44 +0000 (21:00 -0700)]
x86: MP table-detected ISA IRQs can be enabled

This also removes the polling of the serial device, which was a hack for
Ron's AMD board.  If we still need that, even with the IOAPIC, then we
should use a ktask.  And I'll be annoyed.

6 years agoRemoves shift-G from the escape codes
Barret Rhoden [Wed, 12 Mar 2014 03:36:23 +0000 (20:36 -0700)]
Removes shift-G from the escape codes

You can type G now, and have devices like #G.  Crazy!

6 years agoAdds the UCB-Plan 9 license
Barret Rhoden [Wed, 12 Mar 2014 03:26:22 +0000 (20:26 -0700)]
Adds the UCB-Plan 9 license

With a ref to it in LICENSE, for all the headers that just say LICENSE
and not LICENSE-PLAN9.

6 years agox86: moves the PIT into time.{h,c}
Barret Rhoden [Wed, 12 Mar 2014 03:18:28 +0000 (20:18 -0700)]
x86: moves the PIT into time.{h,c}

It's been cluttering the unrelated APIC files for about five years now.

6 years agox86: moves the PIC into its own file
Barret Rhoden [Wed, 12 Mar 2014 03:01:34 +0000 (20:01 -0700)]
x86: moves the PIC into its own file

6 years agox86: PICs for everyone!
Barret Rhoden [Wed, 12 Mar 2014 02:48:46 +0000 (19:48 -0700)]
x86: PICs for everyone!

Turns on the PIC all the time, but masks it.  And cleans up the PIC
initialization a bit, with the goal of removing ENABLE_MPTABLES.

6 years agox86: irq handler func pointers
Barret Rhoden [Wed, 12 Mar 2014 02:28:40 +0000 (19:28 -0700)]
x86: irq handler func pointers

This is more in line with modern OSs (plan 9, linux), where we have some
struct tracking what to do at a given vector, instead of branching on
the trap number.

6 years agoRemove dead code.
Ronald G. Minnich [Fri, 21 Mar 2014 22:41:55 +0000 (15:41 -0700)]
Remove dead code.

No longer used and can't even really be configured.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoThe last piece to test VMs; disable interrupts before starting one
Ronald G. Minnich [Fri, 21 Mar 2014 22:41:25 +0000 (15:41 -0700)]
The last piece to test VMs; disable interrupts before starting one

Can't test as IOAPIC is borked.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoMove timeout code to other side of uthread yield.
Kevin Klues [Fri, 21 Mar 2014 17:51:12 +0000 (10:51 -0700)]
Move timeout code to other side of uthread yield.

Also, only spin on awaiter->data if a timeout was set, and return the
proper value from the futx_wake() call.

6 years agoRearrange the timeout logic to be a little more efficient
Kevin Klues [Fri, 21 Mar 2014 09:49:06 +0000 (02:49 -0700)]
Rearrange the timeout logic to be a little more efficient

Also beef up the comments a bit

6 years agoUpdate pthread futexes to use alarms for timeouts
Kevin Klues [Fri, 21 Mar 2014 06:11:22 +0000 (23:11 -0700)]
Update pthread futexes to use alarms for timeouts

One side effect of this is that the pthread library now depends on
benchutil.  We may want to revisit this dependency.

6 years agoFix bug with duping fds for plan 9 files
Kevin Klues [Fri, 21 Mar 2014 05:53:06 +0000 (22:53 -0700)]
Fix bug with duping fds for plan 9 files

I added a new claim_fd() function similar to the get_fd() and put_fd()
functions in vfs.c.  When duping plan9 fds for a new_proc via dupfgrp()
we call claim_fd() to update the new_proc's open_file list shared with
the vfs.

I also swapped the order of put_fd() and setting the fd in
src/ns/sysfile.c to avoid a potential race condition with the assert in

6 years agoRemove debug prints from cs and csquery
Ronald G. Minnich [Wed, 19 Mar 2014 15:12:19 +0000 (08:12 -0700)]
Remove debug prints from cs and csquery

These now work with the workaround for missing access(2)
and the fixed up llseek system call.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd llseek support for the plan 9 namespace
Ronald G. Minnich [Wed, 19 Mar 2014 14:59:05 +0000 (07:59 -0700)]
Add llseek support for the plan 9 namespace

This fixes, among other things, csquery.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoDebugging hacks.
Ronald G. Minnich [Wed, 19 Mar 2014 02:41:49 +0000 (19:41 -0700)]
Debugging hacks.

Note that offset is 17 in the Tread to cs. Bogus. How's it
getting set to 17?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoCopy hexdump over to parlib
Ronald G. Minnich [Wed, 19 Mar 2014 02:27:30 +0000 (19:27 -0700)]
Copy hexdump over to parlib

It's very handy at times.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFix up bugs in IP query
Ronald G. Minnich [Wed, 19 Mar 2014 00:21:18 +0000 (17:21 -0700)]
Fix up bugs in IP query

the problem was we don't implement access(2) yet

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFix csquery.c
Ronald G. Minnich [Tue, 18 Mar 2014 23:10:17 +0000 (16:10 -0700)]
Fix csquery.c


Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFurther cleanup, but the behavior of procgen eludes me.
Ronald G. Minnich [Tue, 18 Mar 2014 00:35:39 +0000 (17:35 -0700)]
Further cleanup, but the behavior of procgen eludes me.

ctl is still not visible.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agolindent proc. Add in commands.
Ronald G. Minnich [Tue, 18 Mar 2014 00:13:23 +0000 (17:13 -0700)]
lindent proc. Add in commands.

We can now do kill and closefiles on procs. These
are extremely handy.

But the ctl file doesn't show up.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoForce the Qcoalesce flag on pipe fds
Kevin Klues [Fri, 14 Mar 2014 23:32:43 +0000 (16:32 -0700)]
Force the Qcoalesce flag on pipe fds

Without this writes can produce blocks of length 0, and reads can read
them.  This causes problems since reading a zero length blcok returns 0
, and 0 means EOF from the perspective of user space.  Turning on the
Qcoalesce flag removes these 0 length blocks from consideration.

6 years agoExplicitly set the SI_USER flag when signaling
Kevin Klues [Fri, 14 Mar 2014 03:04:52 +0000 (20:04 -0700)]
Explicitly set the SI_USER flag when signaling

Also set any default signal handlers that should be SIG_IGN to the
actualy SIG_IGN pointer instead of to a new function that just does

6 years agoAdd a simple ps command.
Ronald G. Minnich [Thu, 13 Mar 2014 22:28:35 +0000 (15:28 -0700)]
Add a simple ps command.

ash /bin/ps works.
/bin/ps fails, for reasons I don't understand.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoremove monitor call that was used for debugging and is not needed
Ronald G. Minnich [Thu, 13 Mar 2014 22:24:39 +0000 (15:24 -0700)]
remove monitor call that was used for debugging and is not needed

6 years agoGet user to build with the new libraries.
Ronald G. Minnich [Thu, 13 Mar 2014 22:05:05 +0000 (15:05 -0700)]
Get user to build with the new libraries.

Lots of libraries came back, and things stopped building.
Note that Barret's cheap dial is commented out.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoGet status entry in /proc
Ronald G. Minnich [Thu, 13 Mar 2014 21:01:46 +0000 (14:01 -0700)]
Get status entry in /proc

Poor man's ps

/ $ cat '#p/1/status'
       1 WAITING         0/ $

Note: new newline.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoBring the proc device back.
Ronald G. Minnich [Thu, 13 Mar 2014 18:18:13 +0000 (11:18 -0700)]
Bring the proc device back.

We can now view namespaces and such.
I'll extend this more to get us real info.

/ $ ls '#p'
1          trace      tracepids
/ $ cat '#p/1/ns'
cd /
/ $ ash /ifconfig
bind #c -> /dev flag 1
bind #p -> /proc flag 1
bind #s -> /srv flag 1
bind #I -> /net flag 2
bind #l0 -> /net flag 2
Incoming IRQ, ISR: 73 on core 0
I am, default route
/ $ cat '#p/1/ns'
bind  /dev /dev
bind -b #c /dev
bind  /srv /srv
bind -b #s /srv
bind  /net /net
bind -a #I /net
bind -a #l /net
cd /
/ $

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd srvname back
Ronald G. Minnich [Thu, 13 Mar 2014 15:27:48 +0000 (08:27 -0700)]
Add srvname back

We'll need it for proc.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoFix omode handling in dev/srv; have csquery always open #s/cs until we are sure bindi...
Ronald G. Minnich [Tue, 11 Mar 2014 20:41:51 +0000 (13:41 -0700)]
Fix omode handling in dev/srv; have csquery always open #s/cs until we are sure binding works

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd the ndb files needed to make basic csquery work
Ronald G. Minnich [Tue, 11 Mar 2014 19:17:12 +0000 (12:17 -0700)]
Add the ndb files needed to make basic csquery work

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoPlan 9 programs for controlling and checking the network: cs.c, csquery.c, netstat.c
Ronald G. Minnich [Tue, 11 Mar 2014 19:14:05 +0000 (12:14 -0700)]
Plan 9 programs for controlling and checking the network: cs.c, csquery.c, netstat.c

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd ndblib and iplib
Ronald G. Minnich [Tue, 11 Mar 2014 19:04:43 +0000 (12:04 -0700)]
Add ndblib and iplib

Needed for connection services

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
6 years agoAdd default page fault handling to map to SIGSEGV in pthreads
Kevin Klues [Tue, 11 Mar 2014 18:42:16 +0000 (11:42 -0700)]
Add default page fault handling to map to SIGSEGV in pthreads

I refactored the signal handling code a bit so that page faults in our
pthread library trigger SIGSEGV signals that application code can