ASFLAGS = -Wa,--gstabs+ $(INCLUDES) $(DEFINES)
# Core kernel.
-THREADS_SRC = start.S # Must be linked first.
-THREADS_SRC += init.c # Main program.
+THREADS_SRC = init.c # Main program.
THREADS_SRC += thread.c # Thread management core.
THREADS_SRC += switch.S # Thread switch routine.
THREADS_SRC += interrupt.c # Interrupt core.
THREADS_SRC += paging.c # Page tables.
THREADS_SRC += palloc.c # Page allocator.
THREADS_SRC += malloc.c # Subpage allocator.
+THREADS_SRC += start.S # Startup code.
# Device driver code.
DEVICES_SRC = timer.c # Timer device.
_start = .;
/* Kernel starts with code, followed by read-only data and writable data. */
- .text : { *(.text) } = 0x9090
+ .text : { *(.start) *(.text) } = 0x9090
.rodata : { *(.rodata) *(.rodata.*) }
.data : { *(.data) }
-# This module gets linked first, so that the kernel entry point
-# is the very beginning of its binary image. All we need to do is
-# jump to the real entry point.
+#### The loader needs to have some way to know the kernel's entry
+#### point, that is, the address to which it should jump to start the
+#### kernel. We handle this by writing the linker script kernel.lds.S
+#### so that this module appears at the very beginning of the kernel
+#### image, and then using that as the entry point.
.globl start
+.section .start
+
start: call main
# If main returns, spin.