Add source file, line debug (stabs)
Stable scheduling/task switching.

'Work flush commit': major scheduling overhaul, which has cascading
effects throughout other subsystems. The amount of accumulated work
makes it hard to find bug-introducing changes.

There are some minor bugs (mostly screen printing) when task switching
is used, however, it is stable and warrants a commit.

schedule.s:
	major overhaul.

	The job (the legacy tasks scheduled by the IRQ's such as the kb
	and net) handling code is disabled as yet, due to instability.
	The jobs are treated as tasks, and this code is table.

	Cleaned up the code to a large extent.

	Split off mutex.s (also containing semaphore code).

	Add a mutex, (besides the task_queue semaphore), for the scheduler,
	so that it won't be interrupted. Semaphores are dwords, shared
	variables, whereas a mutex is one bit wide.

	Major improvement in debug code and flags. Removed most of
	the debug code to macros to keep the methods readable.

	add scheduler_init, which registers an entry in the task_queue
	for the current 'thread'; instead of having the 'current_task'
	area holding a copy, a simple index points to the running task.

	Add environment variable 'sched.debug': 0 = no output,
	1 = ticker tape/graph, 2 = show task name,
	3 = show 'top'-like output (cumulative). It uses (and inspired)
	the environment variable handler callback.
	The 'top' command simply sets this variable to 3, and waits for
	escape/enter to reset it. Every time the scheduler is run, it updates
	the screen (depending on the setting of the varaible). The frequency
	of this can be controlled by a compile-time setting.

	rename 'schedule' to 'schedule_isr', and add 'schedule_near'
	and 'schedule_far', which translate the stack to suit the expectation
	of schedule_isr.

	The new schedule method's form is basically:

		push all registers
		set kernel context (ds, es)
		mutex lock nolock=9f

		curtask_idx = (curtask_idx + 1) % nr_tasks

		lss	esp, [eax + task_stack]

		mutex unlock
	9:	pop all registers
		iret

	The schedule_isr_TEST is basically the same but it deals with
	running jobs also, which copies the job context (registers)
	onto the stack of the current task. It is relatively stable,
	Mwhen the debug level is high, due to the virtual machine exits
	to update the screen. There's a minor bug and I do see the benefit
	in having a difference between tasks and jobs, for now.

	A major difference between this commit and the previous
	is that the concept of 'continuations' there, would allow to postpone
	the current 'thread', without knowing anything about it, and
	without any initialisation having been done. In essence this
	is still so, besides having to call the scheduler_init method
	before calling schedule_task.

	Added a 'task_done' (and 'job_done', pretty similar besides
	the latter having the current and parent indices on the stack),
	which' address is injected onto the task (job) stack so that it
	can return. The call_task (which executes a job) method is gone,
	as the current task would execute the job automatically since it
	is present on it's stack. When the job completes, the job_done
	simply removes itself from the task_queue, and updates a flag
	in the parent indicating that the job is done, and then returns
	to the task (or scheduler). In this way, jobs can be stacked
	in the task stack, preventing the task from executing until
	it's jobs are done. Particularly jobs that handle I/O on which
	the task is waiting can be efficiently scheduled in those tasks.

	remove task_switch_debug_task as the clock_task demonstrates the
	task switching nicely.

	add task_is_queued check so as to not schedule jobs/tasks that
	are already scheduled (by comparing the eip).

	reworked task_queue_get, though this is only used when jobs
	are enabled. It does not lock, as now it returns a pointer
	to the task which is used afterwards.

	rework schedule_task: don't duplicate tasks (except once,
	when specifically asked: meant to reschedule the current task,
	such as network, when there are more packets to handle).

	registered tasks re-use the allocated stack (which is optionally
	zeroed). This stack is prepared with the task_done handler,
	aswell as containing the task context (all the registers).
	This removes the need of the scheduler to copy the registers
	onto the stack each time there is a task switch.

	Major improvements in task printing.

	Move cmd_top from shell.s to schedule.s.

	add cmd_kill.

.tcshrc:
	add vmware aliases, minor cleanup

