Commit Graph

2310 Commits

Author SHA1 Message Date
Alexander von Gluck IV
196479ae96 headers/bcm283X: Don't depend on others to include board_config.h 2015-03-07 12:35:00 -06:00
Alexander von Gluck IV
427d40adb5 arm/targets: Add rpi2, rename raspberry_pi to rpi1
* The Raspberry pi 2 uses a new SoC which differs slightly
  from the Raspberry Pi 1.
* Someday these two board targets could go away when we get
  FDT support.
2015-03-07 12:31:12 -06:00
Alexander von Gluck IV
d05e5f1db6 bcm283X: Add new peripheral base for bcm2836
* BCM2836 == Raspberry Pi 2
2015-03-07 11:23:49 -06:00
Alexander von Gluck IV
523c77e052 arm: Rename BCM2835 SoC header to bcm283X.h
* Fix a few typos in hrev48873
2015-03-07 11:11:53 -06:00
Alexander von Gluck IV
f8e19d47fb arm: Rename BCM2708 to BCM2805
* To while there was some compatibility between
  BCM2708 and BCM2805, it makes the BCM2806 changes
  more confusing. We don't have any valueable BCM2708
  targets.
2015-03-07 11:03:01 -06:00
Alexander von Gluck IV
5906dbb4d4 platform/u-boot: Work towards using arm mailbox driver
* Reference bcm2708 framebuffer when it makes sense
* Add bcm2708 define to Raspberry Pi board_config.h
2015-03-06 07:47:32 -06:00
Adrien Destugues
ace74964f1 Remove khash from the sources.
Fixes #9552.
2015-01-13 15:48:58 +01:00
Adrien Destugues
9d053f5975 BOpenHashTable: document some subtleties
Mainly the interaction of resizing the table with iterators.
2015-01-13 15:48:57 +01:00
Adrien Destugues
3395fdcd6a gcc4 build fix.
* offsetof is not allowed on non-POD types so we need to use
offset_of_member (gcc2 accepts offsetof, and C++11 relaxed the
constraints on where it is allowed so it should work there too)
* we have offset_of_member as a workaround until we switch to C++11,
move it from khash (which is soon to be removed) to list.h which is the
other place where it is used (for this one single call in our whole
codebase)

Also fix a typo in vfs.cpp.
2015-01-12 19:04:33 +01:00
Adrien Destugues
6235b4967b More useless inclusions of khash.h 2015-01-12 18:23:45 +01:00
Adrien Destugues
955d5259d0 Rewrite sample HashTable description to use the typedefs
This makes the code more readable (as KeyType and ValueType are clearer
than int and Foo) and easier to copypaste and edit.
2015-01-09 18:09:11 +01:00
Jérôme Duval
d6aaebc757 x86: added two MSR definitions. 2014-12-23 19:14:52 +01:00
Michael Lotz
bf685cdf2e kernel: Fix missing reference release in CreateThreadEvent.
CreateThreadEvent::DoDPC() missed a reference release to balance the
acquired reference before queuing the DPC, resulting in the
CreateThreadEvent objects being leaked.

This also removes the destructor that tried to cancel the DPC. Since
the class is reference counted and only destroyed when the DPC has
run and released the last reference, this didn't make much sense.
2014-11-01 16:32:04 +01:00
Michael Lotz
6a80e6889a kernel: Fix missing reference to team/thread in signal events.
The signal to the team/thread is only actually sent in a deferred
procedure. To ensure that the team/thread stays valid between the DPC
being queued and it actually running, we need to acquire a reference.

Fixes #11390, where the DPC was run after the team was already
destroyed.
2014-10-31 16:16:37 +01:00
Ingo Weinhold
6bbd25f071 Make vfs_resize_fd_table() accessible in the kernel
Also update some types from int to uint32.
2014-10-29 21:07:02 +01:00
Ingo Weinhold
078a965f65 vm_soft_fault(): Avoid deadlock waiting for wired ranges
* VMArea::AddWaiterIfWired(): Replace the ignoreRange argument by a
flags argument and introduce (currently only) flag
IGNORE_WRITE_WIRED_RANGES. If specified, ranges wired for writing
are ignored. Ignoring just a single specified range doesn't cut it
in vm_soft_fault(), and there aren't any other users of that feature.
* vm_soft_fault(): When having to unmap a page of a lower cache, this
page cannot be wired for writing. So we can safely ignore all
writed-wired ranges, instead of just our own. We even have to do that
in case there's another thread that concurrently tries to write-wire
the same page, since otherwise we'd deadlock waiting for each other.
2014-10-29 12:37:25 +01:00
Ingo Weinhold
9da590f73e Add vm_page_free_etc()
It additionally gets a vm_page_reservation* argument. If not NULL, the
page count of the reservation is incremented for the freed page.
2014-10-29 02:36:08 +01:00
Michael Lotz
52d500e5b4 kernel: Workaround for double lock of spinlock in user timers.
The thread that is being [un]scheduled already has its time_lock locked
in {stop|continue}_cpu_timers(). When updating the TeamTimeUserTimer,
the team is asked for its cpu time. Team::CPUTime() then iterates the
threads of the team and locks the time_lock of the thread again.

