David Zhu [Wed, 26 Jan 2011 23:35:52 +0000 (15:35 -0800)]
Make arsc and local async calls use the same structure.
Instead of putting the entire call and the parameters in the ring,
we now use a pointer to an external structure that the caller waits
on.
This allows for consistent waiting interface on both remote and
local calls.
David Zhu [Mon, 15 Nov 2010 02:23:32 +0000 (18:23 -0800)]
Adding test case for multproducer async calls.
Fixed ring buffer and arsc to support out of order processing.
Eventually this will be converted to use similar mechanisms as local
async calls and simply use the ring buffer as a way of shipping async
call structures around.
David Zhu [Thu, 28 Oct 2010 21:34:23 +0000 (14:34 -0700)]
More addition to arsc infrastructure.
Specifically, decoupling arsc call page from procdata.
Create an interface that may be used for proc-to-proc call.
Preparing arsc for multi-threaded calls and reordering of request/response.
David Zhu [Fri, 20 Aug 2010 21:13:49 +0000 (14:13 -0700)]
cosmetic change. removing unnecessary elf_info struct.
Barret Rhoden [Wed, 30 Mar 2011 01:47:08 +0000 (18:47 -0700)]
Make clean also cleans userspace
It was just cleaning the kernel and tests.
Barret Rhoden [Sat, 26 Mar 2011 00:22:33 +0000 (17:22 -0700)]
mmap() with addr 0 will start from BRK_END
I might prefer having userspace be the one to adjust the addr to BRK_END
instead of the kernel, but this gets the job done.
Barret Rhoden [Fri, 25 Mar 2011 21:05:24 +0000 (14:05 -0700)]
Disable notifs when changing TLSs
Barret Rhoden [Fri, 25 Mar 2011 20:29:40 +0000 (13:29 -0700)]
More careful about memory allocations
Also note we could have been freeing the wrong size of stacks if someone
happened to use the attrs.
Barret Rhoden [Wed, 23 Mar 2011 20:52:00 +0000 (13:52 -0700)]
Hash for each helpers
In case you want a for each over each value of the hash. Not a big
deal.
Barret Rhoden [Fri, 18 Mar 2011 00:24:27 +0000 (17:24 -0700)]
Fixes uthread sysc block logic
The old version would only screw up if we blocked in uthread_init()
before we entered _M mode. This way is much clearer, and provides an
approved way to see if you're _M or not.
Barret Rhoden [Thu, 17 Mar 2011 23:26:59 +0000 (16:26 -0700)]
Properly clears cur_sysc when leaving a core
This was responsible for the PF when bin_run()ning a non existant
program after running a program on core 0.
Barret Rhoden [Thu, 17 Mar 2011 22:06:08 +0000 (15:06 -0700)]
Test functions for blocking
You can use looper.sh to run an app until it fails (or you reboot).
Use it from busybox with: ash looper.sh block_test.
Barret Rhoden [Wed, 16 Mar 2011 02:38:39 +0000 (19:38 -0700)]
Fixes bug in pop_ros_tf
Brutal bug, where branches would make the wrong decision and syscall
structs would get clobbered. EFLAGS wasn't restored, so an unlucky
IPI/notification would result in bad CCs. Note: subl and addl affect
the flags.
Also, don't use the vcore stack for things like syscall struct storage
after you enable notifs! Once notifs are enabled, you should not be
touching the vcore stack.
Barret Rhoden [Wed, 16 Mar 2011 02:16:09 +0000 (19:16 -0700)]
Fixes mhello to play nice with uthread
Previously, you wouldn't be able to restart thread 0.
Barret Rhoden [Tue, 15 Mar 2011 21:32:14 +0000 (14:32 -0700)]
Catch bugs in sys_block()
Do not call sys_block (or sleep in a blockdev blocking call!) in more
than one place at a time. This will try to catch multiple uses of the
interrupt handler's void*, though it isn't atomic so it will not catch
everything.
Barret Rhoden [Mon, 14 Mar 2011 21:58:46 +0000 (14:58 -0700)]
Stop passing uthread to __uthread_yield()
No need to, and there's a chance of it fucking around with stacks before
we fully get in vcore context.
Barret Rhoden [Mon, 14 Mar 2011 18:56:34 +0000 (11:56 -0700)]
Removes vcores_wanted() from 2LS ops
It was only called from thread_runnable, which was right after another
2LS op where they can just request what they want.
Barret Rhoden [Mon, 14 Mar 2011 18:47:51 +0000 (11:47 -0700)]
Pthread: stop accessing memory after it was freed
Barret Rhoden [Mon, 14 Mar 2011 18:41:56 +0000 (11:41 -0700)]
Support for blocking and restarting uthreads (XCC)
Test it out with SYS_block. Uthreads will call out to the 2LS to block
on syscalls. Pthread code has an example of what to do (though it
doesn't deal with missed messages/overflow yet).
This also introduces a 'state' variable for uthreads, which is mostly
used for debugging in various places.
There's an odd bug floating around still, noticed most recently in
being in vcore_context in thread_yield. It isn't obvious, relies on
timing, and is very rare. If you get it regularly, call me.
Rebuild your cross compiler, or at least reinstall your kernel headers.
Barret Rhoden [Mon, 14 Mar 2011 16:34:00 +0000 (09:34 -0700)]
Atomic or for ints (flag variables)
Barret Rhoden [Mon, 14 Mar 2011 16:31:28 +0000 (09:31 -0700)]
Fixes user/parlib arch symlink
Barret Rhoden [Sat, 12 Mar 2011 02:17:02 +0000 (18:17 -0800)]
vcore_idle()
When you don't want to give up a vcore, but you don't know what to do.
Can only break out via an IPI/notif/interrupt.
Barret Rhoden [Fri, 11 Mar 2011 01:24:43 +0000 (17:24 -0800)]
Fixes _exit and abort() to use exit codes (XCC)
abort() is a bit ugly, but it works for now. If you ever see an exit
value of 1337, it is because the kernel directly called proc_destroy().
Rebuild your cross compiler if you want this stuff to work.
Barret Rhoden [Thu, 10 Mar 2011 02:32:22 +0000 (18:32 -0800)]
Proactive 0s new vm_region structs
This will help catch bugs for now, though if you're using create_vmr(),
be sure to read the comment telling you how to use it! Caller is
supposed to initialize the extra fields.
Barret Rhoden [Tue, 8 Mar 2011 03:01:48 +0000 (19:01 -0800)]
Minor changes to proc_restartcore()
Barret Rhoden [Tue, 8 Mar 2011 01:25:39 +0000 (17:25 -0800)]
uthread yield and exit code merged
Exit now calls yield with a DYING flag set. 2LSs still have both
callbacks; this just simplifies uthread code a bit. uthread_yield() is
now the only way for a uthread to pause its state and hop into vcore
context. Exit does this, just without worrying about its old context.
Barret Rhoden [Tue, 8 Mar 2011 00:04:39 +0000 (16:04 -0800)]
GCC/uthread callbacks on blocking syscalls (XCC)
Doesn't do much yet, just runs a 2LS handler. The uthread stuff will
change a bit soon, and that handler will run in the bottom half of a
yield-ish path in vcore context.
Rebuild your cross compiler.
Barret Rhoden [Sat, 5 Mar 2011 01:41:18 +0000 (17:41 -0800)]
MCS locks have a "notification-safe" variant
Any lock that is grabbed from vcore context needs to use
mcs_lock_notifsafe(), which is analagous to using irqsave in the kernel
on its spin_locks.
Barret Rhoden [Sat, 5 Mar 2011 00:14:19 +0000 (16:14 -0800)]
2LS op for how many vcores to request
Called out of uthread_runnable(), for now. Yielding or whatever is done
by the 2LS sched_entry(), which should never return.
Barret Rhoden [Fri, 4 Mar 2011 23:16:48 +0000 (15:16 -0800)]
MCS locks are smaller and don't rely on vcore_id()
If you had a non-irq_save MCS lock, you would have issues with having
multiple threads lock on the same vcore, or a thread locking and
unlocking on different vcores.
Also, this only uses memory for the callers spinning location (the
qnode) when needed, instead of statically allocating it. The memory for
these should be per-thread (TLS, stack, whatever). This also gets rid
of the need for the padding.
Barret Rhoden [Fri, 4 Mar 2011 01:56:43 +0000 (17:56 -0800)]
Makes 'make' make less noise
Barret Rhoden [Fri, 4 Mar 2011 01:54:43 +0000 (17:54 -0800)]
Allows apps to implement vcore_entry() (XCC)
By default, vcore_entry() calls uthread_vcore_entry(), which is the
standard way to work with user-threads / 2LSs. An app can write a
vcore_entry(), but you'll miss out lots of things.
Rebuild your cross compiler.
Barret Rhoden [Fri, 4 Mar 2011 00:48:20 +0000 (16:48 -0800)]
Split uthread code into its own source file
Some things were a bit uneven, mostly due to event code calling some
functions that think there is a 2LS / sched_ops. That sort of stuff
goes into uthread. If you want to not use the uthread code, then you
get to write your own event handling helpers too. Have fun working with
the raw kernel interface!
Kevin Klues [Thu, 3 Mar 2011 04:24:07 +0000 (20:24 -0800)]
Cosmetic changes, biggest being current_thread renamed to current_uthread
Barret Rhoden [Thu, 3 Mar 2011 01:55:41 +0000 (17:55 -0800)]
Moves retvals, start_routine, and args to the 2LSs
Gets the vcore/uthread code out of the business of worrying about
function arguments, stacks, return values, etc. It also cleans up the
pthread code a bid (don't have to look into the uthread much), with the
exception of init_user_tf(). No way to avoid that look (either for
that, or for stacktop).
It also splits uthread_create() from uthread_runnable(), which was
necessary for the arg indirection (which we did in uthread before), and
is also sort of nice.
Not 100% on this. Depends if we're going to want schedulers that don't
care about retvals, args, and such, or if they want to do it in a way
that isn't pthreads. Imagine a creating a thread that takes more than
one argument!!! *gasp*! My main concern is that pthread-specific
things get buried in the vcore/uthread code.
Barret Rhoden [Thu, 3 Mar 2011 01:06:36 +0000 (17:06 -0800)]
Pulled code specific to all 2LS out of pthread.c
In general, I tried to keep things the same as before. Things got
moved, but there should be very little new behavior. For instance,
uthread_yield is the old pthread_yield, but with a call out to the 2LS
to do its thing. Its thing is the same pthread-specific thing as
before.
The test programs that had a vcore_entry() needed to be changed. Don't
trust any of them, though mhello and syscall still work well. The
others are so ancient it isn't worth keeping them up, esp since they do
stuff they shouldn't.
c3po doesn't build, mostly due to issues with current_thread. That
specific __thread belongs to the vcore. c3po can either use vcores,
like the pthread code does or have another that it uses. I didn't want
to mess with this too much, so you'll get compile errors.
Barret Rhoden [Wed, 2 Mar 2011 19:08:04 +0000 (11:08 -0800)]
Pthread code makes sure it goes into _M mode
Was causing assertion failures since it wasn't really in _M mode (which
is what the assertions are there for!). Adds a few more assertions
about when we are in vcore_context.
Barret Rhoden [Wed, 2 Mar 2011 19:11:15 +0000 (11:11 -0800)]
Minor bug fix in resource.c
Only affects a few commits.
Kevin Klues [Wed, 2 Mar 2011 01:15:31 +0000 (17:15 -0800)]
Complete rewrite of c3po for multicore
I'm trying to factor the code in such a way that we can use a common code base
for both ROS and linux. In the current revision, everything only runs on ROS,
but soon all "vcore" specific code can be implemented for linux by spawning an
underlying linux task and scheduling user threads on top of them.
Currenlty the code only runs reliably if we simply jump to multicore mode, but
don't put any more requests in for vcores (i.e. vcore_request is only called
once, asking for one core). We are working through the bugs to figure out why
this is the case, but most signs point to either a kernel bug, or a low level
userspace bug, beneath the library code implemented here. the test app for
c3po is still under tests/c3po/c3po_test.c
Kevin Klues [Wed, 2 Mar 2011 01:13:36 +0000 (17:13 -0800)]
Rename of *debug* functions to ros_*debug*
Mostly to reduce naming conflicts with other libraries that want to have
functions called debug.
Kevin Klues [Wed, 2 Mar 2011 01:12:39 +0000 (17:12 -0800)]
Stray ) in the install targets removed
Kevin Klues [Wed, 23 Feb 2011 03:45:56 +0000 (19:45 -0800)]
Make c3po compile with std=gnu99
Barret Rhoden [Tue, 1 Mar 2011 22:11:46 +0000 (14:11 -0800)]
proc_destroy() refcnting issues dealt with
proc_destroy() needs to have an edible reference, which it did not have
from __do_mmap(). Incidentally, we just don't call it from there
anymore, but there were a few other unlikely errors that would be
problems.
For now, all code using a struct proc * needs to know where it got the
refcount from. Code in the syscall path (and mm.c) usually is
'borrowing' the ref from current, and is not able to be passed without
incref to certain functions. Also note that you can't incref too much,
since functions like proc_destroy() assume they are taking your
"working" reference (i.e., the one you passed to the function) that
should be refcnt'd exactly once.
As this is the most likely way to fuck up ref counting with processes,
if you see something odd with refcnts (kref assertions, env_cr3 != rcr3,
etc), look in places that involve these "might-not-return" functions.
Barret Rhoden [Mon, 28 Feb 2011 23:41:45 +0000 (15:41 -0800)]
Proc refcnting wrappers
Uses proc_incref() and proc_decref() for help with debugging. Note that
not all sources of incref are via proc_incref() (specifically,
pid2proc()), and other places can still access the kref directly.
Barret Rhoden [Mon, 28 Feb 2011 22:05:26 +0000 (14:05 -0800)]
PROC_DYING cases handled
Yield and tlbshootdown can handle a dying process. Should get rid of
annoying warnings/panics.
Barret Rhoden [Mon, 28 Feb 2011 19:11:10 +0000 (11:11 -0800)]
User code can tell if it is in vcore context (XCC)
Use the function in_vcore_context(). Also moved some functions to
vcore.h that can be easily inlined.
Rebuild your cross compiler.
Barret Rhoden [Fri, 25 Feb 2011 22:03:00 +0000 (14:03 -0800)]
Allows application-specific event handling (XCC)
Programs can assign ev_handlers to an event queue. Mostly untested, for
now.
Reinstall your kernel headers.
Barret Rhoden [Fri, 25 Feb 2011 00:42:36 +0000 (16:42 -0800)]
Vcore helper for clearing notif_pending
Clears pending, catches most of the races. pop_ros_tf() is still the
final point to catch those sorts of things. Changes to ros/membar.h are
cosmetic, so you shouldn't need to reinstall kernel headers or rebuild
your XCC.
Barret Rhoden [Thu, 24 Feb 2011 23:45:07 +0000 (15:45 -0800)]
Event handlers also take the ev_type
So handlers call for bits/no_msg can tell what type they are, which
would be useful for a generic handler.
Barret Rhoden [Thu, 24 Feb 2011 23:36:46 +0000 (15:36 -0800)]
enable_kevent() takes flags, not a bool
Some places were already using flags, which is more flexible. Not that
enable_kevent() is really that great anyway...
Barret Rhoden [Thu, 24 Feb 2011 22:48:03 +0000 (14:48 -0800)]
VCORE_APPRO sets the ev_mbox
When the kernel is picking what the vcore ought to be, the kernel will
use the vcore's ev_mbox. Needs to be this way, since the user doesn't
know which vcore the message is going to (which is the nature of
VCORE_APPRO). If want something that allows a message to go to an
ev_q's mbox, but the IPIs to get sent somewhere else, then use something
like Round-Robin.
Barret Rhoden [Thu, 24 Feb 2011 20:18:15 +0000 (12:18 -0800)]
2LS handles pending preemptions
Initial 2LS schedule_ops, one of which is a sched-specific way to deal
with a pending preemption.
Barret Rhoden [Wed, 23 Feb 2011 23:03:25 +0000 (15:03 -0800)]
Fix for not having a cr3 loaded at all times
If you were in _M mode and sent and event from a core with no proc
current, you'd end up with the old proc's cr3 loaded.
Barret Rhoden [Wed, 23 Feb 2011 22:41:45 +0000 (14:41 -0800)]
Default event handling infrastructure
2LSs/whoever can register handlers in ev_handlers to deal with specific
events. For now, use the default ev_ev handler for EV_EVENT.
handle_events() works for a vcore's default mbox, and handle_event_q()
works for generic ev_qs.
Barret Rhoden [Wed, 23 Feb 2011 22:41:23 +0000 (14:41 -0800)]
Vcore helper for enable/disable notifications
Barret Rhoden [Wed, 23 Feb 2011 22:35:00 +0000 (14:35 -0800)]
Bitmask updates
Extracted some arch-indep code into inc/bitmask.h. Adds
BITMASK_FOREACH_SET(), which will execute a function passing it the
number of each set bit in the map.
Barret Rhoden [Thu, 24 Feb 2011 00:55:57 +0000 (16:55 -0800)]
Makefile cosmetics
David Zhu [Tue, 22 Feb 2011 06:37:28 +0000 (22:37 -0800)]
Adding a debug function to printout buffers like tcpdump.
David Zhu [Tue, 22 Feb 2011 09:19:03 +0000 (01:19 -0800)]
General E1000 cleanup documentation and fixes
Paul network cherry-pick #2.
--------------------------
This is a general cleanup commit. I added extensive documentation
as well as cleaned up ugly parts of code.
fixed some subtle issues with the RX and TX descriptor rings
that could result in odd behavior.
Conflicts:
kern/arch/i686/e1000.c
Paul Pearce [Thu, 22 Apr 2010 21:32:59 +0000 (14:32 -0700)]
Build system to map MMIO into our virtual address space.
cherry-pick paul commit #1
Added a new function, mmio_alloc, which pulls pages from the space
above LAPIC_BASE + PGSIZE, and maps them to physical pages that
are used for MMIO by devices.
This removes all the hacky MMIO code from the driver and arch/pmap.c
David Zhu [Tue, 22 Feb 2011 06:45:22 +0000 (22:45 -0800)]
Quick fix to the compile error.
Kevin Klues [Tue, 22 Feb 2011 05:29:45 +0000 (21:29 -0800)]
Only compile statically for c3po tests the same as other tests
Kevin Klues [Tue, 22 Feb 2011 05:29:28 +0000 (21:29 -0800)]
Force glibc libraries into kfs on install-libs make target
Kevin Klues [Tue, 22 Feb 2011 02:54:01 +0000 (18:54 -0800)]
Addition of c3po library, including revamp of Make system for user libraries.
The c3po library is currently only functional in single core process mode, with
threads that run to completion or yield the processor voluntarily. No AIO
functionality is working yet either. I plan to soon get it working in
multi-core mode so that its threads can be multiplexed on multiple vcores as
well as get the AIO stuff working. One encouraging thing, however, is that we
are in fact using the linked stack stuff, and the capriccio scheduler code with
only MINOR modifications, and everything seems to be working properly. A test
application called c3po_test.c has been placed under tests/c3po/ and is based
on a modified version of pthread_test.c.
As it pertains to the Make system revamp, all user libraries are now self
contained in that they include a top level Makefile instead of a Makefrag
dependent on the ros build environment. In GNUmakefile, these libraries are
built with a recusrive make, rather than including a Makefrag and invoking them
that way. This change required a small change to the cross compiler Makefile,
but should NOT require a rebuild as it was just modified to be aware of the
reorganization; no actual header files were modified.
I also separated the pthread commands out of libparlib, so they are only now
contained in libpthread and not both. If you build an app that relies on the
pthread library you now need to icnlude both -lpthread and -lparlib in order to
use them. This change was necessary now that we are introducing the
libc3po library that implements the pthread functions differently. To use
c3po, simply include -lc3po and -lparlib together instead of -lpthread.
While making these changes, I also revamped the Make system as it relates to
building tests. By default, all of the test files in the tests/ directory are
compiled together with -lpthread and -lparlib. Take a look at the changes to
see how I added a c3po subfolder that allows you to compile other tests with
different Makefile flags. This process can be emulated to include other
subfolders taht group test files together that require any combiantion of
flags, or settings.
There is also a new install-tests Make target that will put all of the binaries
made during a 'make test' into the bin directory of the first entry in
INITRAMFS_PATHS.
Barret Rhoden [Tue, 22 Feb 2011 00:09:31 +0000 (16:09 -0800)]
Syscalls take event_queues for completion (XCC)
If the syscall has an ev_q, the kernel will try and signal/send an
event. tests/syscall.c has examples of how userspace can do it (rawly),
for both a polling ev_q as well as for an IPI driven one (which requires
_M mode).
Use SYS_block whenever you want to test a syscall that will block, but
don't use more than one of them at a time or in conjunction with any
blocking disk reads (for now).
Rebuild your cross compiler.
Barret Rhoden [Tue, 22 Feb 2011 00:03:32 +0000 (16:03 -0800)]
Fixes bug with current in send_event()
Should have been initialized to current/cur_proc.
Barret Rhoden [Tue, 22 Feb 2011 00:00:57 +0000 (16:00 -0800)]
Compiler memory barriers
When you want to prevent the compiler from messing with you.
Barret Rhoden [Sat, 19 Feb 2011 00:18:15 +0000 (16:18 -0800)]
Event helpers for userspace
Provides helpers for some common tasks, and uses them in the example
code. Note that you'll often want something more complicated than
enable_kevent() and get_event_type(), so you'll have to build that from
the other functions in event.c.
Barret Rhoden [Sat, 19 Feb 2011 00:17:02 +0000 (16:17 -0800)]
Adds bitmask functions to user/
They are mostly similar to the kernel's. If you find a bug in one of
them, it's probably in the other.
Barret Rhoden [Thu, 17 Feb 2011 20:23:51 +0000 (12:23 -0800)]
Revamped event interfaces (XCC)
Rebuild your XCC, or at least update the kernel headers.
The event_queue explains how a process would like to receive an event.
This replaces the old notification stuff. Notification now refers to
'active notification', aka IPIs to userspace. Check the documentation
for more info. Test apps show how to use it, for now.
Kevin Klues [Tue, 8 Feb 2011 04:55:07 +0000 (20:55 -0800)]
d_off is offset of *next* dirent, so no need to ++
Old way of doing it was skipping every other entry.
Barret Rhoden [Mon, 7 Feb 2011 08:23:41 +0000 (00:23 -0800)]
Doesn't build eth_audio when you set the Make var
Make sure to not use the eth_audio with sparc for now (set in
Makelocal).
Barret Rhoden [Wed, 2 Feb 2011 22:49:21 +0000 (14:49 -0800)]
Fixes pthread_attr functions
1) Memory leak with the pthread_attr. Caller handles the memory.
2) Need defaults, in case an attr isn't used for pthread create.
3) Some functions weren't returning.
4) Changed names and types to reflect 'detachstate' being the preference
for a new thread, while 'detached' is a bool regarding the actual state.
David Zhu [Fri, 28 Jan 2011 22:41:23 +0000 (14:41 -0800)]
Adding pthread support for stacksize options and detached threads.
Mainly done to support Redis compilation, but should be useful for others.
Barret Rhoden [Wed, 19 Jan 2011 20:47:53 +0000 (12:47 -0800)]
Reverses the default config for MP tables
MP Tables are now turned off by default. There's a minor bug with them
(more specifically with ioapic_init()), that is a low priority for now.
This way, people don't have to manually turn off the MP tables, which
are deprecated.
Kevin Klues [Wed, 19 Jan 2011 19:19:18 +0000 (11:19 -0800)]
Bug in return value or ros_arch_syscall() on SPARC
This bug caused the cross compiler to not build, and probably has
wider implications as well.
Barret Rhoden [Tue, 14 Dec 2010 19:41:22 +0000 (11:41 -0800)]
Eth audio device can notify processes
When you run eth_audio, call it from busybox. This will keep core 0 in
a loop of BB yielding, which will allow the NIC interrupts to be
received. When ROS polls in the monitor, it does not receive interrupts
until it reads a complete line.
Note that the kernel cannot handle a process that does not munmap the
VMR before exiting. I'm not willing to overhaul things for a ghetto
interface/device yet, so just be careful.
Barret Rhoden [Sat, 11 Dec 2010 00:37:35 +0000 (16:37 -0800)]
Closes files in proc_destroy()
If there is a syscall in progress on a file, it will stay open til the
end of the call (which is what the kref does). This change allows us to
have the files (or something they point to) reference the process.
Note, this still doesn't work for mmap() files. Eagle-eyed readers
should know why!
Barret Rhoden [Sat, 4 Dec 2010 00:52:52 +0000 (16:52 -0800)]
Support for the Ethernet-Audio device
Turn on support in your Makelocal. Right now, the kernel copies
whatever it gets into a file (in /dev) that a program (like
test/eth_audio.c) can mmap. When a packet comes in, the old buffer gets
sent back (including on the first time through).
Also adds some networking infrastructure (checksums, #defines), and the
eth_aud packets are intercepted (in a ghetto manner) from both the e1000
and the rl8186 NICs.
Barret Rhoden [Wed, 1 Dec 2010 19:22:54 +0000 (11:22 -0800)]
INET numbers and #defines
Slowly fighting our way out of the ghetto.
Barret Rhoden [Tue, 30 Nov 2010 22:24:44 +0000 (14:24 -0800)]
Fixes TLS (again) for static programs
Basically just broadens the fix from
def9c4d0666 to all TLS allocations,
not just vcore TLS. Still, somewhat curious why this isn't handled by
glibc. Perhaps we're using the wrong functions...
David Zhu [Tue, 23 Nov 2010 07:06:07 +0000 (23:06 -0800)]
Errno must not be touched before TCB is initialized.
Now making sbrk ignore errno in libc.
The alternative is to replicate the logic of sbrk for this particular
call of sbrk, which is even uglier.
Also added some documentation on errno, probably need more docs on TLS.
Barret Rhoden [Tue, 23 Nov 2010 23:26:26 +0000 (15:26 -0800)]
Quick hack to fix e1000
You need to have CONFIG_E1000_MMIO_HACK and pick a machine (like
CONFIG_E1000_ON_S142) so that it will detect a MAC - even if that's not
your machine! Some serious ghettoness is lying in wait for whoever
tries to make this work.
Barret Rhoden [Mon, 22 Nov 2010 22:41:00 +0000 (14:41 -0800)]
PCI: vendor/device/class identification
You can adjust the verbosity of the PCI output during bootup with the
Makelocal variable.
Barret Rhoden [Sun, 21 Nov 2010 22:03:18 +0000 (14:03 -0800)]
PCI cleanup
Shame on Paul, there was some really ghetto shit in there. The IOAPIC
stuff might still work, though it'll need sorted a bit when we get the
ACPI stuff working.
Also required a rewrite of how the NICs config themselves. Note, you
probably shouldn't have device drivers accessing PCI config space...
Barret Rhoden [Fri, 19 Nov 2010 23:42:01 +0000 (15:42 -0800)]
x86: pcpu init called before idling
Technically, something could have gotten messed up in the future, since
we access pcpui before finalizing the smp_boot process.
Barret Rhoden [Fri, 19 Nov 2010 20:21:14 +0000 (12:21 -0800)]
Removed set_current_proc()
It was just confusing (what with __set_proc_current(), which actually
did something). Also finally moved those macros to smp.h.
Barret Rhoden [Fri, 19 Nov 2010 20:06:18 +0000 (12:06 -0800)]
More careful with cur_tf in syscalls
Once we check for it, we need to make sure we use it before we block
(not that proc_alloc() or the resource request stuff block (yet)).
Barret Rhoden [Fri, 19 Nov 2010 19:56:38 +0000 (11:56 -0800)]
Adds a Makelocal option for resetting the stack
This is so that cycles involving smp_idle() never grow without bound.
It's not much of a big deal anyway, since whenever you pop to user
space, it would reset.
If you enable this option, you won't be able to backtrace beyond
smp_idle().
Barret Rhoden [Fri, 19 Nov 2010 19:33:11 +0000 (11:33 -0800)]
Optimize local routine kernel messages
Minor thing: there's no need to send an IPI that will just get ignored.
Barret Rhoden [Fri, 19 Nov 2010 18:16:54 +0000 (10:16 -0800)]
Syscall return paths cleaned up
The first syscall will return naturally via proc_restartcore() (which
does nothing if the core was already restarted and there is no
current_tf).
This also disables batching for now (not that anyone uses it, or the
asynchrony for that matter). In the future, we can use kmsgs
(carefully) for batched syscalls, being careful of the *tf passed around
in the kmsg functions...
Barret Rhoden [Fri, 19 Nov 2010 15:42:28 +0000 (07:42 -0800)]
proc_restartcore() only used for current_tf, etc
It has been like this for a while, with the exception of proc_run()'s _S
case. With the usage of cur_tf as a ptr, this works out well. This is
also the place to intercept the "returning twice" problem.
Barret Rhoden [Fri, 19 Nov 2010 02:30:02 +0000 (18:30 -0800)]
Copies out current_tf to pcpui
This is in response to a pretty bad bug/design issue. The documentation
has a lot about it and about what to expect in future patches. The
TODOs and checks in kthread.c will go away in a couple patches.
Ultimately, we want to avoid copying the TF multiple times, but that's
asm for another day. Recommend writing the location of actual_tf at the
top of the stacktop (avoid computing it, simplify the code, etc).
Note: this compiles on sparc, and might actually work! Hard to tell,
with that glibc-ish bug floating around.
Barret Rhoden [Fri, 12 Nov 2010 22:46:47 +0000 (14:46 -0800)]
Split pcpui->syscalls into a current and next
Instead of using pcpui->syscalls for both who to run next as well as
which call is currently being serviced.
Now it's more clear that a kthread is running a syscall (or none if ==
0), and we now can use signal_current_sc() after a block point (which
could happen (sys_exec()), though it is rare).
And since there is a cur_sysc active during each syscall, we can use
that struct for errno, instead of the errno_loc (which was originally
used for accessing inside an arch-dependent TF, back when we used a
register for errno).
Barret Rhoden [Fri, 12 Nov 2010 22:01:52 +0000 (14:01 -0800)]
Kthreads stop zeroing the current_tf
Should have been done a few patches ago. The kthreads were still saving
the current_tf, preventing us from really popping out to userspace
(though we were still smp_idling and running other processes - just not
the one that 'blocked').
Barret Rhoden [Fri, 12 Nov 2010 06:22:10 +0000 (22:22 -0800)]
Fixes mmap() to use all six args (XCC)
Rebuild your cross compiler.
sys_mmap() doesn't have to do the ghetto 6-arg hack, now that the kernel
can take real 6-arg syscalls.
Barret Rhoden [Fri, 12 Nov 2010 05:56:43 +0000 (21:56 -0800)]
Syscalls now can take six arguments (XCC)
Rebuild your cross compiler.
This also cleans up argument naming. Specifically, we 0-index the
syscall arguments, like good little C programmers.
If someone feels productive, they can make variants (or macro magic) to
cut down on the number of arguments getting passed around for syscalls
that we know only need a few args (in userspace).
Barret Rhoden [Fri, 12 Nov 2010 04:22:25 +0000 (20:22 -0800)]
x86: cleans up syscalls, fixes pop_ros_tf() (XCC)
Rebuild your cross compiler.
Since we do async syscalls, pop_ros_tf() needed fixed for the cases
where it calls sys_self_notify() from within the asm.
Side note: I probably wouldn't have noticed this for a while had I not
been cleaning out the errno and extra registers from
__ros_arch_syscall(), which arguably wasn't a big deal. Turns out it
was worth the time after all.
Barret Rhoden [Fri, 12 Nov 2010 00:37:45 +0000 (16:37 -0800)]
Removes some struct proc* refcnting
We only do it when calling out of syscall.c into something that might
not return and wants a reference it can decref (other than current).
We can just get rid of this completely, making proc_yield() take a
current for a ref, and core_request handling itself. The only reason we
don't yet is that core_request() could be called remotely (current isn't
loaded), so for now we'll keep having it expect an 'edible' reference.
Barret Rhoden [Thu, 11 Nov 2010 02:32:44 +0000 (18:32 -0800)]
All local system calls are asynchronous (XCC)
Rebuild your cross compiler.
For now, userspace just submits a call and then spins on the response
(synchronous in userspace, but async in the kernel). When the kernel
blocks, it first attempts to start/run more syscalls, then restarts the
current_tf (which gets the process back to where it trapped into the
kernel). The kernel will return how many syscalls it started, (similar
to Xen's interface), so if you batch calls, you need to make sure they
all started.
Regardless of whether the call blocked or not, the kernel will return
via smp_idle(). A blocked call will simply post its results and
smp_idle(), just like when it didn't block. Current_tf only has meaning
the "first time", when the process first trapped in. After a kthread
unblocks, current_tf has already restarted, so it no longer has meaning
(and should be 0'd). Things get a bit tricky with some syscalls that
don't return (like yield, resource_req, exec, etc). Fork is also a bit
tricky.
I can see why people like synchronous calls backed by a single kernel
task - but this is quite awesome when it works right.