Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
wiki1179: Kernel_source_guide (Version 88)

Quick Guide to the Kernel Source#


The kernel and the process manager make up the operating system. They share the same address space. The kernel is non-threaded, and forces mutual-exclusion so that there is only ever one instance of it running, (even on SMP (small lie, see the SMP section)). The kernel "is entered" when anyone invokes a kernel call (or system call). The kernel runs in a privileged supervisor (or "ring0" in some architectures) state. The kernel only very rarely inhibits interrupts (and has an extensive and clever way of dancing out of the way of them). The most notable invoker of the kernel is the process manager or "proc".

Where is the Kernel Source?#

/services/system/ker

How do I checkout and build the source?#

Actually, one always builds the kernel and the process manager together:

Where are the good bits?#

Functional AreaRelated Files
kernel public headersservices/system/public/sys
kernel internal headersservices/system/public/kernel
kermacros.h
kerproto.h
externs.h
struct defs for thread, process,
channel , interrupt ...
services/system/public/kernel/objects.h
low-level kernel data structuresnano_object.c
nano_lookup.c
kerext_query.c
nano_query.c
nano_vector.c
nano_alloc.c
debug support,
reading kernel internal data
kprintf.c
cpu_debug.c
kerext_debug.c
nano_debug.c
nano_kerdebug.c
deb_rec.c
floating pointnano_fp_emu.c
kernel api,
linkage
kernel call entry, locking and exit(4)
kerext_*
ker_*
kerargs.h
ker_call_table.c
ker_ring0.c
nano_specret.c
kerext_misc.c
nano_misc.c
asmoff.c
module_list.S
kernel entrypoint, init, config_main.c
init_nto.c
kgetopt.c
kmain.c
idle.c
init_objects.c
nano_conf.c
instrumentation, tracingkertrace.h
ker_trace.c
kerext_trace.c
nano_trace.c
interrupts, events, signalsker_interrupt.c
nano_interrupt.c
nano_clock.c
nano_smp_interrupt.c
nano_event.c
ker_signal.c
nano_signal.c
magicarm/kernel.S
mips/kernel.S
ppc/kernel.s
sh/kernel.s
x86/kernel.S
messaging,
send, receive, reply
nano_message.c
nano_xfer.c
nano_xfer_msg.c
nano_xfer_check.c
nano_xfer_cpy.c
ker_channel.c
ker_connect.c
ker_fastmsg.c
ker_message.c
messaging, asynchronousnano_asyncmsg.c
messaging, networkedker_net.c
messaging, pulsesnano_pulse.c
nano_xfer_pulse.c
MMU stuff
cache control, address spaces, page faulting
kerext_cache.c
walk_asinfo.c
kerext_bind.c
kerext_page.c
kerext_stack.c
memory manager stubs(2)smm_*
nano_memphys.c
embedded memory mananger(1)emm_init_mem.c
emm_mmap.c
emm_munmap.c
emm_pmem_add.c
emm_vaddr_to_memobj.c
nano_memphys.c
Minidriver support(6)mdriver.c
mutex support
thread synchronization
ker_sync.c
nano_sync.c
power management stubkerext_cpumode.c
process creation/destructionkerext_process.c
security (uname,pw), rlimitskerext_cred.c
nano_cred.c
kerext_limits.c
schedulerker_sched.c
nano_sched.c
nano_clock.c
kexterns.c
Adaptive Partitioning Schedulersee the source guide for aps
shutdown, rebootkerext_reboot.c
shutdown_nto.c
Symmetric Multiprocessing support(3)nano_smp_interrupt.c
smp_flush_tlb.c
smp_get_cpunum.c
smp_send_ipi.c
services/system/smpswitch.h
ker_nop.c
system page
firmware/bios interface, key kernel globals
ker_sys.c
nano_syspage.c
timers, clocknano_clock.c
ker_timer.c
nano_timer.c
ker_clock.c
thread creation/deletionnano_thread.c
ker_thread.c