This workaround passes a possibly locked thread through the relevant
functions so Team::CPUTime() can decide whether or not a thread it
iterates needs to be locked or not.

This works around #11032 and its duplicates #11314 and #11344.
2014-10-29 00:25:37 +01:00
Adrien Destugues
4ed39e6a62 disk device manager: check that partitions are unmounted before uninitializing.
when uninitializing a partition or a disk (removing the partition
table), check that all partitions from that table are unmounted, as they
are about to become invalid.

Fixes #8827.
2014-10-28 23:52:57 +01:00
Adrien Destugues
04dbe5b1c5 safemode.h: make it usable from C code. 2014-10-28 23:52:22 +01:00
Ingo Weinhold
fa80e7b28f x86 kernel args: Increase number of page tables 2014-10-27 10:57:28 +01:00
Michael Lotz
e9922e775f haiku_loader: Fix wrong size of gBootGDT on x86_64.
The BOOT_GDT_SEGMENT_COUNT was based on USER_DATA_SEGMENT on both
x86 and x86_64. However, on x86_64 the order of the segments is
different, leading to a too small gBootGDT array. Move the define to
the arch specific headers so they can be setup correctly in either case.
Also add a STATIC_ASSERT() to check that the descriptors fit into the
array.

Pointed out by CID 1210898.
2014-10-22 21:06:07 +02:00
Paweł Dziepak
ac97d35790 kernel/arch: remove leftover debug message
Polite fault handlers are nice, but we like the silent ones even more.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-25 21:57:32 +02:00
Paweł Dziepak
95e97463d2 kernel: add generic wrapper for accessing user memory
This patch adds user_access() which can be used to gracefully handle
page faults that may happen when accessing user memory. It is used
by arch_cpu_user{memcpy, memset, strlcpy}() to allow using optimized
functions from the standard library.

Currently only x64 uses this, but nothing really is arch specific here.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-14 22:39:07 +02:00
Paweł Dziepak
396b74228e kernel/x86_64: save fpu state at interrupts
The kernel is allowed to use fpu anywhere so we must make sure that
user state is not clobbered by saving fpu state at interrupt entry.
There is no need to do that in case of system calls since all fpu
data registers are caller saved.

We do not need, though, to save the whole fpu state at task swich
(again, thanks to calling convention). Only status and control
registers are preserved. This patch actually adds xmm0-15 register
to clobber list of task swich code, but the only reason of that is
to make sure that nothing bad happens inside the function that
executes that task swich. Inspection of the generated code shows
that no xmm registers are actually saved.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-14 19:16:52 +02:00
Paweł Dziepak
b41f281071 boot/x86_64: enable sse early
Enable SSE as a part of the "preparation of the environment to run any
C or C++ code" in the entry points of stage2 bootloader.

SSE2 is going to be used by memset() and memcpy().

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-14 19:16:52 +02:00
Paweł Dziepak
6156a508ad kernel/x86[_64]: remove get_optimized_functions from cpu modules
The possibility to specify custom memcpy and memset implementations
in cpu modules is currently unused and there is generally no point
in such feature.

There are only 2 x86 vendors that really matter and there isn't
very big difference in performance of the generic optmized versions
of these funcions across different models. Even if we wanted different
versions of memset and memcpy depending on the processor model or
features much better solution would be to use STT_GNU_IFUNC and save
one indirect call.

Long story short, we don't really benefit in any way from
get_optimized_functions and the feature it implements and it only adds
unnecessary complexity to the code.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-09-14 19:16:51 +02:00
Ithamar R. Adema
eea45d0a32 ARM: cleanup of bootloader memory mapping
* Removes default mapping of a portion of the RAM (will be done
  as needed)
* Passes on the page directory area to kernel, so on early vm init
  the kernel can use the area for pagetable allocation.
* Leaves it to the platform to pass in physical memory range(s). This
  will ultimately come from FDT.
* Fix long standing issue with allocation of the heap, potentially
  causing other part of the bootloader to overwrite the heap.
* Implements pagetable allocator in kernel for early vm mapping.

This fixes the first PANIC seen, we now just get the same one later
on when the VM is up... more to come...
2014-09-07 20:56:15 +02:00
Ithamar R. Adema
6048591e9d Revert "Added check to ensure KDL does not include frames beyond kernel entry in the backtrace. This prevents KDL from faulting when printing backtrace on ARM."
This reverts commit 3fbb24680c.

As I mentioned in #11131, this fix is not correct, and works around
the problem. The real reason was that arch_debug_call_with_fault_handler
was not working properly, so the fault handler went crazy.

