Thread0 can call pthread_exit()

Needed to not free thread0's TLS (it was never malloc'd), and needed to
trigger exit() when the last pthread (including thread0) exits.
Slightly more consistent VC count interfaces

The main concern was the size of size_t vs uint32_t.  We're still sloppy
about uint32_t vs int.

The kernel header still has max_vcores as a size_t.  I'll change that
next time I muck around in that part of the headers (I don't want to
force more toolchain rebuilds).
Multiboot memory detection fixes

A few things:
- Multiboot's regions don't cover all of physical memory; it has holes.  We now
  init the pages[] array (for x86) to mark all pages as busy, and explicitly
  mark the free pages.
- The previous version of this worked a little, since the unmarked, non-free
  pages weren't on any free page lists.  However, the contiguous memory
  allocator (which is really lousy btw) looks directly at refcnts, bypassing
  the lists.
- One problem is that there is a big chunk of unusable memory around 0xfec00000
  (IOAPIC and friends).  This was working okay with multiboot's memory
  mappings, but not with qemu's "here's a lot of memory" approach.  In lieu of
  doing full-fledged memory detection/probing, I'm just ignoring physical
  memory from [0xc0000000, 0xffffffff].  This only applies to qemu, when
  launched with the -kernel flag.
- 32 bit had some other issues when giving out memory near the 4GB mark, as
  well as having other issues with 64 bit addresses (note some of the changes
  from %p to 0x%016llx).
- The bug with giving out pages that were mapped to IO/BIOS/x86 magic regions
  in high memory showed up as clobbered bookkeeping in small slab pages in
  kmem_cache_grow() (stored at the end of the pages improperly allocated).
  Good times!
ROUNDDOWN can handle uint64_t on 32 bit (XCC)

ROUNDDOWN was casting to a uintptr_t, which would truncate a uint64_t on
32 bit builds.  (Came up in mboot parsing, when pages above
0x0000000100000000 would get treated as if offset from 0).

Since the compiler complains about the int->pointer->int casting, even
in code that should never be called (based on the sizeof() in
ROUNDDOWN), we had to make ROUNDDOWN (and ROUNDUP) only work on
uintptr_t.  Ideally, we'll fix that in the future (C11 features,
perhaps).

You should reinstall your kernel headers to get the new changes for
userspace, though it's not a huge deal.
Add plan 9 namespace. Fails on chan.c but we're working on that.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Trivial changes toward compiling.
And further changes.
compiles, does not link
more support functions.
Need to get the devtab ldscript bit done.
Boots, and there is a monitor command (9open) to serve as a model for the rest.
To test, type
9open #Z 0
(#Z being a plan 9 notation for device Z, my regression device)

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Namec works. Waserror is way improved.

It's not quite as easy to use as Plan 9 but waserror is way better.
It also now has a great deal of integrity checking at the cost of a bit more
work on the programmer's part.

And, the 9open test works :-)

Changes to date and issues:
changing incref/decref to krefs (semantics)
removing utf-8
Translating proc structs
The fact that we don't have current-> or up->

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Print the returned fd

9open/sysopen works. There is still some ordinance left should you
open a non-# file, however.

Focusing on read/write next.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Implement read system call

The read system call is by far the harder of the two. It includes directory
reads and that includes union mount reads, with all corner cases included.

The test is:
9open #Z 0
get the returned fd -- in this case, usually 0
Try to read 22 bytes @ 0
9read 0 22 0
Fails. But, doesn't panic or do anything nasty. The waserror stuff is working
very well.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Implement write.

One can now
9open #Z/regressctl 0
9write 0 v 1 0

and watch it explode ... but a fix will happen.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Write works.

I'm going to yank a lot of these debug prints at some point but
they're handy.

Turns out write always worked, I was opening the file readonly and the
kernel objected.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Stitch plan 9 open into sys_open

This seems to be working; the oflags are bog-standard unix. Not sure
how to manage the omode yet.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Get write working

Add create as well, since ash calls with flags O_CREAT|O_TRUNC

not working yet, need to do readdir first however.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
convert functions to akaros-style dirents

convM2A converts to akaros kdirents, which we hope to make less limiting
in the future. We might, for example, return more informative dirents
from the kernel and then cut them down to
POSIX-style braindead dirents in a library.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Add start of plan 9 doc.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
more text.

I'm finding issues with amend, so this is a new push.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
readdir and stat.

With this set of changes,
ls '#Z'
works

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
IO works a bit more

ls '#Z' gets one file, not two
All IO gets EPERM

stat command seems to work OK.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
More stuff working, io still fails

It's kind of amazing how much work a simple
echo hi > x
involves on Unix. Just amazing. Had to add some kind of fcntl support.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
use the current pointer.

Somehow I missed current.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>