mutex.s:
	split-off from schedule.s: contains macro's that are used throughout.
	define some mutexes for core components (scheduler, screen, net, tcp)

Makefile:
	register mutex.s

am79c971:
	set ds, es in isr

debug.s:
	allow printing label for DEBUGS

debugger.s:
	fix macro jump label (overlapped with elsewhere).
	TODO: some standard for macro label reservation, or .altmacro/LOCAL
	kludge.

	debug_printsymbol: only print 4 chars of relative offset to symbols.

	save/restore mutexes and task_queue_sem on debugger entry/exit.

	lock all mutexes and the scheduler except for the screen mutex.

	since debugger is called from the exception interrupt handler,
	a stack is printed. The up/down arrow keys allow to scroll the
	stack whenever it is fully on screen.

	add 's' to print schedule (same as shell 'ps' command).

	start implementing 'mode': allow scrolling for different areas on
	screen, such as the stack, the process list (which may update
	which registers are printed, etc). For now it doesn't do anything.

	update 'p' (printregisters) to print the exception registers,
	not the current registers.

hwdebug.s:
	minor cosmetic fixes, aswell as a dr7 flag fix.

idt.s:
	update IRQ proxy scheduler target labels (_isr, _near).

	exception handler: set es; print exception number; extract
	print registers method; call debugger on some other
	exceptions aswell;
	extract print stack method: update print stack to allow proper
	scrolling (i.e. eip/cs/eflags not hardcoded), and dont print symbols
	for cs/eflags; calculate the screen offset at which the stack
	is printed, taking into account scrolling, so that the debugger
	can scroll the stack.

kernel.s:
	register mutex.s; call scheduler_init (abstract semaphore knowledge).

keyboard.s:
	add KB_POLL, a 'peek ? remove : nop' to prevent the keyboard job
	from waiting for keystrokes.

net.s:
	improve cmd_netstat output.

	add a net_rx_queue (disabled by default), so that when the net task/job
	is running, and thus scheduling it again will fail, packets won't be
	dropped. Allowing rescheduling of the task for each packet floods
	the scheduler. The code is unstable and thus disabled with the
	NET_RX_QUEUE flag.

	Fix a bug in socket_open (label at wrong position).

print.s:
	macro updates.
	use mutex to access screen in PRINT_START/END, as otherwise
	task switching creates concurrency issues where colors and screenpos
	are overwritten. Note that not everywhere where screenpos is
	altered, mutexes are used. It is foreseen to have a different
	screen/console context for each task, but for now the placement
	of the mutex solves most concurrency issues introduced by
	the scheduler.

	update newline to clear the rest of the line using the background
	color of the last character. (I left the new code indented
	as it nicely aligned with the existing code, showing the
	interleaving of two purposes).

	add printlnc.

	add [screen_scroll_lines], to keep track of how many lines are scrolled
	THis can be used by retrieving the value, do some printing,
	and calculating the difference, to see where a screen position has
	moved. Used in the debugger/idt to calculate the location where
	the stack is printed.

shell.s:
	reset [screen_pos] to actual position before newline, otherwise
	the newline will clear the entire line.

	update shell environment variables: add a 'handler' field,
	which gets called each time the variable is changed (TODO: call
	it on unset). This feature is used in the scheduler, so it can
	keep track of whether or not to print the debug output (the 'top'
	like output), without having to look up the value of the
	environment variable on each IRQ (which uses an array iteration,
	string compare, and atoi). Instead, this is now only done when
	the variable value actually changes.
	THis allows also for form-checked environment variables, where
	invalid values could be rejected, or events triggered as soon
	as the variable is changed.

	cmd_netdump: do not call nic_zeroconf - it duplicates the routing
	table, and nic configuration is done properly now.

	updated cmd_fork and clock_task, using a two-state 'wait',
	which yields nice output in 'top' which uses the symbol table to
	print the current address of a task. Run 'fork' a few times
	to get some timers on screen, and run 'set sched.debug = 3' or
	run 'top' to see.