Commit Graph

25 Commits

Author SHA1 Message Date
Travis Geiselbrecht
e4d65228b5 [mp] restructure the sequence of how cpus are brought up
- Move a bit of the shared logic of secondary bootstrapping into a new
  function, lk_secondary_cpu_entry_early() which sets the current cpu
  pointer before calling the first half of the secondary LK_INIT
  routines.
- Create the per cpu idle threads on the main cpu instead of the
  secondary as they come up.
- Tweak all of the SMP capable architectures to use this new path.
- Move the top level mp routines into a separate file top/mp.c
- A bit more correctly ifdef out more SMP code.
2025-10-12 19:47:33 -07:00
Travis Geiselbrecht
cc9c3a053c [arch][mmu] clean up page size definitions in each arch's defines.h
No real functional change except how the smaller ARCH_DEFAULT_PAGE_SIZE
is now computed and set in defines.h instead of rules.mk for arch/arm to
be consistent with the other arch that has a large/small build (riscv).
2025-08-31 19:16:58 -07:00
Peter Collingbourne
894a580b5f [top] use incomplete array declarations for constructor symbols
Clang will omit the initial comparison in this while loop on the
assumption that two different variables will not have the same address,
which will lead to a crash if the kernel has no constructors.

It will, however, retain the comparison for incomplete arrays
because they may have zero size (and therefore may alias with another
variable). Therefore, change the declarations of the start/end symbols
for the constructor list to incomplete arrays.
2022-04-19 18:29:02 -07:00
Travis Geiselbrecht
a895bcece5 [kernel][warnings] fix a few -Wmissing-declarations warnings in the kernel 2021-10-21 23:14:27 -07:00
Travis Geiselbrecht
445283fd8c [lib][unittest] slight tidying of the unittest library
Added unittest lib to the test virtual project. Currently nothing uses
it.
2020-05-10 19:50:08 -07:00
Travis Geiselbrecht
df32504748 [kernel] test run sorting some includes
No functional change.
2019-07-13 17:21:00 -07:00
Travis Geiselbrecht
cba9e47987 [license] replace the longer full MIT license with a shorter one
Used scripts/replacelic. Everything seems to build fine.
2019-07-05 17:22:23 -07:00
Travis Geiselbrecht
d8fa82cb91 [formatting] run everything through codestyle
Almost nothing changes here except moving braces to the same line as the
function declaration. Everything else is largely whitespace changes and
a few dangling files with tab indents.

See scripts/codestyle
2019-06-19 21:02:24 -07:00
Travis Geiselbrecht
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
Travis Geiselbrecht
2eb32a4369 [style] mass reformat all the non external code to 4 space indents
Ran everything through scripts/codestyle.space, which uses astyle
to generally follow K&R style.

Biggest non whitespace change is pulling brackets down on function
declarations, which I'm pretty ambivalent about, but astyle insists
on taking a stance
2016-02-14 12:24:01 -08:00
Brian Swetland
1de5270d6e [kernel][smp] reduce impact of SMP code on UP builds
Hopefully to nothing...
- remove current/pinned cpu tracking in thread struct
- macroize access to current/pinned cpu tracking
- empty-inline/remove vestigial mp_* bits in UP builds
2016-01-17 18:46:51 -08:00
Travis Geiselbrecht
a79328fe97 [main] move the printf for heap after the pre-heap init hooks are run 2015-11-02 11:55:30 -08:00
Travis Geiselbrecht
e53bc45b5b [top] add missing license and reformat top/ module 2015-10-22 21:58:59 -07:00
Travis Geiselbrecht
fab92f3179 [lib][heap] have novm initialize itself, rename novm 'heap' to 'arena' to be less confusing 2015-10-15 18:15:45 -07:00
Travis Geiselbrecht
3bbc7ac101 WIP patch from erik 2015-10-15 15:30:49 -07:00
Will Lee
141e4ffaa5 [kernel] call static constructors after heap init
Avoids badness when a constructor needs to malloc() something, etc.
2015-07-07 15:56:45 -07:00
Travis Geiselbrecht
89e69bbd50 [top] change the welcome message if compiled with SMP enabled 2015-03-31 15:30:52 -07:00
Travis Geiselbrecht
f0fad1590b [init][smp] have secondary init run in arch code up to threading, and complete in secondary thread
-move the per-cpu initialization of the gic and cortex-a9 timer into an init hook.
  This removes the hard coded call in arm/arch.c
-make sure the timer initialization happens in the pre-threading callback, in case
  a secondary init hook needs the timer.
2015-03-27 14:14:12 -07:00
Arve Hjønnevåg
2ff3f126e2 [init] Make lk_init_level re-entrant
Change api to pass in a range of levels to call, instead of just the
last level.
Allows secondary init hooks to run in parallel on multiple cpus.

Change-Id: I7447547818a35d475631b3e7fa8315ff7f80ba4f
2015-03-18 20:43:13 -07:00
Arve Hjønnevåg
fd51c054b6 [kernel] Add secondary cpu init and entry point
Call lk_init_secondary_cpus on the main cpu to create bootstrap
threads for secondary cpus. Call lk_secondary_cpu_entry on secondary
cpus to boot them. It is not safe to call into the heap on secondary
cpus before getting to the bootstrap thread.

Change-Id: Id9ee72a96cdc894dc8089527bde8468f36a25eac
2015-03-11 19:57:17 -07:00
Arve Hjønnevåg
794d304599 [kernel][thread] Allow pinning threads to a specific cpu
The existing runqueues are scanned on resched until a thread that is
not pinned to another cpu is found.

Per-pu runqueues can be added later to avoid this scan.

Change-Id: Idd7dbddb4b79ef38a0ccd0c42b53f8867020e6cd

Conflicts:
	kernel/thread.c
2015-03-10 17:49:32 -07:00
Travis Geiselbrecht
8fb2c54304 [kernel] remove critical_section, move everything to spinlocks 2015-03-10 16:43:54 -07:00
Travis Geiselbrecht
ee9d2927ad [arm] add ability to pass and generically read up to 4 boot args from whoever loaded lk
-Extend arch_chain_load() to pass 4 args
2014-11-21 15:50:18 -08:00
Travis Geiselbrecht
a40b543556 [init] new init hook system
Allows code anywhere in the system to define an init hook which is
called at the run level specified.
Hooks are guaranteed to be called in order of init level. Within an init
level the order of the hooks is not guaranteed.
2013-08-03 15:35:16 -07:00
Travis Geiselbrecht
702d168927 [kernel] move the top level kmain() out of kernel/ into top/
The kernel shouldn't really own most of the bringup of all
the modules. Generally speaking the kernel can and should be treated
like any other module in the system.
2013-06-20 20:40:11 -07:00