if NCPUS > 1 stuff is not being considered so far.

i386/i386at/boothdr.S: _start

i386/i386at/boothdr.S: boot_entry

i386/i386at/model_dep.c: c_boot_entry

i386/i386at/boothdr.S: discover_x86_cpu_type

i386/i386at/model_dep.c: i386at_init

i386/i386/pic.c: picinit

i386/i386at/model_dep.c: mem_size_init

i386/intel/pmap.c: pmap_bootstrap

i386/i386/gdt.c: gdt_init

i386/i386/idt.c: idt_init

i386/i386at/int_init.c: int_init

i386/i386/ldt.c: ldt_init

i386/i386/ktss.c: ktss_init

kern/startup.c: setup_main

kern/debug.c: panic_init

kern/printf.c: printf_init

kern/sched_prim.c: sched_init

kern/sched_prim.c: wait_queue_init

kern/processor.c: pset_sys_bootstrap

kern/ast.c: ast_init

vm/vm_init.c: vm_mem_bootstrap

vm/vm_resident.c: vm_page_bootstrap

vm/vm_resident.c: pmap_startup

kern/zalloc.c: zone_bootstrap

vm/vm_object.c: vm_object_bootstrap

vm/vm_external.c: vm_external_module_initialize

vm/vm_map.c: vm_map_init

vm/vm_kern.c: kmem_init

i386/intel/pmap.c: pmap_init

kern/zalloc.c: zone_init

kern/kalloc.c: kalloc_init

vm/vm_fault.c: vm_fault_init

vm/vm_resident.c: vm_page_module_init

vm/memory_object.c: memory_manager_default_init

ipc/ipc_init.c: ipc_bootstrap

ipc/ipc_table.c: ipc_table_init

ipc/ipc_notify.c: ipc_notify_init

ipc/ipc_hash.c: ipc_hash_init

ipc/ipc_marequest.c: ipc_marequest_init

vm/vm_init.c: vm_mem_init

vm/vm_object.c: vm_object_init

ipc/ipc_init.c: ipc_init

kern/ipc_host.c: ipc_host_init

kern/ipc_host.c: ipc_pset_init

kern/ipc_host.c: ipc_pset_enable

kern/ipc_host.c: ipc_processor_init

i386/intel/pmap.h: PMAP_ACTIVATE_KERNEL

kern/timer.c: init_timers

kern/mach_clock.c: init_timeout

kern/xpr.c: xprbootstrap

kern/time_stamp.c: timestamp_init

kern/mach_clock.c: mapable\ time\ init

i386/i386at/model_dep.c: machine_init

device/cons.c: cninit

i386/i386/fpu.c: init_fpu

linux/dev/init/main.c: linux_init

linux/dev/arch/i386/kernel/irq.c: init_IRQ

linux/dev/arch/i386/kernel/irq.c: reserve_mach_irqs

linux/dev/kernel/sched.c: linux_sched_init

linux/dev/init/main.c: calibrate_delay

linux/dev/glue/kmem.c: linux_kmem_init

linux/src/drivers/pci/pci.c: pci_init

linux/src/arch/i386/kernel/bios32.c: pcibios_init

linux/src/drivers/pci/pci.c: scan_bus

linux/src/arch/i386/kernel/bios32.c: pcibios_fixup

linux/dev/glue/net.c: linux_net_emulation_init

linux/dev/drivers/block/genhd.c: device_setup

linux/dev/glue/block.c: blk_dev_init

linux/src/drivers/block/ide.c: ide_init

linux/dev/drivers/block/floppy.c: floppy_init

linux/src/drivers/scsi/scsi.c: scsi_dev_init

linux/dev/net/core/dev.c: net_dev_init

linux/pcmcia-cs/glue/pcmcia.c: pcmcia_init

i386/i386at/autoconf.c: probeio

i386/i386at/model_dep.c: inittodr

i386/intel/pmap.c: pmap_unmap_page_zero

kern/task.c: task_init

kern/syscall_emulation.c: eml_init

kern/thread.c: thread_init

i386/i386/pcb.c: pcb_module_init

i386/i386/fpu.c: fpu_module_init

i386/i386/iopb.c: iopb_init

kern/thread_swap.c: swapper_init

kern/sched_prim.c: recompute_priorities

kern/mach_factor.c: compute_mach_factor

kern/startup.c: start_kernel_threads

[...]

kern/startup.c: cpu_launch_first_thread

i386/i386at/model_dep.c: startrtclock

i386/i386/pit.c: clkstart

i386/intel/pmap.h: PMAP_ACTIVATE_KERNEL

i386/i386/pcb.c: load_context

[...]

kern/startup.c: start_kernel_threads

Threads get created.

kern/sched_prim.c: idle_thread

One for each CPU.

kern/thread.c: reaper_thread

kern/thread_swap.c: swapin_thread

kern/sched_prim.c: sched_thread

[...]

kern/bootstrap.c: bootstrap_create

The ?multiboot modules have been put somewhere into memory by GRUB. The boot scripts are parsed. The modules' ELF image's PT_LOAD sections are ``read'' (that is, vm_allocate and copyout) and turned into real tasks. The multiboot modules' memory regions can be deallocated then.

[...]

vm_pageout

Does not return.

IRC, freenode, #hurd, 2013-10-07

<cureOS> look, where should i dig or where from should i start from, if i
  have desire to know how the kernel was written from baremetal? Can it be
  ever done nowadays?
<youpi> cureOS: the boot entry of the kernel is i386/i386at/boothdr.S ,
  boot_entry
<youpi> that's what grub jumps to
<youpi> then that jumps to c_boot_entry
<youpi> and everything else is C
<cureOS> grub loads it somehow. how does it prepare cpu and memoty, cpu
  cache control if any... segments for stack..
<youpi> see the grub documentation
<youpi> basically it's all flat linear space
<cureOS> does kernel transform it after that?
<youpi> see the ldt/gdt initialization
<youpi> from i386at_init and children
<youpi> nothing much fancy, a kernel cs/ds, and user cs/ds
<braunr> and paging, naturally
<youpi> sure