Split arch/memory.h to aspace.h and stack.h, add generic mm/aspace.h

The generic mm/aspace.h is added to contain additional definitions based
on the architecture definitions, currently *_END definitions for each
range. Replaced uses of XXX_BASE + XXX_SIZE with XXX_END.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add initial draft of IPC API and some example code

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add attach and detach hooks to object_type_t

These functions are called when a handle is attached to or detached from
a process. They will be used by the IPC code to determine when a port's
owner no longer references the port. Also refactored some of the object
manager code.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Keep a thread's security context constant the whole time it is in the kernel

A thread's security context should remain constant for the whole time it is
in the kernel so that its identity and privileges do not change between
security checks if another thread changes the process-wide security context.
Do this by saving the token returned by the first call to
security_current_token() and returning the same one from all subsequent calls.
The saved token is cleared by thread_at_kernel_exit() so that any identity
changes take effect the next time the thread enters the kernel.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add security_current_context() function

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Fix completely broken condvar_signal()

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Moved token_current() to token.c, fixed a number of bugs

Don't need a separate file just for one function, so move it to token.c.
Also fix a few bugs: since token_current() doesn't add an extra reference
to the token, token_release() shouldn't be called on the returned token,
and fixed an incorrect error return value.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add semaphore_reset() function to unblock all threads waiting on a semaphore

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add object_handle_open()

Added a shortcut function for creating a handle and then immediately
attaching it to a process.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Pass NULL name to vm_map() in kernel ELF loader to name regions using file path

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add new IPC-related status codes, remove no longer needed ones

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Implement the new IPC system

Initial implementation of the new IPC system. It is mostly complete, except
for kern_connection_forward(), and process/thread special ports. Probably
still has some bugs, but I spent a great deal of time thinking about possible
race conditions etc. so I'm fairly confident it should work pretty well.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add IPC test program

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add const to entry argument to kern_thread_create()

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Forgot to update libkernel when kern_thread_create() was changed

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Implement process root ports

Processes can now have an associated root port that can be connected to by
specifying PROCESS_ROOT_PORT as the port to kern_connection_open(). The root
port will be used by processes to communicate with the service manager
instance for their session, which can then be used to look up other services.
New processes can have a new root port specified in the process_attrib_t
structure, or if none is specified, they inherit their parent's root port.
Also cleaned up the process/thread code a bit, and added missing support
for {PROCESS,THREAD}_SELF to some syscalls.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Update IPC test application to use root port functionality

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Change copyright date on template files to 2014.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Fix return value of process_access() (always returned true, oops...)

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>