Commit Graph

2232 Commits

Author SHA1 Message Date
Jonathan Schleifer
617793f41b Add back declarations to kernel_cpp.h for GCC
Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
2015-11-07 20:53:13 +01:00
Jonathan Schleifer
71e0324992
Move new / delete kernel_cpp.h -> kernel_cpp.cpp
new and delete may not be defined as inline, as Clang loudly complains.
The same is true for static.
2015-11-07 18:16:23 +01:00
Simon South
75c31ae28d system: Build using public elf.h header
Reduce duplication of code by

* Removing from elf_common.h definitions available in os/kernel/elf.h
* Deleting elf32.h and elf64.h
* Renaming elf_common.h to elf_private.h
* Updating source to build using public and private ELF header files
  together

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2015-11-07 11:49:56 +13:00
Axel Dörfler
6adf7a0c75 VFS: prevent FD inheritance for the kernel completely.
* Each io_context now has a "inherit_fds" member that decides whether
  or not this context allows to inherit FDs to its children.
* This replaces the former O_CLOEXEC mechanism.
2015-09-11 17:08:35 +02:00
Michael Lotz
5d4501aa01 Assorted whitespace cleanup and typo fixes. 2015-08-20 21:54:41 +02:00
Michael Lotz
f9a8f3e727 Clean up various whitespace and fix one header guard. 2015-08-02 23:19:07 +02:00
Jérôme Duval
189156a069 Boot stdio.h: define a bunch of functions required by c++ headers. 2015-07-26 10:07:21 +02:00
Axel Dörfler
4bf862e368 syslog_daemon: Converted to BServer.
* Instead of letting the kernel search for the syslog port, the
  daemon now registers itself with the kernel (which even solves
  a TODO).
* A port is created for the actual log messages from the launch_daemon,
  and used on start.
* However, the SyslogTest does not yet work, due to the BMessage <->
  KMessage communication problems.
2015-07-22 20:40:47 +02:00
Axel Dörfler
035e3e77ed kernel: profile system when SYSTEM_PROFILER is defined.
* This enables a mechanism to profile almost the complete boot process
  (starting with main2()), if SYSTEM_PROFILER is defined to 1.
* You can access the profiling data using "profile -r".
2015-07-22 20:39:52 +02:00
Jérôme Duval
94887feb64 Added some support for GCC 5+. 2015-07-20 21:45:02 +02:00
Hamish Morrison
d6d439f3f7 Reimplement unnamed POSIX semaphores using user_mutex
* Fixes sharing semantics, so non-shared semaphores in non-shared
  memory do not become shared after a fork.
* Adds two new system calls: _user_mutex_sem_acquire/release(),
  which reuse the user_mutex address-hashed wait mechanism.
* Named semaphores continue to use traditional sem_id semaphores.
2015-05-24 14:03:40 +01:00
Alexander von Gluck IV
9c5e234cb3 arm: Initial Cubieboard4 work
* SD cards are "blessed" with a boot0 spl and boot1 u-boot
  at fixed locations.
* Allwinner's u-boot is lacking a lot.
* Upstream u-boot should be better at some point. WIP:
  http://lists.denx.de/pipermail/u-boot/2015-January/201537.html
2015-04-11 16:53:04 -05:00
Michael Lotz
459e651fd5 syscalls: Remove lookup_symbol syscall again.
This partially reverts b959d46dbd.
2015-04-11 11:18:51 +02:00
Michael Lotz
b959d46dbd syscalls: Add get_stack_trace and lookup_symbol syscalls.
The get_stack_trace syscall generates a stack trace using the kernel
debugging facilities and copies the resulting return address array to
the preallocated buffer from userland. It is only possible to get a
stack trace of the current thread.

The lookup_symbol syscall can be used to look up the symbol and image
name corresponding to an address. It can be used to resolve symbols
from a stack trace generated by the get_stack_trace syscall. Only
symbols of the current team can be looked up. Note that this uses
the symbol lookup of the kernel debugger which does not support lookup
of all symbols (static functions are missing for example).

This is meant to be used in situations where more elaborate stack trace
generation, like done in the userland debugging helpers, is not possible
due to constraints.
2015-04-10 16:00:49 +02:00
Alexander von Gluck IV
b1ad5660b2 arm: Prevent bcm283X inclusion from breaking other boards
* Move *_BASE into board_config.h to prevent conflicts
2015-04-04 17:44:32 -05:00
Fredrik Holmqvist
251eb00d51 Use B_PRId32. 2015-04-01 20:18:00 +02:00
Alexander von Gluck IV
c6a4fee579 loader/u-boot: Use FDT serial info to create uart
* drop my fdt tests
* we have to call fdt parsing code *after* cpu_init (why?)
* pass fdt pointer to all FDT support calls to avoid confusion
  once we get into the kernel land
* look for PL011 compatible uart and use it
* Add some saftey checks to serial putc code to avoid null*
* fdt_node_check_compatible returns 0 on success not 1
* fdt_get_device_reg needs to add the SOC base to the result
* fdt_get_device_reg might need to add the second range cell
  instead of reg?
2015-03-28 15:52:16 -05:00
Alexander von Gluck IV
40eb7121b6 arm/fdt: Start using new fdt code in mmu_man's fdt_serial logic
* Expose fdt_get_device_reg for others to use
2015-03-14 14:29:30 -05:00
Alexander von Gluck IV
fe19a9b18b arm/fdt: Add functions to get device bases by name + alias
* Move more code into fdt_support
* We now can query FDT registers based on name or alias
* Return addr_t where it makes sense
* Copyright change ok'ed by mmu_man
2015-03-14 13:03:51 -05:00
Alexander von Gluck IV
f121867b87 arm/fdt: Initial reorg of fdt support code
* Makes FDT support code useable by everyone
  without all of the externs
* Further movement to be non-u-boot centic
  may still happen.
2015-03-14 09:50:46 -05:00
Alexander von Gluck IV
af056576ea bcm283X: Don't break all non-bcm arm builds, warn.
* Called via arm_mailbox_bcm2835 *and* arm_framebuffer_bcm2835
* This is a bit messy. We really should be getting these
  chipset-centric bases from the provided FDT / DTB.
* I can't think of a way to redo this without undoing
  work towards FDT.
2015-03-13 17:43:35 -05:00
Alexander von Gluck IV
deb4929b9a rpi1/rpi2: Use PL011 UART fallback in loader.
* Adjust UART base locations to reflect ARM pref base.
* We have a working haiku_loader_u-boot on Raspberry Pi 2!:q
2015-03-07 13:42:18 -06:00
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