Initial Commit.

Change-Id: I4911a929337f30b1c4f3d77a97b4156f29e22fc3
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Add initial skeleton.

The _very_ minimal code to get x86 and arm to boot to kernel_main.

Build with:
  make ARCH=[x86|arm] CROSS_COMPILE=<compiler_prefix>

Defaults to ARCH := x86, CROSS_COMPILE = '' (nothing).

Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Change-Id: Ifb8070b80eea458b60ac2efd458c1c5b40cb64d2
Add boot targets to arch makefiles.

Add the target 'boot' and 'gdb-boot' to the x86 and arm makefiles. These
target will build a kernel, and boot using qemu.

On x86 this requires a simple grub wrapper/floppy disk image, while arm
can just pass the elf to qemu via '-kernel'.

gdb-boot will tell qemu to wait for a debugger to attach before
executing any code.

Change-Id: I2454a54696f2e8532911c13a40af5c960390514d
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Add IO interface and stdint types.

Expect architectures to provide an "arch/types.h" header file that
provides stdint types, as well as an ioaddr_t type that defines the size
of an io address.

timix/io.h defines the functions that kernel code will use to interface
with a peripheral. This header also provides a read/write memory barrier
interface (rmb/wmb). This is not used on x86 since peripherals are
accessed over in/out instructions, however ARM memory-mapped peripherals
will require these barriers for correct behavior.

Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Change-Id: I3624d0586ab4d73740fee1e24479cf85f24e3fa4
Pull in more modules.

Add new headers:
  * atomic.h   - Atomic/xchg ops.
  * stddef.h   - NULL
  * compiler.h - MUST_CHECK
  * variable_queue.h
  * assert.h   - assert macro
  * panic.h    - panic()

Pull in mutex from timix, slightly modified (since timix mutexes used
TCB pointers as the "lock" value.

Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Change-Id: I2fc1e630c4c4775803ff6af0a332070e69c9ca41
x86: add multiboot code.

The bootloader passes a pointer to a "Multiboot Info Structure" in
register ebx. Pass this structure to the c_entry function in x86 and add
structure definitions in x86/include/multiboot.h

Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Change-Id: I29dce45410923f2cef541d443e5b5492e08c5b06
arm: Add atag code.

The bootloader will pass system information to the kernel using ATAG
structures, add header and support code to pass the atag pointer to the
kernel.

Change-Id: I80475d2c8c656f519fde08a201d2dbe142233684
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Add ARM Coprocessor accessor macros and vector

Arm coprocessor registers are accessed via mrc/mcr instructions such as:

  mrc p15, 0, r0, c0, c0, 0

Where:
        mrc -> Move to arm register from coprocessor
        mcr -> Move to coprocessor from arm register
        r0  -> Source/Destination arm register

        p15/0/c0/c0/0 -> Coprocessor register address.

CP registers are addressed via the form cp/op1/crn/crm/op2.

The fact that the cp register address cannot be in a register makes
putting this into C-friendly form difficult, so the solution is to use a
CPP macro that injects some inline assembler to emit the instruction.

Architected CP registers have macro names defined to make source code
more readable, ex, the following are the same:
    cp_read(myvar, 15, 0, 0, 0, 0);
    cp_read(myvar, MIDR);
Where 'myvar' is the C variable to write the value to (must be a valid
lval).

Change-Id: I601f546079f53f93b9f3af03cfd8e401699e8702
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Port in timix-libstring, stub out malloc.

Add support for standard string operations by including
<timix/string.h>. The string library has a dependancy on the heap
(malloc), so this has been stubbed out in kerenel/malloc.c (defined in
include/stdlib.h).

Change-Id: I787bad49335d6c11d3b2400480fdd7c25521b252
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Physical memory manager stub

Before we can think about setting up paging we need to track the
physical memory we have in the system. Typically the bootloader will
pass information about RAM/ROM locations to the kernel (via atags,
multiboot info struct, etc) that can be used to initialize this module
in architecture setup code.

Also move _all_ arch header files into arch/$ARCH/include/arch/ such
that there is no chance of a namespace clash. A select few of these
header files are suitable for being included by kernel code (such as
arch/types.h), however private headers are placed in the same directory.

Change-Id: I4c4b3156a4a2e02dfd4217452d70ef4360de5a45
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
arm: Add Image target

Building an arm kernel will now generate a raw Image file. When qemu is
booted with this binary it will correctly stuff atags into r2 during
boot.

Change-Id: I894e527cf14e6f7b84f42a2d43f8ece947ef6932
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
nios2: Initial arch tree

Nios2 is a soft microprocessor that runs on Altera FPGA devices. This
commit provides baseline startup code that compiles against the current
timix kernel code.

Change-Id: I1843c96a5e585e9abf48b8827e6bf573410c32f1
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Makfile: Use linux-style O=<objdir> variable

Linux supports out-of-tree build using a variable called 'O'
Ex:
  make O=kobj

Support this syntax, however default to the build/ directory.

Change-Id: I1e3178862dfeedcb8d59cf7cb4302ca11b7cb342
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
arm: Enable MMU in head.S

Generate a basic page table in head.S such that we can branch into
position dependant code.

This implementation does not work if physical/virtual addresses do not
have the same 1MB offset.

Change-Id: I8b29a106725f460dee9c24938b8777e74af3e422
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
nios2: Add srec target.

In order to utilize the Altera board flashing tools, we need to get the
kernel into the 'srec' format. This target depends on tools in the
altera toolchain.

Some parameters in this target (base, end, entry) will be board
dependant and are currently filled with place-holder values (meaning the
target is non-functional at this time).

Change-Id: I0b360786622970808a623f452c1eba8e38316075
Signed-off-by: Tim Detwiler <timdetwiler@gmail.com>
Misc changes.

Change-Id: Ic81c51c200e9ac18aec660715cda05a78f5b740d