Footnotes

(1) The embedded memory manager is only used when the OS is built as a stand-alone executive, i.e. without the process manager. QNX never ships it that way. So the emm_* files are generally not used. The nominal memory manager is in the process manager.

(2) The memory manager implementation is located in proc. It overrides these stubs in the kernel.

(3) Actually there is SMP support scattered throughout the kernel. Look for #if defined(VARIANT_smp). Kernel modules, which aren't allowed to have compile variants, will test NUM_PROCESSORS or runmask instead.

(4) How we enter and exit the kernel is described here.

(5) There is no footnote 5.

(6) Fixme: wth are minidrivers

Where the heck is the implementation of KernelCall()? #

You won't find it by grepping. To find the implementation of a kernel call spelled like CamelCaseKernelCall, look for a function ker_camel_case_kernel_call. For example the SchedCtl() kernel call is implemented by ker_sched_ctl(). How the invocation seqence works is described here.

What are the file naming conventions?#

filename patternMeans
ker/ker_*kernel entry file. Checks parameters and decides when to lock the kernel
ker/nano_*low-level implementation, in-kernel state and in ring-0 or supervisor mode
ker/arm/*
ker/mips/*
ker/ppc*
ker/sh/*
ker/x86/*
processor specific code for ARM, PowerPC, Hitach SH-4, and Intel x86 processor architectures



Active Tab Versions Inactive Tab - left sideAssociations Inactive Tab - left sideAttachments Inactive Tab - left sideBack LinksInactive Tab - right side  
    Version From To Version Comment Created By
    Version 88 Attilla Danko(deleted)  -  09/05/2007
    Version 87 straightened out minidriver source file list Brian Stecher  -  08/31/2007
    Version 86 typos Brian Stecher  -  08/31/2007
    Version 85 fix some typos Douglas Bailey  -  08/31/2007
    Version 84 Attilla Danko(deleted)  -  08/31/2007
    Version 83 Attilla Danko(deleted)  -  08/30/2007
    Version 82 Attilla Danko(deleted)  -  08/30/2007
    Version 81 Attilla Danko(deleted)  -  08/30/2007
    Version 80 Attilla Danko(deleted)  -  08/30/2007
    Version 79 Attilla Danko(deleted)  -  08/30/2007
    Version 78 Attilla Danko(deleted)  -  08/30/2007
    Version 77 Attilla Danko(deleted)  -  08/30/2007
    Version 76 Attilla Danko(deleted)  -  08/30/2007
    Version 75 Attilla Danko(deleted)  -  08/30/2007
    Version 74 Attilla Danko(deleted)  -  08/30/2007
    Version 73 Attilla Danko(deleted)  -  08/30/2007
    Version 72 Attilla Danko(deleted)  -  08/30/2007
    Version 71 Attilla Danko(deleted)  -  08/30/2007
    Version 70 Attilla Danko(deleted)  -  08/30/2007
    Version 69 Attilla Danko(deleted)  -  08/30/2007
    Version 68 Attilla Danko(deleted)  -  08/30/2007
    Version 67 Attilla Danko(deleted)  -  08/30/2007
    Version 66 Attilla Danko(deleted)  -  08/30/2007
    Version 65 Attilla Danko(deleted)  -  08/30/2007
    Version 64 Attilla Danko(deleted)  -  08/30/2007
    Version 63 Attilla Danko(deleted)  -  08/30/2007
    Version 62 Attilla Danko(deleted)  -  08/30/2007
    Version 61 Attilla Danko(deleted)  -  08/30/2007
    Version 60 Attilla Danko(deleted)  -  08/30/2007
    Version 59 Attilla Danko(deleted)  -  08/30/2007
    Version 58 Attilla Danko(deleted)  -  08/30/2007
    Version 57 Attilla Danko(deleted)  -  08/30/2007
    Version 56 Attilla Danko(deleted)  -  08/30/2007
    Version 55 Attilla Danko(deleted)  -  08/30/2007
    Version 54 Attilla Danko(deleted)  -  08/30/2007
    Version 53 Attilla Danko(deleted)  -  08/30/2007
    Version 52 Attilla Danko(deleted)  -  08/30/2007
    Version 51 Attilla Danko(deleted)  -  08/30/2007
    Version 50 Attilla Danko(deleted)  -  08/30/2007
    Version 49 Attilla Danko(deleted)  -  08/30/2007
    Version 48 Attilla Danko(deleted)  -  08/30/2007
    Version 47 Attilla Danko(deleted)  -  08/30/2007
    Version 46 Attilla Danko(deleted)  -  08/30/2007
    Version 45 Attilla Danko(deleted)  -  08/30/2007
    Version 44 Attilla Danko(deleted)  -  08/30/2007
    Version 43 Attilla Danko(deleted)  -  08/30/2007
    Version 42 Attilla Danko(deleted)  -  08/30/2007
    Version 41 Attilla Danko(deleted)  -  08/30/2007
    Version 40 Attilla Danko(deleted)  -  08/30/2007
    Version 39 Attilla Danko(deleted)  -  08/30/2007
    Version 38 Attilla Danko(deleted)  -  08/30/2007
    Version 37 Attilla Danko(deleted)  -  08/30/2007
    Version 36 Attilla Danko(deleted)  -  08/30/2007
    Version 35 Attilla Danko(deleted)  -  08/30/2007
    Version 34 Attilla Danko(deleted)  -  08/30/2007
    Version 33 Attilla Danko(deleted)  -  08/30/2007
    Version 32 Attilla Danko(deleted)  -  08/30/2007
    Version 31 Attilla Danko(deleted)  -  08/29/2007
    Version 30 Attilla Danko(deleted)  -  08/29/2007
    Version 29 Attilla Danko(deleted)  -  08/29/2007
    Version 28 Attilla Danko(deleted)  -  08/29/2007
    Version 27 Attilla Danko(deleted)  -  08/29/2007
    Version 26 Attilla Danko(deleted)  -  08/29/2007
    Version 25 Attilla Danko(deleted)  -  08/29/2007
    Version 24 Attilla Danko(deleted)  -  08/28/2007
    Version 23 Attilla Danko(deleted)  -  08/28/2007
    Version 22 Attilla Danko(deleted)  -  08/28/2007
    Version 21 Attilla Danko(deleted)  -  08/27/2007
    Version 20 Attilla Danko(deleted)  -  08/24/2007
    Version 19 Attilla Danko(deleted)  -  08/24/2007
    Version 18 Attilla Danko(deleted)  -  08/24/2007
    Version 17 Attilla Danko(deleted)  -  08/24/2007
    Version 16 Attilla Danko(deleted)  -  08/24/2007
    Version 15 Attilla Danko(deleted)  -  08/24/2007
    Version 14 Attilla Danko(deleted)  -  08/24/2007
    Version 13 Attilla Danko(deleted)  -  08/24/2007
    Version 12 Attilla Danko(deleted)  -  08/24/2007
    Version 11 Attilla Danko(deleted)  -  08/24/2007
    Version 10 Attilla Danko(deleted)  -  08/24/2007
    Version 9 Attilla Danko(deleted)  -  08/24/2007
    Version 8 Attilla Danko(deleted)  -  08/24/2007
    Version 7 Attilla Danko(deleted)  -  08/24/2007
    Version 6 Attilla Danko(deleted)  -  08/24/2007
    Version 5 Attilla Danko(deleted)  -  08/24/2007
    Version 4 Attilla Danko(deleted)  -  08/24/2007
    Version 3 Attilla Danko(deleted)  -  08/24/2007
    Version 2 Attilla Danko(deleted)  -  08/24/2007
    Version 1 Attilla Danko(deleted)  -  08/24/2007