Commit Graph

165 Commits

Author SHA1 Message Date
Travis Geiselbrecht
d836b07279 [console] add a panic time alternate version of the thread list
This works if the thread lock is held at panic time to keep it from
recursing.
2021-10-07 00:00:22 -07:00
Travis Geiselbrecht
476b750102 [kernel][ports] double the size of the port message on 64bit hosts
It seems the initial port packet size was sized to hold two words for a
32bit machine. In the 64bit case double the size from 8 bytes to 16.
2021-06-27 00:30:58 -07:00
Travis Geiselbrecht
89f9805277 [lib][console] move the state of the console into an object
This will allow in the future multiple instances of it to be active at
at a time. Place the current console in a new TLS slot per thread so
threads created as a side effect of console commands can properly run
commands.
2021-05-29 00:52:47 -07:00
Travis Geiselbrecht
a3713e8b39 [arch][riscv] add simple support for context switching user space aspaces
Pretty inefficient but probably works well enough.
2021-04-09 02:00:57 -07:00
Travis Geiselbrecht
d28e8dc3e0 [kernel][mutex] tweak a mutex routine to take a const 2021-04-02 19:28:58 -07:00
Travis Geiselbrecht
7102838b49 [arch] have each arch define ARCH_HAS_MMU
This lets some code decide whether or not there's any mmu
present to use. Also kernel VM will complain if it isn't set
as an extra safety.
2021-03-30 02:48:59 -07:00
Travis Geiselbrecht
7033559d38 [inc][c++] add some additional __BEGIN_CDECL/__END_CDECLS to various global headers
Just a few that were missed, and picked up with some additional C++ code.
2021-01-20 01:02:48 -08:00
Travis Geiselbrecht
ed7e3571c2 [kernel][thread] gcc 10.2 warning fix
In a previous patch, on architectures where SMP is disabled,
thread_pinned_cpu() will always return a negative number. GCC 10.2
is somewhat more aggressive about negative shift values so it wasn't
detecting that the second path of an if statement is never taken.

Solution is to cache the pinned cpu value and use it for both the
test and the operation.
2020-10-09 01:25:03 -07:00
vannapurve
961ef679cf [kernel][thread] Wake up only needed cores
This change ensures that during thread scheduling
only needed cores are woken up as per the thread's
CPU affinity rather than all cores. This would avoid
un-necessary wakup for other cores from lower power
states without having to execute anything.

Signed-off-by: vannapurve <vannapurve@google.com>
2020-10-09 01:10:35 -07:00
Travis Geiselbrecht
4edb93adde [lib][console] rename some console command types to be prefixed with console_
Some of the structures, notably 'cmd', in the lib console stuff are a
little too generically named and have collided with some other code
so prefix the names a bit more cleanly with console_

The change is largely mechanical, and folks with out of tree code can
easily switch by renaming:
cmd -> console_cmd
cmd_args -> console_cmd_args
cmd_block -> console_cmd_block
console_cmd -> console_cmd_func

Apologies if this breaks you but it should be pretty easy to fix.
2020-07-25 15:59:58 -07:00
Travis Geiselbrecht
f371fa246b [arch] move the atomic ops into a separate header
Now you need to include arch/atomic.h to get to the atomic routines.
This simplifies a recusion issue in the way arch/ops.h included
arch_ops. Also just generally makes things cleaner.
2020-05-16 15:05:34 -07:00
Travis Geiselbrecht
c57b661c93 [kernel][thread] change the way get_current_thread is inlined
Previously, was relying on a regular definition with the arch_ops.h code
overriding it with a static inline. This has been annoying for some
years since it forces the declarations to be in order. Change it to
simple declare an inline wrapper around an arch_ routine that does
whatever it needs to do.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
7cc7d79e74 [pmm] add a few more convenience routines
Add a routine to just allocate a single page and a fast page for
allocating a single kvaddr page.
2020-05-10 16:51:58 -07:00
Travis Geiselbrecht
bff17f7e99 [platform][riscv] add code to read the size of memory from the FDT
Tweak the novm allocator to let us more easily add a variable sized
arena at boot.

Also added code to trap secondary cpus and reenable the use of WFI
instruction.
2019-11-02 18:13:02 -07:00
Travis Geiselbrecht
fdc08a8446 [arch][riscv] port to riscv64
Very little needed to port except to conditionalize some assembly in the
context switch and exception code. Mostly needed to move build system
stuff around and add a new project.
2019-11-02 17:21:13 -07:00
Travis Geiselbrecht
df32504748 [kernel] test run sorting some includes
No functional change.
2019-07-13 17:21:00 -07:00
Travis Geiselbrecht
6cb02526b7 [include][console] split lib/console.h into two
TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
2019-07-13 16:56:33 -07:00
Travis Geiselbrecht
3aecdda231 [includes] replace header guards with #pragma once 2019-07-13 15:46:16 -07:00
Travis Geiselbrecht
85a50ea3f4 [kernel][license] try out using a smaller version of the license header
Replace the body of the MIT license with a reference to the LICENSE file
and a URL with the MIT license. Replaces 20 something lines with 3.