With commit eb92810 that is fixed so this can be reverted.
2014-09-07 19:15:01 +02:00
PulkoMandy
83f5e2a258 Fix stack alignment for bootloader.
The ARM SP is pointing to the top item of the stack, not the first free
byte. This was confusing dprintf making it fail to print 64bit integers.
2014-09-02 17:01:27 +02:00
Arvind S Raj
3fbb24680c Added check to ensure KDL does not include frames beyond kernel entry in the backtrace. This prevents KDL from faulting when printing backtrace on ARM. 2014-09-02 13:39:57 +02:00
Paweł Dziepak
4b75a1e237 kernel/x86_64: implement x86_swap_pgdir in C++
No reason not to inline this function.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-08-25 23:07:29 +02:00
Paweł Dziepak
2e2c9bd3d0 os/support: implement atomic_*() using GCC builtin helpers
If GCC knows what these functions are actually doing the resulting
code can be optimized better what is especially noticeable in case of
invocations of atomic_{or,and}() that ignore the result. Obviously,
everything is inlined what also improves performance.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2014-08-25 23:05:07 +02:00
Adrien Destugues
4ad7d95bac Revert "Add sys/ucontext.h"
This reverts commit 6ddf93bfbe.

As pointed out by Ingo, those were moved to sugnal.h in the latest issue
(issue 7) of the POSIX spec. Sorry!
2014-08-09 20:18:05 +02:00
Adrien Destugues
6ddf93bfbe Add sys/ucontext.h
* Move ucontext_t and mcontext_t there as that's where POSIX says they
should be.
2014-08-09 18:37:43 +02:00
Arvind S Raj
82d287ddcb Reserve 8MB space for kernel before RAM_loader
...so that kernel does not overwrite the loader.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #11067.
2014-08-08 17:39:33 +02:00
François Revol
c8826605df Guard header for use by assembler code
Somehow it ends up being used by shell.S for the verdex bootstrap.
2014-07-23 13:27:23 +02:00
PulkoMandy
4a2260f21a Let the bootloader know about ARMv7.
When an ARMv7 CPU is detected, immediately turn on the FPU. This allows
us to use vsnprintf in the TRACE call in that function, as our libc is
compiled with floating point support and will trigger a fault if the FPU
is not available.

This lets the boot go further, and crash in mmu_init. Next steps:
* Find why mmu_init is crashing
* Setup some fault handlers, otherwise we call uboot ones, and they are
not very helpful. They will also probably not work once the mmu is
enabledvery helpful. They will also probably not work once the mmu is
enabledvery helpful. They will also probably not work once the mmu is
enabled...
2014-06-13 22:15:54 +02:00
Alexander von Gluck IV
cc67216333 kernel: Toggle not toogle; no functional change 2014-05-20 18:36:30 -05:00
Alexander von Gluck IV
a8f9011015 h2: Fix bluetooth driver build, missing PrivateKernelHeaders
* We likely should move all of this stuff to normal
  atomic test and set operations at some point.
