Initialise repository

This is the first commit of my work on the nos kernel. This project is
purely an entertainment/education exercise, and is based very heavily on
the James Molloy's OS development tutorials, available here:

    http://www.jamesmolloy.co.uk/tutorial_html/

At the moment, the kernel is in a very bare state, offering paging,
limited ISR, IRQ and PIT support, and direct access to the VGA
framebuffer through a weak TTY abstraction.

Over time I will be adding more modules and functionality, with the
emphasis being on simple and understandable designs instead of features,
compatibility or even stability (this project is purely a technical
exercise and I have no intention of it being used for anything other
than vaguely probing the field of operating system design and
implementation).
timer: Make timer_callback static
Add ISR callback -Wunused-parameter pragmas

An ISR handler function accepts a struct registers_s as its parameter,
as defined in nos/isr.h. However, there is nothing to suggest that all
ISR handlers require access to this registers structure. For example,
the page fault ISR handler obtains a faulting address through register
CR2, not from the registers parameter.

This patch prevents compiler warnings from ISR handlers that do not use
the registers parameter, by adding GCC diagnostic pragmas to ignore
-Wunused-parameter warnings.
Add TAGS file generator

The patch adds a script 'scripts/tags.sh' that generates an
emacs-compatible TAGS file using etags. We have added a corresponding
Makefile rule and added the TAGS file to git's ignored files list.
Ensure correct phony targets in Makefile
scripts/simulate: Add documentation header
Add ordered-array data structure and algorithms

This patch adds a simple generic struct ordered-array_s structure, along
with corresponding functions to create, destroy, insert item, lookup
item and remove item.

The insertion algorithm simply iterates along the array, so array insertion is
an O(n^2) operation in worst-case-scenario conditions. A binary search tree or
heap-ordering algorith would be faster for inserting new elements; this
improvement can be implemented transparently at a later date, without breaking
the API.

Note that the ordered-array destructor is currently not-implemented.
kstream: Move k_* macros into kstream.h

The k_message, k_warn and k_critical macro functions have been moved
into the kstream header file, from their old location in the util.h
header. This is because a file may include util.h without first
including kstream.h, causing an implicit function declaration of
kstream_message().

It is not possible for util.h to include kstream.h as this causes some
circular cross-dependency problems, as kstream.h depends on some
definitions from util.h.
kstream: Remove unused variables
scripts/tags: Improve source directory selection

This changes the usage of the tags scripts from:

     tags.sh <srcdir>

to:

     tags.sh <directory ...>

The benefit of this is that rather than specifying the top of the source
tree and searching for all C sources within it (including, perhaps in
unwanted locations, such as .git/ or .docs/), you can now run the script
with more precise granularity, such as $ ./scripts/tag.sh path/dir1/
path/dir2/.

The make TAGS target has been update accordingly. Additionally, an unnecessary
variable has been removed.
Top level Makefile improvements

This patch combines three sets of improvements to the top level Makefile
operation:

  1) Replace kernel make target with per-dir targets
  2) Makefile 'run' target does not result in compilation
  3) Make clean target is made more generic

The top level Makefile kernel target has been replaced with an array of
targets, one for each of the members of the array $(SOURCEDIRS). This
allow for directory specific building. New source directories should be added to
this array.

This nos target dependency has been removed from the run target, so that
executing 'make run' does not update the kernel image. From now on, you must
call compilation specifically, using 'make all run'. This decouples the kernel
sources and build state from the operation of the emulator.
paging: Various source refactors and improvements

This patch combines a number of paging source improvements, including:

    1) Use more symbolic constants in memory algorithms.
    2) Fix missing funciton prototype.

The patch defines a set of macro constants in the nos/paging.h header file, such
as PAGE_SIZE and ALIGNMENT_MASK. This helps reduce the quantity of 'magic
numbers' in our code, making it easier to read and maintain.
Add 'todo' script

This patch adds a file scripts/todo.sh which searches for and displays all
'TODO:' and 'FIXME:' tags in a list of directories, passed as command line
arguments. Additionally, a 'make todo' target has been added which executes this
script with a list of all of the source directories. Addresses issue #12.

  #12: Add a 'todo' viewer script

  There should be a script to search through all of the source files and display
  a list of all mentions of 'TODO:' and 'FIXME:' tags, complete with file name
  and line number, for example:

    $ ./scripts/todo
    nos/main.c:109    FIXME   Undefined reference error.
    nos/tty/ports.h   TODO    Refactor enum declaration.
memory: Make destination types void pointers

The idea here is that the memory functions should be type agnostic, so
void pointers is the most appropriate way of expressing this.
Implement contiguous memory allocation and deallocation

This patch supplements the existing placement address algorithm for
memory allocation with a dynamic memory allocation and deallocation
system. Some of the implemented features include:

    1) The heap is defined as a data structure which can be created at
       run time, allowing for multiple different heaps.

    2) Heaps can expand and contract at run-time as necessary.

    3) Heaps contain an index of blocks, sorted by size.

    4) Block allocation occurs on a first fit basis.

    5) A block is book-ended by a header and a footer.

    6) A block can be either active or not (a hole).

    7) Freeing a block changes its status to a hole. On doing so, the
       heap will scan the blocks immediately to the left and right to
       see if they are holes as well. If so, the holes will be
       merged. This prevents fragmentation over time.

Based off of James Molloy's kernel development tutorial, available here:
    http://www.jamesmolloy.co.uk/tutorial_html/7.-The%20Heap.html

Addresses issue #5: Add a memory manager
ordered-array: Implement destructor
ordered-array: Use kcreate over kmalloc
Tidy up stray files

'TODO' tracking is now implemented using GitHub's issue tracker.
Merge memory.[ch] into string.[ch]

The standard C reference contains memset() and memcpy() function
prototypes in <string.h>, so in order to conform closer to existing
standards, the memory.[ch] sources have been merged into string.

Addresses issue #2.

    #2: memory.c and memory.h are unnecessary

    The functions memory_copy() and memory_set() should be moved into
    the nos/util.[ch] source pair, with their current parent memory.[ch]
    files being removed. Having those two memory utility functions in a
    seperate file does not provide any useful or meaning code
    modularisation, and the files are ambiguously named (what kind of
    memory? What can I expect to gain from adding #include
    <nos/memory.h> to my source file?  Heap functions? malloc?).
string: memory_set and memory_copy return pointers