No functional change.
2019-06-19 23:28:14 -07:00
Travis Geiselbrecht
3699e45942 [include][lib] move most of the dangling top level include/lib/.h files into their lib
Only remaining one is console.h which is a little funny and will need to
be dealt with separately.
2019-06-19 22:44:15 -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
4f2d4841d8 [kernel][includes] move the kernel includes into the kernel directory
No functional change, just moved some include files.
2019-06-19 19:46:11 -07:00
Travis Geiselbrecht
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
leliang.zhang
dfc1159abb [novm] fix the bug which cause memory leak in novm 2019-06-19 18:38:05 -07:00
Travis Geiselbrecht
f98cef7992 [warnings] fix warnings across the entire code base
Fix or squelch all warnings in all code covered by buildall.
2018-12-16 17:33:22 -08:00
Travis Geiselbrecht
8cf28bbdcf [arch][riscv] Initial port to a riscv32 sifive target
Currently targets qemu's sifive_e machine, which is a split flash/ram
machine, much like the Sifive HiFive1. Untested as of yet on a real
HiFive1.

Basic support including interrupts and architectural timers in place.
2018-12-16 16:44:23 -08:00
Alex Elzenaar
86717f4a3b Minor documentation comment change to timer implementation. 2018-01-22 23:35:32 -08:00
Will Drewry
cf3b7a15df kernel/port.c: make make_buf() safe
make_buf() is a static function with two callers who pass in one of
two constants. The parameters allowed for any uint count to be
supplied and the arithmetic during memory allocation was unchecked

This change updates make_buf() to reflect its usage, which is
safe, while eliminating any future uses from accidentally becoming
unsafe.
2017-12-22 13:52:43 -08:00
James Zhong
089dce3a7d [kernel][vm][pmm] Bug fix in pmm
Bug fix of PAGE_ADDRESS_FROM_ARENA in pmm of vm module

Signed-off-by: James Zhong <sha8312@gmail.com>
2017-04-21 17:14:45 -07:00
circl0
6782ea9af6 [kernel] fix get top thread error if NUM_PRIORITIES < 32 2016-09-30 10:39:58 -07:00
John Grossman
0c782aa381 [spelling] signalling --> signaling (#162)
Switch from the UK spelling of signalling (also, signalled and
signaller) to the American spelling.
2016-09-07 15:29:56 -07:00
Erik Gilling
c01adc6e0d [kernel] Add debug tracking of stack memory usage.
On thread creation, initializes the stack to a known value.  When
thread state is dumped, this value is uses to intuit max stack
usage.
2016-06-03 12:25:01 -07:00
Erik Corry
6d0122b98e [heap] Add API used by Dartino to get arena list 2016-03-23 21:22:39 +01:00
Travis Geiselbrecht
2a51111387 [kernel] add more controlled way to switch vmm address spaces 2016-02-23 21:07:22 -08:00
Gurjant Kalsi
42e76b1fc7 [ports] Add an API to dynamically add/remove ports from a port group. 2016-02-23 14:23:25 -08:00
Travis Geiselbrecht
14a4c60172 [kernel][vm] get rid of external declaration of address_to_page 2016-02-16 15:25:31 -08:00
Travis Geiselbrecht
9a5cd5c529 [kernel][vm] add support for multiple user address spaces
Generically add support for more than one user address space,
attach to a thread, and context switch as thread swaps happen.

Add support for ARM and ARM64, and stub out support for x86 platforms.
2016-02-16 15:24:25 -08:00
Travis Geiselbrecht
a4ca0a6e00 [vmm] move most users of arch_mmu_query directly to vaddr_to_paddr() 2016-02-14 12:45:53 -08:00
Travis Geiselbrecht
d569c090ea [vim] remove vim expandtab comments on most of the files 2016-02-14 12:32:07 -08: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
Gurjant Kalsi
52f4728c44 [magic][constants] Convert all of LK's multichar character kernel magic constants to hex. 2016-02-09 15:02:05 -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
ec69e5f881 [kernel] properly set the target debug led when inside non-idle thread context 2015-12-14 15:20:25 -08:00
Travis Geiselbrecht
4ab14424bd [cppcheck] clean up a few suggestions from cppcheck 2015-11-24 15:08:38 -08:00
Carlos Pizano
6cdc5cd1da [kernel][port] Fix memory leak on port_open() 2015-11-23 12:38:40 -08:00
Carlos Pizano
614eaf166a [kernel][ports] Add basic ports functionality
Missing mostly more tests, specifically group tests.

BUG=none
R=travisg@google.com

Review URL: https://codereview.chromium.org/1437453002 .
2015-11-20 14:43:27 -08:00
Travis Geiselbrecht
7c1b8a0b66 [kernel] add a #define to set to enable tracing 2015-11-06 15:51:29 -08:00
Travis Geiselbrecht
814ca4e8a5 [kernel] add code to check some overrun padding placed on the bottom of each threads' stack
-Should impact context switch performance a bit
-Only enabled at LK_DEBUGLEVEL > 1
2015-11-04 18:35:20 -08:00
Travis Geiselbrecht
2d1e01cdd4 [kernel] remove THREAD_CHECKS which was always just the equivalent of DEBUG_ASSERT 2015-11-04 18:35:20 -08:00
Travis Geiselbrecht
c8c923ecbf [kernel][novm] change the novm alloc routine to take a bitmap instead of arena index 2015-10-23 09:48:28 -07:00