2014-05-18 22:33:56 -05:00
Pawel Dziepak
76636769bd kernel/x86_64: inline x86_{read, write}_msr()
This patch makes it possible to inline rdmsr and wrmsr instruction. The
performance impact shouldn't be significant since they are used relatively
rarely and wrmsr is usually a serializing instruction, but there is no reason
not to do so.
2014-05-06 21:41:49 +02:00
Pawel Dziepak
88e8e24c84 kernel/x86_64: improve context switch implementation
The goal of this patch is to amortize the cost of context switch by making
the compiler aware that context switch clobbers all registers. Because all
register need to be saved anyway there is no additional cost of using
callee saved register in the function that does the context switch.
2014-05-06 21:15:55 +02:00
Pawel Dziepak
9db5b975f9 kernel/x86_64: rework of IDT handling code
Similarly to previous patch regarding GDT this is mostly a rewrite of
IDT handling code from C to C++. Thanks to constexpr IDT is now entirely
generated at compile-time.
2014-05-06 14:59:54 +02:00
Pawel Dziepak
cd59bf4349 kernel/x86_64: x86_64 gdt handling code overhaul
Virtually no functional change, just rewriting the code from
"C in *.cpp files" to C++. Use of constexpr may be advantageous but
that code is not performance critical anyway.
2014-05-06 14:59:53 +02:00
Oliver Tappe
94089b909d Revert 6f68e52 and fix the gcc2 build via template.
* Instead of forcing the hash-table to use a copy of the key,
  introduce and use TypeOperation template to avoid taking a
  reference of a reference type (which gcc2 doesn't allow).
2014-04-20 00:26:29 +02:00
Ingo Weinhold
5c0f8450ac Boot loader: Add support for choosing an old packages state
For potential boot volumes with older packages states the respective
item in the boot volume menu now has a sub menu for selecting a state.
The boot loader functionality for this feature is complete -- i.e. the
respective kernel is loaded and the name of the old state is added to
the kernel args -- but kernel packagefs and package daemon support is
still missing.
2014-04-18 23:31:39 +02:00
Ingo Weinhold
59ae1c816d Boot loader: Add get_stat(), directory_from()
* Add Node::Stat() and simplify Descriptor::Stat().
* Add get_stat() and directory_from().
2014-04-18 23:31:39 +02:00
Ingo Weinhold
2f019bd6ca boot loader: Implement subset of <dirent.h> API
* Add opendir(), closedir(), readdir(), rewinddir().
* Add open_directory(), similar to opendir(), but basing the path off a
  specified directory.
2014-04-18 23:31:39 +02:00
Pawel Dziepak
b167307526 kernel: Properly synchronize suspending new thread
After load_image() the child thread is suspended and the parent is
expected to resume it later. However, it is possible that the parent
attempts to resume its child after it has been notified that the image
had been loaded but before the child managed to suspend itself. In such
case the child would suspends itself after that wake up attempt and,
consequently will not be ever resumed.

To mitigate that problem flag Thread::going_to_suspend has been added
which helps synchronizing thread suspension and continuation in a similar
way that "traditional" thread blocking is performed. This means that
the child should behave in a following manner: set its going_to_suspend flag,
notify the parent (i.e. any thread that may want to resume it), acquire
its scheduler_lock and suspend itself if the going_to_suspend flag is set.
The parent should follow pattern: clear going_to_suspend flag of the thread
that is about to be resumed, acquire that thread scheduler_lock and enqueue
it in a run queue if it is suspended.

Thanks Oliver for reporting the bug and identifying what causes it.
2014-03-17 02:40:12 +01:00
Pawel Dziepak
d7e1e3e012 kernel/UserEvent: Make sure UserEvent object is valid during DPC
Most of the actual UserEvent work is done in DPC so that we don't have
to care about the limitations of the context in which UserEvent::Fire()
is invoked. This requires appropriate management of lifetime of UserEvent
instances to make sure that DoDPC() method is always called on a valid
object.
2014-03-17 02:40:12 +01:00
Alexander von Gluck IV
d035469704 ARM: Name beagleboneblk back to beagle
* Pulkomandy pointed out that all Beagle hardware is
  very similar so we could likely get away with a single
  ARM target board.
2014-02-26 15:33:40 -06:00
Alexander von Gluck IV
8cfbbff4df ARM: Fix dmb opcode 2 on ARMv6
* Typo, also fix tabs
* Sorry for the spam, this should be correct now
2014-02-26 13:22:18 -06:00
Alexander von Gluck IV
b6994f96c0 ARM: Break apart ARMv5 and older dsb/dmb
* Add isb just because.
* pdziepak pointed out that ARMv5 and before
  had different barrier support.
* pdziepak also mentioned that dsb was too strong
  for __sync_synchronize
2014-02-26 13:17:21 -06:00
Alexander von Gluck IV
a21611e439 ARM: Add ARMv6 or older __sync_synchronize built-in
* On ARMv6 or older, we do a simulated dsb.
* Move __sync_synchronize into thread.c in libroot
  and use the new arch_atomic.h dsb/dmb defines.
* Gets arm @bootstrap-raw to end of bootstrap.
2014-02-26 12:51:51 -06:00
Alexander von Gluck IV
6d3363214f ARM: Simplify board specification
* Don't assume verdex as it isn't clear this was
  occurring.
* Make an educated guess on HAIKU_BOOT_PLATFORM
  based on provided board (but still allow it to
  be overridden)
* Error out if user doesn't populate
  HAIKU_BOOT_PLATFORM or enters an unknown board
  name.
* You need to add "-sHAIKU_BOOT_BOARD=xxx" to
  your jam to build for the proper ARM device.
* Rename beagle to beagleboneblk as per the
  documentation.
2014-02-26 00:27:18 -06:00
Ithamar R. Adema
8f4db360bc arm/atomic: round of atomic function changes
* change vint{32,64} to int{32,64} in:
  * kernel implementation
  * syscall definitions
  * libroot prototypes
* update syscall functions with new atomic prototypes.
2014-02-15 11:46:12 +01:00
Ithamar R. Adema
5cef6be21f arm/atomic: fixup arch_atomic.h
* Remove _inline functions, since we're not using inlines
* Use compiler barrier instead of GCC builtin
2014-02-15 11:46:11 +01:00
Alexander von Gluck IV
35171b073d arm: Miscellaneous build fixes
* Use atomic_get_and_set for return value
* Atomics are no longer volatile
* Add missing arch_cpu_pause stub
* Move arch_cpu_idle to arch_cpu header to match
  other architectures
2014-02-12 23:37:15 -06:00
Alexander von Gluck IV
8018e8fa91 arm: Rework hrev46863 to use gcc built-in
* Those calls were indeed v7+ only, and our toolchain
  is v6.
2014-02-12 23:34:08 -06:00
Alexander von Gluck IV
92b2e03d0d arm: Add initial memory barrier functions
* These likely need reviewed by someone better
  at arm assembly. (#10537)
2014-02-12 23:11:11 -06:00
Pawel Dziepak
a96e17ba9d kernel: Adjust load tracking interval 2014-02-06 03:23:28 +01:00
Pawel Dziepak
527da4ca8a x86[_64]: Separate bootloader and kernel GDT and IDT logic
From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.
2014-01-28 00:44:02 +01:00
Adrien Destugues
50df6e9824 Add missing pipe character in KDL keymap.
For non-US keyboards, the extra 102th/105th key is used to reach \. But,
we also need it to report | when shifted (this is the key left to
"enter").

This affects only USB keyboards. Thanks to gordoncjp for reporting!
2014-01-27 10:57:11 +01:00
Pawel Dziepak
82bcd89b92 kernel: Add CPUSet::{Clear, Set}BitAtomic() functions 2014-01-24 13:59:58 +01:00
Pawel Dziepak
03451e4cc1 kernel: Fix deadlock with thread sending signal to itself
UserEvent can be fired from scheduler_reschedule() i.e. while holding current
thread scheduler_lock. If the current thread goes sleep and during reschedule
one of its timers sends a signel to it, then scheduler_enqueue_in_run_queue()
attempts to acquire again its scheduler_lock resulting in a deadlock.

There was also a minor issue with both scheduler_reschedule() and
scheduler_enqueue_in_run_queue() acquiring current CPU scheduler mode lock.
2014-01-24 13:59:58 +01:00
Stephan Aßmus
14652ec4bb trim support code: The passed in MemoryDeleter was never used.
When a buffer has to be allocated, I guess the intention was to
assign the MemoryDeleter to it, so that it would later be freed.
CID 1130505
2014-01-22 22:23:31 +01:00
Pawel Dziepak
e1720098c6 kernel: No need for arch specific ifdefs in arch/atomic.h 2014-01-20 04:09:17 +01:00
Alexander von Gluck IV
c9e66bfc9b kernel: Add missing smp memory barrier calls. Set max cpu to 1
* Set max cpu to 1 for PPC until atomic functions are finished
* We have atomic functions inline in the kernel and assembly
  code in libroot post-scheduler merge... isn't that a lot of
  duplication?
2014-01-19 19:33:21 -06:00
Alexander von Gluck IV
fb8026e82b kernel: Add missing PPC CPU functions for idle / pause 2014-01-19 14:38:01 -06:00
Alexander von Gluck IV
524bea3553 kernel: fix missing cpu cache defines non-x86
* Regression introduced due to scheduler change
* Other other non-x86, non-ppc, and non-arm platforms
  need evalulated for this metric
2014-01-19 14:27:09 -06:00
Alexander von Gluck IV
6647d2c95a kernel: fix missing SMP_MAX_CPUS on non-x86
* Regression introduced due to scheduler change
* Drop MAX_BOOT_CPUS as it is no longer used
2014-01-19 14:09:51 -06:00
Ingo Weinhold
8540ec2446 Save previous session's debug syslog during boot
Add boot loader debug menu option "Save syslog from previous session
during boot". If enabled (defaults to true), the previous session's
debug syslog data is copy to a separate buffer and passed to the
kernel, which writes it back to the file /var/log/previous_syslog.
As long as Haiku still boots, this should now be the most convenient way
to retrieve the output from a kernel crash.
2014-01-19 10:46:00 +01:00
Pawel Dziepak
d0f2d8282f Merge branch 'scheduler'
Conflicts:
	build/jam/packages/Haiku
	headers/os/kernel/OS.h
	headers/os/opengl/GLRenderer.h
	headers/private/shared/cpu_type.h
	src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.h
	src/bin/sysinfo.cpp
	src/bin/top.c
	src/system/kernel/arch/x86/arch_system_info.cpp
	src/system/kernel/port.cpp
2014-01-17 04:06:15 +01:00
Pawel Dziepak
a2634874ed scheduler: Estimate the load thread is able to produce
Previous implementation based on the actual load of each core and share
each thread has in that load turned up to be very problematic when
balancing load on very heavily loaded systems (i.e. more threads
consuming all available CPU time than there is logical CPUs).

The new approach is to estimate how much load would a thread produce
if it had all CPU time only for itself. Summing such load estimations
of each thread assigned to a given core we get a rank that contains
much more information than just simple actual core load.
2014-01-09 03:50:54 +01:00
Pawel Dziepak
4ca31ac964 kernel: Fix ABA problem in try_acquire_read_spinlock() 2014-01-06 21:03:42 +01:00
Pawel Dziepak
8cf8e53774 kernel/x86: Inline atomic functions and memory barriers 2014-01-06 09:08:53 +01:00
Pawel Dziepak
cb66faef24 scheduler: Work around GCC2 limitations in function inlining
GCC2 won't inline a function if it is used before its definition.
2014-01-06 01:22:53 +01:00
Pawel Dziepak
81e04d7b97 kernel: Remove cpu_info::load
This field forces kernel to track each CPU load all the time. It is not
a problem with the current scheduler on a multicore systems, but on
single core machnies or with any other future scheduler this field may
become just an unnecessary burden. It isn't difficult for an application
to compute CPU load by itself when it needs it.
2014-01-03 19:44:57 +01:00
Pawel Dziepak
135bb9c959 kernel: Do not attempt to interrupt a thread that is not waiting 2013-12-31 03:53:56 +01:00
Pawel Dziepak
15a7f2046a kernel: Return CPU load in cpu_info 2013-12-29 22:47:06 +01:00
Pawel Dziepak
e46f284adc kernel/util: MinMaxHeap: Fix unused variable warnings 2013-12-29 22:47:05 +01:00
Pawel Dziepak
a47974dd06 scheduler: Use heap to determine highest priority thread 2013-12-29 19:24:01 +01:00
Pawel Dziepak
3309bf33c7 kernel/util: Make MinMaxHeap::Peek*() const 2013-12-23 03:52:13 +01:00
Pawel Dziepak
b89b5d3826 x86: Make arch/smp.h a C++ only header 2013-12-20 22:05:26 +01:00
Pawel Dziepak
b258298c70 kernel: Protect cpu_ent::active_time with sequential lock
atomic_{get, set}64() are problematic on architectures without 64 bit
compare and swap.
Also, using sequential lock instead of atomic access ensures that
any reads from cpu_ent::active_time won't require any writes to shared
memory.
2013-12-20 01:31:32 +01:00
Pawel Dziepak
6639514437 x86[_64]: Support assigning MSI IRQs to arbitrary CPU 2013-12-20 01:07:08 +01:00
Pawel Dziepak
e3d001ff02 x86: Implement multicast ICIs 2013-12-19 19:35:44 +01:00
Pawel Dziepak
1b06228f13 kernel: Propagate scheduler modes to cpu{freq, idle} modules 2013-12-17 23:26:37 +01:00
Pawel Dziepak
4fcbac58de kernel: Make get_cpu_topology() return a pointer to const
The client code is not supposed to change the topology info.
It would be also nice if cpu_topology_node::children was an array of
pointers to const but that would require several const_casts in the
topology tree generation code so it's probably not worth it.
2013-12-17 22:08:18 +01:00
Pawel Dziepak
735f67481f x86: Debugger can now use dr3 2013-12-17 04:31:29 +01:00
Pawel Dziepak
a5b070f1fa x86: Store pointer to the current thread in gs:0
Apparently, reading from dr3 is slower than reading from memory
with cache hit.

Also, depending on hypervisor configuration, accessing dr3 may cause
a VM exit (and, at least on kvm, it does), what makes it much slower
than a memory access even when there is a cache miss.
2013-12-17 04:08:51 +01:00
Pawel Dziepak
611376fef7 x86: Let each CPU have its own GDT 2013-12-17 03:57:20 +01:00
Pawel Dziepak
7b9668170c kernel, boot: Increase CPU limit to 64 2013-12-16 05:00:02 +01:00
Pawel Dziepak
d02aaee17e kernel, libroot: Add more memory info in system_info
system_info now contains all information previously available only
through __get_system_info_etc(B_MEMORY_INFO, ...).
2013-12-16 04:53:46 +01:00
Pawel Dziepak
1bc7045fdf kernel, libroot: Introduce new API for obtaining system info 2013-12-16 03:58:43 +01:00
Ingo Weinhold
9bdb5e0a92 kernel safemode: Add functions to get options early
Add get_safemode_option_early() and get_safemode_boolean_early() to get
safemode options before the kernel heap has been initialized. They use a
simplified parser.
2013-12-10 19:05:47 +01:00
Ingo Weinhold
7a1e706df7 safemode.h: Update coding style 2013-12-10 17:07:20 +01:00
Pawel Dziepak
3e0e3be760 boot, kernel: Replace MAX_BOOT_CPUS with SMP_MAX_CPUS 2013-12-06 19:43:08 +01:00
Pawel Dziepak
f0fe981769 kernel: Fix gcc2 build 2013-12-06 03:31:20 +01:00
Pawel Dziepak
2b04d8ab31 x86/paging: Use CPUSet instead of cpu_mask_t 2013-12-06 03:27:48 +01:00
Pawel Dziepak
7629d527c5 kernel: Use CPUSet in ICI code instead of cpu_mask_t 2013-12-06 03:08:39 +01:00
Pawel Dziepak
730882d615 kernel: Remove RunQueueLink.h 2013-12-05 23:28:42 +01:00
Pawel Dziepak
52b442a687 kernel: smp_cpu_rendezvous(): Use counter instead of bitmap 2013-12-05 23:10:04 +01:00
Pawel Dziepak
d287274dce scheduler: Code refactoring 2013-12-05 22:47:30 +01:00
Ingo Weinhold
7b83ce1142 Add KDL command "mapping"
* VMTranslationMap:
  - Add DebugPrintMappingInfo(): Given a virtual address it is supposed
    to print the paging structure information for that address. To be
    implemented by derived classes.
  - Add DebugGetReverseMappingInfo(): Given a physical addresss it is
    supposed to find all virtual addresses mapped to it. To be
    implemented by derived classes.
* X86VMTranslationMapPAE: Implement the new methods
  DebugPrintMappingInfo() and DebugGetReverseMappingInfo().
* Add KDL command "mapping". It supports both virtual address lookups
  and reverse lookups.
2013-12-05 05:13:21 +01:00
Ingo Weinhold
7bf85edf58 Allow disabling ASLR via DISABLE_ASLR environment variable
* VMAddressSpace: Add randomizingEnabled property.
* VMUserAddressSpace: Randomize addresses only when randomizingEnabled
  property is set.
* create_team_arg(): Check, if the team's environment contains
  "DISABLE_ASLR=1". Set the team's address space property
  randomizingEnabled accordingly in load_image_internal() and
  exec_team().
2013-12-01 02:51:50 +01:00
Ingo Weinhold
e2c5cf691d boot loader: Menu: Add SetTitle() 2013-11-30 19:56:26 +01:00
Ingo Weinhold
cbfc38c62d boot loader: MenuItem: Add SetLabel() 2013-11-30 19:39:57 +01:00
Pawel Dziepak
2b7ea4cddf kernel: Remove Thread::next_state 2013-11-29 19:31:10 +01:00
Pawel Dziepak
673f08a995 kernel: Make thread_block_locked() private 2013-11-29 05:30:50 +01:00
Pawel Dziepak
7f8cf14b71 scheduler, kernel/util: Fix style issues 2013-11-29 04:51:38 +01:00
Pawel Dziepak
3514fd77f7 kernel: Reduce lock contention when processing ICIs 2013-11-29 03:36:44 +01:00
Pawel Dziepak
286b341a40 kernel: Merge two occurences of thread resume code 2013-11-28 14:03:57 +01:00
Pawel Dziepak
7db89e8dc3 kernel: Rework cpuidle module
* Create new interface for cpuidle modules (similar to the cpufreq
   interface)
 * Generic cpuidle module is no longer needed
 * Fix and update Intel C-State module
2013-11-25 23:50:27 +01:00
Ingo Weinhold
dd11460a49 Add a hex dump utility for use in KDL commands 2013-11-25 12:45:36 +01:00
Pawel Dziepak
0e94a12f8e kernel: Make CACHE_LINE_ALIGN visible in the whole kernel 2013-11-25 00:35:15 +01:00
Pawel Dziepak
03f7d3d1db kernel: Restore logical processor disabling 2013-11-24 22:51:07 +01:00
Pawel Dziepak
14e36af649 kernel[/util]: Fix debug builds 2013-11-21 03:24:54 +01:00
Pawel Dziepak
024541a4c8 kernel: Improve rw_spinlock implementation
* Add more debug checks
 * Reduce the number of executed instructions that lock the bus.
2013-11-21 02:25:03 +01:00
Pawel Dziepak
308f594e2a kernel, libroot: Make scheduler modes interface public 2013-11-20 23:32:40 +01:00
Ingo Weinhold
c04f3a625a boot loader: Add safe mode blacklist submenu
It's a browser for the system package content, where entries can be
selected to blacklist them. The selected entries are removed from the
packagefs instance in the boot loader, so that e.g. selected drivers
won't be picked up. The paths are also added to the safe mode driver
settings and will be interpreted when the system packagefs instance is
mounted by the kernel.
2013-11-20 16:00:35 +01:00
Ingo Weinhold
6c7abe9829 boot loader: Menu[Item] API improvements
* Make Menu and MenuItem polymorphic.
* MenuItem:
  - Make SetMarked() virtual, so it can be overridden.
  - Add SetSubmenu() and Supermenu().
  - Delete the submenu in the destructor.
* Menu:
  - Add Entered()/Exited() hooks. They frame the time the user navigates
    the menu or any of its submenus. The hooks allow for subclasses
    populating their item list dynamically.
  - Add SortItems().
* Update boot loader menu copyright text to include 2013, now that it is
  over soon. :-)
2013-11-20 16:00:34 +01:00
Ingo Weinhold
435fb01509 DoublyLinkedList: Add Sort() 2013-11-20 16:00:34 +01:00
Ingo Weinhold
7e7f482590 SinglyLinkedList: Missing include 2013-11-20 16:00:34 +01:00
Pawel Dziepak
9c2e74da04 scheduler: Move mode specific logic to separate files 2013-11-20 09:46:59 +01:00
Ingo Weinhold
2fdd1d9ef1 khash: Move string hash functions to own header/source file
Unlike khash they shouldn't be phased out (only renamed).
2013-11-19 15:08:34 +01:00
Pawel Dziepak
d897a478d7 kernel: Allow reassigning IRQs to logical processors 2013-11-18 04:55:25 +01:00
Pawel Dziepak
955c7edec2 kernel: Measure time spent in interrupt handlers 2013-11-18 01:50:37 +01:00
Pawel Dziepak
6a164daad4 kernel: Track load produced by interrupt handlers 2013-11-18 01:17:44 +01:00
Pawel Dziepak
288a2664a2 scheduler: Remove sSchedulerInternalLock
* pin idle threads to their specific CPUs
 * allow scheduler to implement SMP_MSG_RESCHEDULE handler
 * scheduler_set_thread_priority() reworked
 * at reschedule: enqueue old thread after dequeueing the new one
2013-11-13 05:31:58 +01:00
Pawel Dziepak
829f836324 scheduler: Minor cleanup 2013-11-12 04:42:12 +01:00
Ingo Weinhold
e5f6591382 VM: vm_memset_physical(): Correct length parameter type 2013-11-11 22:27:52 +01:00
Pawel Dziepak
03fb2d8868 kernel: Remove gSchedulerLock
* Thread::scheduler_lock protects thread state, priority, etc.
 * sThreadCreationLock protects thread creation and removal and list of
   threads in team.
 * Team::signal_lock and Team::time_lock protect list of threads in team
   as well.
 * Scheduler uses its own internal locking.
2013-11-08 02:41:26 +01:00
Pawel Dziepak
72addc62e0 kernel: Introduce Thread::time_lock and Team::time_lock 2013-11-07 22:16:36 +01:00
Axel Dörfler
547cd462f8 trim: Added is_called_via_syscall() function.
* And use it in get_trim_data_from_user(), formerly known as copy_*().
* This fixes differentiating between user and kernel buffers.
2013-11-07 19:06:13 +01:00
Axel Dörfler
99086aa323 trim: Target SCSI UNMAP command instead of WRITE SAME.
* The UNMAP command is theoretically much faster, as it can get many block
  ranges instead of just a single range.
* Furthermore, the ATA TRIM command resembles it much better.
* Therefore, fs_trim_data now gets an array of ranges, and we use SCSI UNMAP
  to trim.
* Updated BFS code to collect array ranges to fully support the new
  fs_trim_data possibilities.
2013-11-07 19:03:47 +01:00
Pawel Dziepak
3519eb334a kernel: Change Thread::team_lock to rw_spinlock 2013-11-07 04:20:59 +01:00
Pawel Dziepak
defee266db kernel: Add read write spinlock implementation 2013-11-07 04:20:32 +01:00
Pawel Dziepak
d3e5752b11 scheduler: Performance mode is actually low latency mode 2013-11-07 01:50:20 +01:00
Pawel Dziepak
83983eaf38 kernel: Remove Thread::alarm 2013-11-07 01:40:02 +01:00
Pawel Dziepak
aa4aca0264 kernel: Protect signal data with Team::signal_lock 2013-11-07 01:32:48 +01:00
Pawel Dziepak
73ad2473e7 Remove remaining unnecessary 'volatile' qualifiers 2013-11-06 00:03:07 +01:00
Pawel Dziepak
273f2f38cd kernel: Improve spinlock implementation
atomic_or() and atomic_and() are not supported by x86 are need to be
emulated using CAS. Use atomic_get_and_set() and atomic_set() instead.
2013-11-05 22:47:18 +01:00
Pawel Dziepak
077c84eb27 kernel: atomic_*() functions rework
* No need for the atomically changed variables to be declared as
   volatile.
 * Drop support for atomically getting and setting unaligned data.
 * Introduce atomic_get_and_set[64]() which works the same as
   atomic_set[64]() used to. atomic_set[64]() does not return the
   previous value anymore.
2013-11-05 22:32:59 +01:00
Pawel Dziepak
f4b088a992 kernel: Protect UserTimers with sUserTimerLock 2013-11-05 05:36:05 +01:00
Pawel Dziepak
4824f7630b kernel: Add sequential lock implementation 2013-11-05 04:16:13 +01:00
Pawel Dziepak
3c819aaa72 kernel: DPC: remove schedulerLocked argument 2013-11-04 23:51:18 +01:00
Pawel Dziepak
11cacd0c13 kernel: Remove thread_block_with_timeout_locked() 2013-11-04 23:45:14 +01:00
Jérôme Duval
e2183a14c4 Increased kernel stack size by another page for 64-bit
* USB boot now works on x86_64 with PM.
2013-11-04 18:53:49 +01:00
Pawel Dziepak
d8fcc8a825 kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag
The flag main purpose is to avoid race conditions between event handler
and cancel_timer(). However, cancel_timer() is safe even without
using gSchedulerLock.

If the event is scheduled to happen on other CPU than the CPU that
invokes cancel_timer() then cancel_timer() either disables the event
before its handler starts executing or waits until the event handler
is done.

If the event is scheduled on the same CPU that calls cancel_timer()
then, since cancel_timer() disables interrupts, the event is either
executed before cancel_timer() or when the timer interrupt handler
starts running the event is already disabled.
2013-10-31 01:49:43 +01:00