Commit Graph

6484 Commits

Author SHA1 Message Date
François Revol
495efc382b loader: Drop the HashMap for partition lookup by id
The HashMap constructor was called before the heap is initialized,
ending up calling malloc from the OpenHashMap constructor.

Oddly it was still working on x86 but broke other platforms.

Instead we add a Lookup() static method to Partition,
which by default walks gPartitions for the id,
and recursively calls itself on the children lists.

This means we must add a partition even temporarily to gPartitions
before Scan()ing it though.

Signed-off-by: François Revol <revol@free.fr>
2016-09-02 19:02:33 +12:00
Fredrik Holmqvist
735f1daee9 EFI: Implement console code. 2016-09-02 19:02:32 +12:00
Fredrik Holmqvist
bd0604764e Setup -fno-pic or -fpic in Architecture Rules.
EFI boot needs -fpic but all boot code was built with -fno-pic.
This is now set accordingly in HAIKU_BOOT_CCFLAGS and
HAIKU_BOOT_C++FLAGS.

Also setup compile flags for EFI platform.
2016-09-02 19:02:32 +12:00
Fredrik Holmqvist
211483cb51 EFI: Initial test EFI application
* Only set HAIKU_BOOT_PLATFORM to bios_ia32 if not defined
* Add gnuefi build feature
* Introduce BOOT_LDFLAGS, and move options for passing to linker
  into ArchitectureSetup
* x86_64 compile fixes for warnings in boot loader
* loader/elf.cpp: don't include ELF32 support when targeting EFI
* relocation_func.cpp: copy of the relocation code from gnuefi
  to make _relocate extern "C", and avoid including <efilib.h>
* boot_loader_efi.ld: copy of gnuefi's elf_x86_64_efi.lds,
  modified to include support for C++ constructors, etc. Keep in
  sync with the gnuefi package

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-09-02 19:02:29 +12:00
Adrien Destugues
2080509cb0 Fix some missing parentheses
* Problem found by gcc4.
2016-08-27 09:31:16 +02:00
Adrien Destugues
c92f19c6e8 Fix definition of _setjmp
The #pragma weak does not work, the symbol is not defined and when
already defined, it is not made weak. Moreover, it does not make the
symbol global so we need to declare it with a FUNCTION.

If we want the symbol to be weak, then we should use .weak to do so. The
_longjmp symbol should also be changed to match, in that case.

Fixes #12912.
2016-08-14 09:18:07 +02:00
Augustin Cavalier
4fecb09f14 libroot: Ship empty libpthread.a and libm.a for POSIX and general compatibility.
A few weeks back, I spotted in the Musl FAQ that they apparently ship
empty libm.a and libpthread.a files (https://www.musl-libc.org/faq.html),
which they said was for POSIX compatibility. A bit of digging got me to
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html which
says:

> It is unspecified whether the libraries libc.a, libl.a, libm.a, libpthread.a,
> librt.a, [OB] [Option Start] libtrace.a, [Option End] libxnet.a, or liby.a
> exist as regular files. The implementation may accept as -l option-arguments
> names of objects that do not exist as regular files.

So to follow the letter of the law, we only need to have the "c99" command
accept these; however, it appears all Linux and BSD cstdlibs accept them
no matter what compliance mode is in effect.

Discussed with PulkoMandy. This will make HaikuPorts' job a lot easier...
2016-08-13 11:16:06 -04:00
Adrien Destugues
8efb6db7b9 elf.h: rename ELF_MAGIC to ELFMAG
- This is how it is named in other versions of elf.h (Linux, glibc, possibly more)
- ELF_MAGIC is used by libelf for the same thing, and the defines conflicts,
  breaking libelf build on Haiku.
2016-08-06 20:32:47 +02:00
Adrien Destugues
766f682338 Fix build and first runtime problem in network boot
The boot still crashes some time later, but at least it is easier to
test now.

- PackageFS included in the net boot archive
- Tell the system it is booted "from image" when netbooting
2016-08-06 20:29:08 +02:00
François Revol
02283e080c M68K: drop the custom C arch_cpu_user_mem*() for the default impl
I didn't notice there was a C++ version that didn't require writing asm.

I'll have to write them anyway for speed someday.
2016-07-20 21:57:19 +02:00
François Revol
169349c98f M68K: more SMP stubbing
We'll very much likely never support SMP on M68K...
(unless someone has an SMP machine to donate? :D)
2016-07-20 21:56:15 +02:00
François Revol
ad4b06aa75 m68k/paging: Convert to new-style CPU management
* Aka, post-scheduler changes
* Luckily M68K paging code is very simular to x86 paging
2016-07-20 21:28:56 +02:00
François Revol
9df4533caa M68K: use the updated atomic semantics
* Use atomic_get_and_set to return the old value
* Atomics are no longer volatile
2016-07-20 21:26:32 +02:00
François Revol
a462159ce3 M68K: Update to new system_info structures 2016-07-20 21:26:12 +02:00
François Revol
7cd7ba758c M68K: fix implicit casts of fault handler 2016-07-20 21:07:26 +02:00
François Revol
830fd19eb5 M68K: Fix spinlock initialization 2016-07-20 21:06:38 +02:00
François Revol
d26fd5f68d M68K: drop the platform_type field, the enum is gone from OS.h 2016-07-20 20:31:14 +02:00
François Revol
c094f04537 M68K: dos2unix some files
For some reason they used CR-LF.
2016-07-20 20:27:08 +02:00
François Revol
990d34efdd M68K: add arch_cpu_idle and arch_cpu_pause inline stubs
Remove the stub from arch_cpu.cpp

We might want to implement a 040 CPU module providing idle using LPSTOP.
2016-07-20 20:26:29 +02:00
François Revol
181391c106 ARM: Add TODO on barrier calls, we might need to do more here
They look suspiciously empty.
2016-07-20 18:53:24 +02:00
Ingo Weinhold
c60453fd79 Core dump: Add symbols for commpage to core file 2016-05-22 22:10:48 +02:00
Ingo Weinhold
90f571868e kernel: Add elf_read_kernel_image_symbols()
Refactor new function out of _user_read_kernel_image_symbols(). Can be
used to get a kernel image's symbols from within the kernel as well.
2016-05-22 22:10:47 +02:00
Ingo Weinhold
a689b8f22e kernel: team_create_thread_start_internal(): Set text_delta
The commpage's symbol table entries are commpage start relative.
2016-05-22 22:09:53 +02:00
Jérôme Duval
f022c304b0 readdir_r(): uses the logic of readdir()...
to retrieve more than one entry.
* readdir_r() is now affected by rewinddir(), thus fixing #12755.
* extends dirent_test with readdir_r().
2016-05-07 16:40:53 +02:00
Jérôme Duval
ab7c65d33d arm: remove duplicate arch_get_thread_debug_cpu_state(). 2016-05-02 21:25:05 +02:00
Ingo Weinhold
a0c364c70d Core file images note: Add text delta field 2016-04-29 22:32:15 +02:00
Ingo Weinhold
9266cd66c7 extended_image_info: Add text_delta field
Needed to offset a symbol address read from the symbol table to the
actual load address.
2016-04-29 22:32:14 +02:00
Ingo Weinhold
5cde7a856d Add symbol and string table addresses to core file 2016-04-27 02:16:54 +02:00
Ingo Weinhold
8c6cb8af01 runtime loader: Register extended image info with kernel
Add structure extended_image_info which extends image_info by the
fields symbol_table, symbol_hash, string_table.
2016-04-27 02:16:09 +02:00
Ingo Weinhold
82185a52e2 Future proofing core file format
* The Haiku specific notes contain a structure size field, now.
* Change the type of the count and size fields in the Haiku specific
  notes to uint32 also for 64 bit ELF. The size field for a note is a
  uint32 anyway.
2016-04-27 00:55:23 +02:00
Ingo Weinhold
467fe4ca0c kernel: Add core dump facility
* Add function core_dump_write_core_file(). It writes a core file for
  the current thread's team. The file format is similar to that of
  other OSs (i.e. ELF with PT_LOAD segments and a PT_NOTE segment), but
  most of the notes are Haiku specific (infos for team, areas, images,
  threads). More data will probably need to be added.
* Add team flag TEAM_FLAG_DUMP_CORE, thread flag
  THREAD_FLAGS_TRAP_FOR_CORE_DUMP, and Team property coreDumpCondition,
  a condition variable available while a core dump is progress. A
  thread that finds its flag THREAD_FLAGS_TRAP_FOR_CORE_DUMP set before
  exiting the kernel to userland calls core_dump_trap_thread(), which
  blocks on the condition variable until the core dump has finished. We
  need the team's threads to stop so we can get their CPU state (and
  have a generally unchanging team state while writing the core file).
* Add user debugger message B_DEBUG_WRITE_CORE_FILE. It causes
  core_dump_write_core_file() to be called for the team.
* Dumping core as an immediate effect of a terminal signal has not been
  implemented yet, but that should be fairly straight forward.
2016-04-24 18:22:14 +02:00
Ingo Weinhold
ac1f1a926e kernel: +image_iterate_through_team_images()
Like image_iterate_through_images(), but iterates though the images of
the given team only.
2016-04-24 17:30:52 +02:00
Ingo Weinhold
99f00556a4 kernel: +arch_get_thread_debug_cpu_state()
Similar to arch_get_debug_cpu_state(), but the thread whose CPU state
to retrieve is specified. Works only for threads that aren't running,
and on x86-64 we can get the FPU state only when the thread was
interrupted in userland.
Not implemented for the incomplete architecture ports.
2016-04-24 17:29:28 +02:00
Ingo Weinhold
7a187cd629 _user_debug_thread(): Use new signal SIGNAL_DEBUG_THREAD
This resolves a TODO: We used thread_interrupt() to wake up the thread
from an interruptable wait. However, if the thread was already in the
kernel and about to start waiting, that would have no effect and the
thread would wait anyway. Now there's the new non-blockable signal
SIGNAL_DEBUG_THREAD, which is sent to the thread instead, making sure
that thread doesn't start waiting.
2016-04-24 11:54:17 +02:00
Fredrik Holmqvist
20e11028aa Don't use partition pointer as id, as it only works on 32bit platforms.
Use a counter to generate the partition id, and store the id to partition
lookup in a hashmap instead.
2016-04-14 19:18:21 +12:00
Dario Casalinuovo
2b05e191ce Revert "Force runtime_loader permissions during build"
This reverts commit f45b1ff242.
2016-04-06 12:12:25 +02:00
Dario Casalinuovo
f45b1ff242 Force runtime_loader permissions during build
* Fixes #12373.
2016-04-06 00:29:38 +02:00
Axel Dörfler
67988f501a NodeMonitor: Resolve mount points for B_WATCH_CHILDREN.
* When a watched directory contains a mount point, we need to resolve
  the actual parent directory of the mount point in the file system to
  serve the monitor.
2016-03-28 14:31:27 +02:00
Axel Dörfler
6f7fc2204b NodeMonitor: Added B_WATCH_CHILDREN flag.
* Added a directory argument for notify_{stat/attribute}_changed().
* This allows to watch only a directory, and get the notifications for
  all of its files, not just add/remove entry notifications.
2016-03-28 14:31:27 +02:00
Michael Lotz
3108c9bed0 ioapic: Fix 64 bit build with tracing enabled, some cleanup.
* Use print format macros to fix the 64 bit build.
* Correct a typo in the shift of the trigger mode definition. As the
  value is 0 either way, this does not make a functional difference.
* Use macros instead of values in comparisons.
2016-03-12 13:34:01 +01:00
Adrien Destugues
3b4f50d3fb Style fix.
Thanks to axel for watching!
2016-03-04 20:01:58 +01:00
Adrien Destugues
93ea83e53d Allow custom baud rates for FTDI serial ports
- Termios: cf{get,set}{i,o}speed can handle arbitrary speed values.
- The value is stored in the appropriate fields of the termios structure
  in this case. The old constants (stored in the flags) are preserved
  for BeOS binary compatibility.
- Adjust the FTDI FT232* driver to accept custom rates, by replacing the
  hardcoded regster values with a function that will compute it
  according to FTDI documentation (confirmed giving the same values for
  the existing baudrates).
2016-02-27 19:08:53 +01:00
François Revol
e89ef1fef7 U-Boot: TRACE fdt_serial instead of dprintf
and disable it by default (it would hang on some platforms anyway).
2016-02-26 22:59:33 +01:00
François Revol
c82af4bebe U-Boot: try to use virtual-reg to get the UART
XXX: possibly only for _BOOT_MODE?
2016-02-26 22:58:45 +01:00
François Revol
14cfccd011 U-Boot: add a 'physical' arg to fdt_get_device_reg()
If false, try to use the virtual-reg property first.
2016-02-26 22:58:17 +01:00
François Revol
73ef47f70a loader: TRACE undefined symbols
While the kernel shouldn't have any, it happens on platforms missing new features.

Make it explicit.
2016-02-26 22:57:06 +01:00
Alexander von Gluck IV
4e7b05cca2 platform/bios_ia32: Fix regression introduced in hrev48326
* Reverts f3e381dd
* Details in #12633
* For some unknown reason, this change breaks an Intel Core 2
  system from booting (Dell Optiplex 960, E8400)
* If anyone has any ideas on why, let me know :-)
2016-02-02 18:48:19 -06:00
Adrien Destugues
9ec8a1e4d9 Kernel POSIX: add stpcpy.
- Required by new GCC versions, which are able to optimize string
  appends using it.
- Fixes build of ACPICA for x86/gcc4.
2015-12-29 10:24:06 +01:00
Michael Lotz
28d3c8ca50 runtime_loader: Resync heap impl with the one of the bootloader.
The heap implementation of the runtime_loader was switched to the one
of the bootloader in 6f0994d but was since updated independently.

To keep the diff between the two implementations as small as possible,
the bootloader implementation was first copied to the runtime_loader
and then some features not relevant in the runtime_loader (like the
special large allocation handling) have been removed and the
runtime_loader specific features (grow_heap, add_area) have been
reintegrated. But basically this applies 96689a5..HEAD of
src/system/boot/loader/heap.cpp to the runtime_loader heap.

This brings in the switch from a linked list to a splay tree based
free chunk management. Since the allocation counts in the runtime_loader
are rather small, this does not perceptibly affect performance in either
direction though.
2015-12-27 13:54:48 +01:00
Michael Lotz
8bbfae7b05 runtime_loader: Fix endless rld heap grow loop in edge case.
The needed storage space for tracking the allocation size was not
accounted for when growing the heap. Since the growth size is always
rounded up to a multiple of 32KiB, this did almost never matter as the
new allocation wouldn't need the full size. If the allocation did
happen to need the full size however, the newly added area would always
be too small. As the allocation attempt was simply restarted after each
successful growth, this lead to an endless loop creating small new
areas, which would then quickly starve the system for memory.
2015-12-27 13:54:47 +01:00
Augustin Cavalier
6984b8554c Revert "libroot: Undefine constants for unsupported POSIX features"
This reverts commit 7aebec8db1.
As per the discussion on the mailing list.
2015-12-21 12:16:33 -05:00
Simon South
7aebec8db1 libroot: Undefine constants for unsupported POSIX features
Haiku does not yet support certain features related to POSIX threads.
Constants used to test for the presence of these features should
therefore be left undefined, according to the POSIX spec, but are
currently set to -1. This can cause software built on Haiku to
incorrectly detect the presence of these features.

* unistd.h: Undefine _POSIX_THREAD_ATTR_STACKADDR,
  _POSIX_THREAD_PRIORITY_SCHEDULING feature constants.
* conf.cpp: __sysconf: Return -1 for unsupported features.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-21 11:09:34 -05:00
Simon South
dbf060a3f7 libroot: Add brk() and sbrk().
This commit replaces the placeholder implementation of sbrk(), which
operated on a process' heap, with real implementations of brk() and
sbrk() that adjust a process' program break.

* unistd.h: Add standard definitions of brk() and sbrk(); include
  stdint.h for intptr_t.
* thread.cpp: Recognize RLIMIT_AS and RLIMIT_DATA resource limits
  (both currently unlimited); order limit identifiers alphabetically.
* arch-specific.cpp: Remove sbrk_hook().
* malloc_debug_api.cpp: Remove sbrk_hook().
* unistd/Jamfile: Build brk.c instead of sbrk.c.
* unistd/brk.c: Add.
* unistd/sbrk.c: Delete (placeholder implementation).
* libroot_stubs.c: Remove sbrk_hook().
* libroot_stubs_legacy.c: Remove sbrk_hook().
* src/tests/.../posix/Jamfile: Build brk_test.c.
* brk_test.c: Add (simple unit test that demonstrates behaviour of
  sbrk()).

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2015-11-22 17:59:22 +01:00
Michael Lotz
ba307a12db vfs: Cleanup: Move functions around for more logical grouping.
Move static internal functions out of the API functions block and drop
their vfs_ prefix and move an API function into the API functions block.
2015-11-08 22:31:56 +01:00
Michael Lotz
c73d13015d kernel: Use anonymous namespaces to avoid type collisions.
The anonymous namespace makes type definitions local to the translation
unit (like static does for objects). For pretty much any type not shared
across multiple files this is what one wants to happen (and might
erroneously expect to happen automatically).

This commit solves some actual collisions that were present:

* The VFS and the rootfs both used an incompatible VnodeHash struct for
  their BOpenHashTable.
* XSI semaphores and message queues both used queued_thread, Ipc and
  IpcHashTableDefinition.

For release builds these did not cause problems as the types were fully
inlined. Debug builds would crash at boot however because parts of a
BOpenHashTable<VnodeHash> from the rootfs meant to operate on struct
rootfs_vnode would be applied to one from the VFS expecting struct
vnode.

As such collisions are violations of the one definition rule, the code
is at fault and unfortunatley the compiler isn't required to diagnose
such problems across translation units (which isn't actually trivial).
This can lead to subtle and hard to debug problems and it's therefore
best to avoid leaking types into the global namespace whenever possible.
2015-11-08 22:31:56 +01:00
Jonathan Schleifer
f7ededa623
shell.S: Add .section .bss to make Clang happy 2015-11-08 16:30:40 +01:00
Jonathan Schleifer
50a1d86c88
byteorder.S: Use flds instead of fld
Clang refuses to guess.
2015-11-08 16:27:31 +01:00
François Revol
c518435bb1 VFS: pass correct vnode to fs calls in default get_vnode_name
The opendir and closedir/free_dircookie hooks were called with
mismatched vnode. It seems only googlefs is actually affected by this,
since all other fs without a get_vnode_name just don't are about the
passed vnode arg to closedir and free_dircookie.

Now I should really get some sleep!
2015-11-08 04:32:57 +01:00
François Revol
8f4a653ca6 VFS: typo 2015-11-08 04:32:57 +01:00
Jonathan Schleifer
93bcaf3650
arm/arch_exceptions.S: Replace spsr_all with spsr
After a quick look at binutils, they seem to be equal, however, Clang
does not accept the _all one.
2015-11-08 00:59:18 +01:00
Jonathan Schleifer
15d594cccd
ARM: Add __aeabi_memset and __aeabi_memmove alias 2015-11-08 00:54:32 +01:00
Jonathan Schleifer
d8548e00aa
Fix some more type mismatches with std::{min,max} 2015-11-08 00:44:18 +01:00
Jérôme Duval
6c4cca34c2 glibc: replace extern __inline with __extern_always_inline for x86.
* also update __atan2l for x86, update __FAST_MATH sections.
2015-11-08 00:38:20 +01:00
Jérôme Duval
b49dd60c46 Drop namespace std after 95d4ed6778. 2015-11-08 00:38:19 +01:00
Jonathan Schleifer
c7624537a3
ARM: Alias __aeabi_memcpy to memcpy 2015-11-07 23:11:14 +01:00
Jonathan Schleifer
55de0addd5
arm/arch_string.S: Only use sane insns for Clang 2015-11-07 18:29:50 +01:00
Jonathan Schleifer
ed6dfed2a0
Fix a type mismatch for std::min() 2015-11-07 18:16:40 +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
Jonathan Schleifer
b310316956
Fix arm/arch_string.S for Clang 2015-11-07 18:08:01 +01:00
Jonathan Schleifer
95d4ed6778
Add missing "using std::nothrow" 2015-11-07 18:08:01 +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
Simon South
874e9521b2 x86_64: Glue code: Keep stack 16-byte-aligned
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2015-10-28 21:24:34 +01:00
Jérôme Duval
6c009cde0b kernel: avoid dprintf messages for known header types we don't use.
* fix a typo in runtime_loader/count_regions().
2015-10-28 21:21:56 +01:00
Simon South
d5447eb9c0 runtime_loader: Do not assume executable has dynamic segment
This prevents a crash when loading a statically linked executable.

Fixes #12287.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2015-10-26 21:23:30 +01:00
Simon South
078b88b12d runtime_loader: Randomly position only relocatable code
The use of an unreliable test for relocatability effectively broke
runtime_loader's support for non-position-independent executables, as it
would insist on randomly positioning these files' segments in memory
anyway causing the program to quickly crash.

With this change runtime_loader uses the object type specified in the
file's header to determine whether its segments can be safely relocated,
restoring support for non-PI executables.

Fixes #12427.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2015-10-26 21:19:25 +01:00
Murai Takashi
1e6dd3feed Fix GCC 5 maybe-uninitialized warnings.
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #12020
2015-10-26 21:13:24 +01:00
Murai Takashi
949cf6ac85 Fix GCC 5 build.
* Add -fgnu89-inline flag for libroot/posix/glibc
* Change __GNUC__ == 4 to __GNUC__ >= 4

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

Fixes #11990, most of the changes had already been done.
2015-10-26 19:05:24 +01:00
Adrien Destugues
1388211503 Implement stat.st_rdev for block and character devices.
* devfs: set st_rdev to the inode number of the node being queried. This
  may not be the best thing to do, as it does not match what is set in
  st_dev for other files, so it can't be used to find which device
  stores a particular file. I'm not sure if st_rdev is actually used that
  way anywhere, however.
* vfs: do not clobber st_rdev with -1 for "special" (device) files.
  Refactor the code a little so setting the common attributes is done in
  a single place.

Fixes #12390.
2015-10-11 18:26:21 +02:00
Simon South
5df5223b4b kernel: Don't send SIGTTOU if calling thread is blocking it
POSIX requires SIGTTOU to be sent to a process in a background process
group that tries to change the foreground process group ID associated
with its controlling terminal, unless the process is ignoring SIGTTOU or
the calling thread is blocking it. Previously the code checked the
former condition but not the latter, making it possible for calls to
tcsetpgrp() to get stuck in a loop and never return.

Should fix #3417.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-10-08 19:25:31 -04:00
François Revol
594187ade2 glibc/ppc: add missing math stuff
hopefully fixing the build for the 53rd time...
2015-09-18 03:59:56 +02:00
François Revol
bbdf4c27fa glibc: avoid linking long double math stuff on PPC and M68K 2015-09-18 03:59:56 +02:00
François Revol
dab2aa8189 complex.h: fix __NO_LONG_DOUBLE_MATH test
PPC doesn't support long double yet...
2015-09-18 03:59:55 +02:00
Jessica Hamilton
8927348ef1 Boot menu: change colours of sub-menu headers. Fixes #12371.
Changed from white on red background, to yellow on black
(neutral) background. Red on black made it look like a
warning, whereas yellow feels more informative.
2015-09-15 01:32:07 +00:00
Axel Dörfler
eb62d3337b VFS: Slight rework of the FD disconnect feature.
* This should fix ticket #4157, although I probably have missed
  something.
* In any case, it no longer messes with the ref counts of the
  file descriptor, and the race condition in put_fd() should be
  gone.
* It's still rather messy all in all.
2015-09-11 17:25:01 +02: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
Axel Dörfler
e668e80db0 VFS: Always open kernel FDs with O_CLOEXEC.
* Avoids leaking them into userland.
2015-09-11 08:57:15 +02:00
Michael Lotz
d64c7086d5 Various whitespace cleanup only. 2015-09-05 16:09:33 +02:00
Michael Lotz
8b9bb054f4 libroot_debug: Replace two more uses of printf in guarded heap.
Use the internal print_stdout() instead as done when printing the
stack traces.
2015-08-23 13:19:12 +02:00
Michael Lotz
5dbea46970 libroot_debug: Track freeing thread in guarded heap separatley.
Previously the thread member was overwritten with the freeing thread
when a page was freed, leading to confusion when hitting unallocated
pages due to the debugger message still stating "allocated by thread".

Track the freeing thread separately as it might be interesting to know
both, which thread initially allocated and which thread eventually freed
an allocation.
2015-08-23 13:10:12 +02:00
Michael Lotz
c4a9344a11 libroot_debug: Support alignments > B_PAGE_SIZE in guarded heap.
These are always allocated using an area. The allocation size is
increased as to guarantee the availability of a suitable address. The
pages between the allocation info and the actual, aligned start address
and the pages past the allocation end are then protected.

This commit also fixes corruption of the allocation info for large
allocations that used areas. The alignment wasn't taken into account
when calculating the amount of space needed. The alignment could then
lead to rounding down the allocation start such that it would overlap
with the allocation info.
2015-08-20 21:59:41 +02:00
Michael Lotz
5d4501aa01 Assorted whitespace cleanup and typo fixes. 2015-08-20 21:54:41 +02:00
Michael Lotz
efb0a3a853 EntryCache: Add entry_cache_add_missing() for negative caching.
It provides a way for filesystems to cache a lookup failure and
therefore prevents repeated lookups of missing entries. This is a
common scenario for example in command lookup and compiling, where
each directory in PATH or each include directory is searched for the
given entry.
2015-08-20 21:25:56 +02:00
Alexander von Gluck IV
5d91a421b9 glibc/arm: More generic math functions 2015-08-15 00:00:26 -05:00
Alexander von Gluck IV
76cc2d8f45 glibc/arm: Filling in more ARM gaps 2015-08-14 21:06:40 -05:00
Alexander von Gluck IV
17ddd6c09d libroot/arm: Add in some missing math functions
* Using native assembly functions would be a lot faster,
  but would require quite a bit of changes to glibc.
* This gets arm linking for now... I'd personally like
  to see musl in here in the future for gcc4 images. (pre-R2)
2015-08-14 13:46:05 -05:00
Alexander von Gluck IV
ab341b9d63 kernel/arm: Correct platform id on ARM 2015-08-14 12:50:05 -05:00
Michael Lotz
1748116d1c libroot_debug.so: Fix missing alignment in guarded realloc. 2015-08-13 22:33:55 +02:00
Michael Lotz
8fa441bf5c libroot_debug: Revert to a legacy default alignment of 8.
This reverts the legacy default alignment (in absence of max_align_t)
to 8, as it was before.
2015-08-13 22:12:19 +02:00
Michael Lotz
f474606ee9 libroot_debug: Merge guarded heap into libroot_debug.
The individual debug heap implementations are now exposed via a
structure of function pointers and a common frontend dispatches the
malloc and malloc_debug APIs through them.

The MALLOC_DEBUG environment variable can be used to select the guarded
heap by adding 'g', otherwise the debug heap is used as the default.
Consequently the separate libroot_guarded is not needed anymore and has
been removed.

To allow the use of environment variables this early, init_env_post_heap
has been added and the heap dependent atfork() moved there. This allowed
to fold the code of init_heap_post_env into init_heap so the former has
been removed.
2015-08-13 22:12:18 +02:00
Rene Gollent
422b0ec754 libroot: Fix issue reported in ticket #12291.
fts.c:
- Our fts functions were imported from FreeBSD and consequently did not
  use the same weak alias methodology that most of our glibc-derived
  POSIX functions do. These subsequently wound up clashing with the
  implementation of said functions in current versions of coreutils,
  resulting in assertion failures when e.g. running a program through
  stdbuf, since the BSD-derived functions had different flag constraints
  than their GNU peers. Consequently, this change adjusts the fts_*
  family of functions to similarly be exported as weak symbols so they
  can be preempted.
2015-08-10 17:01:35 -04:00
Michael Lotz
f9a8f3e727 Clean up various whitespace and fix one header guard. 2015-08-02 23:19:07 +02:00
Rene Gollent
27dec4bb1e user_debugger: Adjust handling of continue request.
- B_DEBUG_MESSAGE_CONTINUE_THREAD now checks if the thread in question
  is in a suspended state rather than waiting on the debug nub port, and
  if so, handles resuming it automatically. This allows the continue message
  to be used on the main thread of a team that was freshly created under
  debug control without the API user having to be cognizant of the distinction.
2015-07-31 17:28:00 -04:00
Jérôme Duval
2a868d7645 glibc: replace extern __inline with __extern_inline.
* this helps to comply with C99. As a reminder, some of these headers
are also used by x86_gcc2 src/libs/stdc++.
2015-07-26 10:09:22 +02:00
Rene Gollent
410b38b5c5 libroot: Fix strto{i,u}max.
- According to POSIX, these functions should map to whatever's appropriate
  for the platform's intmax_t size, which in our case is a 64-bit integer.
  Our (2004) implementation, however, was calling the 32-bit variations of
  strto*(), leading to truncation for larger values.
2015-07-24 21:57:11 -04:00
Axel Dörfler
34671d601a Added execvpe().
* This closes #12114 again; while not POSIX, it's just a line away.
* Removed exect() from the header -- not sure where this came from.
  but I can't find anything about it on the net.
* Consolidated use of asterisk style in exec.cpp.
2015-07-23 13:30:30 +02:00
Axel Dörfler
463d38e40b Fixed exec*(), and __flatten_process_args() with NULL env.
* Not sure if it's following any standard, but environ can be NULL
  (either by manually setting it to NULL, or by calling clearenv()).
2015-07-22 20:44:12 +02:00
Axel Dörfler
7987907008 launch_daemon: We can now talk to the authentication manager.
* When creating the port of the registrar's authentication manager, we
  now set it manually, so that the user/group functions work.
* This allows LaunchDaemon::_StartSession() to set up the user, and
  groups as needed.
2015-07-22 20:43:26 +02:00
Axel Dörfler
ef462ab57f libroot: ensure that the launch_daemon doesn't wait for itself.
* The launch_daemon might indirectly call get_launch_daemon_port()
  which may cause a deadlock. Just fail in this case.
2015-07-22 20:41:09 +02:00
Axel Dörfler
1f374c8b2a libroot: hardcode find_directory() to /home/boot for root.
* This is a work-around to allow the registrar, and the launch_daemon
  to call find_directory() without worries.
2015-07-22 20:41:05 +02:00
Axel Dörfler
bea38cb711 registrar: implemented auth port via launch_daemon.
* get_roster_port_name() is no longer needed.
* This also removes the app_server restart code from the debug
  server -- this will be done by the launch_daemon in the future.
2015-07-22 20:41:01 +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
9d69dc097d libroot: added ability to communicate with the launch_daemon.
* These methods don't really work yet, as BMessage doesn't support
  replying with a KMessage; the request is received, but the reply
  never gets to the target.
2015-07-22 20:40:42 +02:00
Axel Dörfler
89168ad8b9 Boot the system via launch_daemon.
* This is actually working already, although we cannot reproduce all
  the features of the former Bootscript yet. This is without any
  dependency support in launch_daemon.
* All shell activity like cleaning out /tmp, setting up the environment,
  setting the time, etc. is not yet working.
2015-07-22 20:40:33 +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
a83446983d libroot: added a complex.h header based on ...
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html
* added missing parts from glibc.
* x86_64 was already complete, x86 was missing a few functions.
* should help with #12202, provided that the gcc4 buildtools are rebuilt.
2015-07-10 22:39:21 +02:00
Ingo Weinhold
fb29004aaf disk device manager: Remove obsolete include path
virtualdrive hasn't been used for a long time. Should help with #12162.
2015-07-05 09:40:13 +02:00
Augustin Cavalier
6eafb4b041 Replace a few references to Subversion with Git.
There are a whole bunch more of these around, but these were the
ones I was confident replacing.
2015-06-19 15:36:52 -04:00
Jérôme Duval
0dc6b011fe malloc: implement malloc_usable_size().
* Fix #12132
2015-06-13 14:29:11 +02:00
François Revol
78b7298197 u-boot: PPC: Fix warnings 2015-06-12 23:18:33 +02:00
Hamish Morrison
b092f872b3 fork: update the thread id in the pthread struct after forking
Otherwise the child process's main thread will inherit the thread id
of its parent and pthread operations will be directed at the wrong
thread.
2015-06-04 13:36:29 +01:00
Hamish Morrison
9afa331102 chown: leave owner and group unchanged when values of -1 are passed 2015-06-02 16:54:40 +01: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
Axel Dörfler
748c0f3021 kernel: Fixed broken port tracing.
* Broken since the scheduler merge.
2015-05-11 22:55:41 +02:00
Hamish Morrison
fb67dbf0a4 user mutex: dequeue waiters when waking them up
* This prevents the same waiter being woken multiple times, before it
  has a chance to run and dequeue itself.
2015-05-07 23:20:54 +01:00
Hamish Morrison
10b4fed24f Add support for pthread_condattr_get/setclock()
* Allows use of either CLOCK_REALTIME or CLOCK_MONOTONIC as the time
  base for pthread_cond_timedwait().
2015-05-02 20:55:57 +01:00
Humdinger
040029e0b8 Have B_FIND_PATH_LIB_DIRECTORY return the architecture.
Fixes #12028.
2015-04-28 08:07:22 +02:00
François Revol
a2ddc1c06e Fix CompileDTS rule to locate the device tree blob properly
This avoids having to call it from the BoardSetup files.
2015-04-24 02:27:55 +02:00
Michael Lotz
5d05694ad6 kernel guarded heap: Implement allocations debugger command.
It can be used to dump the current heap allocations with their details
and stack traces if enabled.
2015-04-23 23:04:38 +02:00
Michael Lotz
453ee84e23 kernel guarded heap: Also store team id for allocations. 2015-04-23 23:01:53 +02:00
Michael Lotz
337c4ccf01 kernel debugger: Use memcpy for stack trace on kernel stack.
If it was already determined that the memory is within the kernel
stack, a simple memcpy is enough.

This allows capturing kernel stack traces in situations where a fault
handler cannot be installed (i.e. where one is already installed).
2015-04-23 22:54:45 +02:00
François Revol
5c2425a61e PPC: fix COFF bootloader entry point
The concept of entry point in COFF is actually different than in ELF.

In COFF, the entry point is actually a "descriptor" (pointer) to the actual
start code. So we patch the entry point address when calling objcopy.

Now my old Performa 5400/180 actually starts the loader correctly \o/
2015-04-22 02:43:35 +02:00
François Revol
ade89bf38e PPC: simplify the bootloader linker script
the OF 2.0 COFF loader skips sections other than
.text .data and .bss, so merge others into those three.
2015-04-22 02:43:34 +02:00
François Revol
c3bffc88c9 fix warnings 2015-04-21 00:25:30 +02:00
François Revol
10e57f6e58 PPC: fix handler type cast 2015-04-20 17:19:33 +02:00
Alexander von Gluck IV
f178e4a248 arm: bcm2835 framebuffer
* Drop some messy mmu externs
* Set proper page flags
2015-04-19 20:13:24 -05:00
Alexander von Gluck IV
f427a82d48 arm: Add debug function to dump mmu state
* We don't change the data cache (and other) settings.
  Interesting to know their state on each platform.
* Not used by default as it needs called after
  serial-init in u-boot
2015-04-19 20:13:23 -05:00
Michael Lotz
9bf9ee3806 Whitespace and style cleanup only. 2015-04-12 18:50:01 +02:00
PulkoMandy
7d82b5d4ab arm/mmu: Fix boot on beagle-xm
* The changes for pi2 support led to the virtual addresses overlapping
with the page table again on the beagle, because the kernel address
space overlaps with the physical RAM identity mapped. Try to find a
memory range in a way that will work in both cases.
2015-04-12 17:52:24 +02: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
97ebc043a6 Remove empty file probably accidentally added in hrev47198. 2015-04-11 23:37:55 +02:00
Michael Lotz
8f9d4cad45 syscalls: Remove get_stack_trace syscall again.
This reverts the other half of b959d46dbd.
2015-04-11 23:37:55 +02:00
Michael Lotz
3dfbe1a12d guarded_heap: Use __arch_get_stack_trace() instead of syscall.
The stack base and end addresses are stored in TLS slots that are
prepared when enabling stack traces and filled in lazily on use for
each thread. This avoids the need of calling get_thread_info to get
these values.

Also simplifies the code somewhat due to proper frame skipping support.
2015-04-11 23:37:54 +02:00
Michael Lotz
c012e7e930 libroot: Add private __arch_get_stack_trace().
It can be used to get a stack trace of the current thread. Note that
this works by walking frame pointers and will not produce anything
useful if an application is compiled with the frame pointers omitted.

The stack base and end addresses have to be provided as arguments and
are used to check that the frame pointers fall within that range. These
values are thread specific and can be retrieved with get_thread_info().
No other sanity checks (like checking for loops in the linked list) are
done.

This is a simplified rewrite of the stack trace code from the kernel
debugger.

As this code is common to x86 and x86_64 but is not generic across
architectures I introduced x86_common as a directory to put such
sources.
2015-04-11 23:37:54 +02:00
Michael Lotz
459e651fd5 syscalls: Remove lookup_symbol syscall again.
This partially reverts b959d46dbd.
2015-04-11 11:18:51 +02:00
Michael Lotz
bd5dea318a guarded_heap: Replace symbol lookup syscall with runtime_loader.
Use the private runtime_loader API to do the symbol lookup instead of
using the syscall.
2015-04-11 11:18:51 +02:00
Michael Lotz
ebdc1d480e runtime_loader: Add imageName and exactMatch to symbol lookup.
Extend the get_nearest_symbol_at_address() private runtime_loader
export to include imageName and exactMatch arguments.

The imageName holds the SONAME of the image, if available, so cannot
neccessarily be extracted from the image path.

Whether or not there was an exact match, i.e. the symbol with its size
contains the address, is now returned in exactMatch.
2015-04-11 11:18:50 +02:00
Michael Lotz
0cf3d62115 Make guarded heap accessible through its own libroot_guarded.so.
This adds libroot_guarded.so to the HaikuDevel package. It is the same
as libroot_debug with the debug heap swapped out for the guarded heap.
The guarded heap has some useful features that make it desirable to use
while having the disadvantage of a large memory and address space
overhead which make it unusable in some situations. Therefore the
guarded heap cannot simply replace the debug heap but should still be
made available. As the heap init needs to happen even before having
environment variables, the heap to use can not be chosen dynamically.
Exposing them through their own libraries is the next best thing.
2015-04-11 09:41:25 +02:00
Michael Lotz
74c284545b malloc_debug: Remove condition that is always true. 2015-04-10 17:11:56 +02:00
Michael Lotz
ec0190adb0 malloc_debug: Implement allocation dump on exit in guarded heap.
When enabled (using heap_debug_dump_allocations_on_exit(true) or
MALLOC_DEBUG=e) this causes a dump of all remaining allocations when
libroot_debug is unloaded. It uses terminate_after to be called as
late as possible.

When combined with alloc stack traces this makes for a nice if a bit
crude leak checker. Note that a lot of allocations usually remain
even at that stage due to statically, lazyly and globally allocated
stuff from the various system libraries where it isn't necessarily
worth the overhead to free them when the program terminates anyway.
2015-04-10 17:04:28 +02:00
Michael Lotz
e26a4e7b7a malloc_debug: Also print stack traces when dumping guarded heap. 2015-04-10 16:49:02 +02:00
Michael Lotz
607ac916de malloc_debug: Impl. heap_debug_dump_allocations in guarded heap. 2015-04-10 16:42:29 +02:00
Michael Lotz
158e20e60e malloc_debug: Implement alloc/free stack traces in guarded heap.
When configured to do so (using heap_debug_set_stack_trace_depth(depth)
or MALLOC_DEBUG=s<depth>) the guarded heap now captures stack traces on
alloc and free.

A crash due to hitting a guard page or an already freed page now dumps
these stack traces. In the case of use-after-free one can therefore see
both where the allocation was done and where it was freed.

Note that there is a hardcoded maximum stack trace depth of 50 and that
the alloc stack trace takes away space from the free stack trace which
uses up the rest of that maximum.
2015-04-10 16:28:42 +02:00
Michael Lotz
f4bd38257b Whitespace cleanup only. 2015-04-10 16:10:05 +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
Michael Lotz
416255de4e libroot: Fix typo in static variable name. 2015-04-10 15:05:13 +02:00
Michael Lotz
abf230a9ac malloc_debug: Set default alignment to max_align_t if available.
For it to be available we build malloc_debug in C++11 mode when not
using GCC2. Note that max_align_t is not in the std namespace in GCC4
versions prior to GCC 4.9. The extra "using namespace std" is there to
be forward compatible once we update.
2015-04-08 12:56:58 +02:00
Ithamar R. Adema
efdcada6f3 BlockWriter: Do not panic on failing read/writes
These were here for debugging purposes, as often it is a sign of
inconsistencies. However, for USB disks this is a normal occurence
when someone janks out of the device without unmounting first.

Make sure we log these cases though, as it still helps debugging.

Fix sponsered by http://www.izcorp.com
2015-04-05 22:18:09 +02:00
Michael Lotz
121655e9ee malloc_debug: Add default alignment option.
This allows for something similar as was implemented in 217f090 but
makes it optional and configurable.

The MALLOC_DEBUG environment variable now can take "a<size>" to set
the default alignment to the specified size. Note that not all
alignments may be supported depending on the heap implementation.
2015-04-04 22:55:57 +02:00
Michael Lotz
b0e31a9ce3 Revert "malloc_debug: align allocations".
This reverts commit 217f090f9e.

At least for the guarded heap this completely defeats the purpose. If
software requires a certain alignment it should request it using
memalign explicitly instead of assuming it.
2015-04-04 22:55:57 +02:00
Michael Lotz
37acb83e4c libroot_debug: Fix build of guarded_heap after atomic changes. 2015-04-04 11:04:35 +02:00
Michael Lotz
ffba66060b UserlandFS: Make 64 bit clean and enable build for x86_64.
I did not bother to fix the BeOS kernel emulation, so this part is
still left out of the x86_64 build.
2015-03-29 16:25:17 +02:00
Murai Takashi
cddfcf2f87 Fix incorrect initialization.
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2015-03-29 11:01:31 +02:00
Alexander von Gluck IV
3f80e2801f loader/fatfs: Fix tracing 2015-03-28 17:36:53 -05:00
Alexander von Gluck IV
115ac6bcae arm/mailbox: Load mailbox base from FDT in loader 2015-03-28 16:56:50 -05:00
Jérôme Duval
f5e61f7174 libroot.so: libc-lock.h: use a pthread mutex based impl.
* based on current glibc sysdeps/nptl/bits/libc-lock.h file.
* include missing headers which were previously included by libc-lock.h.
* This fixes #11182.
2015-03-28 22:02:53 +01: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
Michael Lotz
3384ca1a7b rootfs: Fix wrong comparison for buffer reuse on rename.
The comparison to decide whether or not to reuse the name buffer when
renaming a rootfs entry was reversed. For renames where the new name
was longer than the old one this resulted in writing beyond the name
buffer and corrupting random kernel memory.

A likely candidate for this to be triggered was when a audio cd was
renamed due to a CDDB lookup, as the placeholder "Audio CD" is quite
short and the actual CD name is usually longer.

Fixes: #10259. Possibly fixes the related #9528 and #9858.
2015-03-28 12:18:29 +01:00
Jérôme Duval
c5b66b40ab use macro instead of attributes for weak aliases. 2015-03-28 09:41:40 +01:00
Axel Dörfler
b7a87fd137 find_paths_etc(): added user/system only flags.
* B_FIND_PATHS_(USER|SYSTEM)_ONLY cause only the specified paths
  to be included in the result list.
2015-03-26 21:47:22 +00: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
de8d2d8957 arm/fdt: Clean up debugging statements
* Add some comments
2015-03-13 23:52:37 -05:00
Alexander von Gluck IV
59ef0db249 arm/fdt: Add code to navigate FDT.
* This isn't be best long-term place for this code,
  will likely move to some generic FDT support code.
* We pass a path like "/soc/gpio" and get back the
  base physical register address in memory minus
  the range offset.
2015-03-13 23:46:54 -05:00
François Revol
1a8d852f25 ARM: Fix copy-paste oversight 2015-03-14 04:11:47 +01:00
Alexander von Gluck IV
401afabd40 loader/arm/mmu: Set first available va to KERNEL_LOAD_BASE
* The existing code set the first available pa and va to
  the end of the page dirctory.
* The arm mmu code was attempting to identity map (va==pa)
  the memory, but also wanted memory to be in kernel space.
  This allocation method isn't possible on all boards
  (including the pi)
* We're adjusting the dynamic ram to KERNEL_LOAD_BASE
  plus the max size of the kernel. (which is what most
  other platforms are doing)
2015-03-13 16:25:03 -05:00
Alexander von Gluck IV
91c878846b u-boot: Improve error checking on framebuffer 2015-03-10 22:40:38 -05:00
Alexander von Gluck IV
2ac9acbba4 bcm2835: Improve framebuffer tracing and error trapping 2015-03-10 22:40:07 -05:00
Alexander von Gluck IV
2fc1ec2238 bcm2835: Adjust mailbox base register 2015-03-10 22:07:38 -05:00
Alexander von Gluck IV
f90ec6bffc bcm2835: Use mailbox calls again 2015-03-07 20:43:41 -06:00
Alexander von Gluck IV
ed9a0b70f3 u-boot/serial: Only reference pl011 on ARM
* This will likely change once we FDT.
2015-03-07 13:50:32 -06: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
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
Paweł Dziepak
91bf7d51f0 boot/arm: mailbox_bxm2708: add final and override specifiers
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2015-03-06 19:03:59 +01:00
Paweł Dziepak
1410ffb696 boot/arm: use std::atomic<> to access bcm2708 mailbox
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2015-03-06 19:03:59 +01:00
Paweł Dziepak
2b92ac2a70 boot/arm: enable C++14
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
2015-03-06 19:03:59 +01:00
Alexander von Gluck IV
5eeb4163fa platform/u-boot: Make bcm2708 mailbox code functional
* Functional == compiles. Needs tested :-)
2015-03-06 10:17:52 -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
Alexander von Gluck IV
7ddf9bcf0d boot/arm: bcm2708 cleanup; no functional change 2015-03-05 22:54:21 -06:00
Alexander von Gluck IV
c798e80b79 raspberry_pi: Move over to u-boot.
* The raspberry_pi loader wasn't in great shape anyway,
  but could still contain some valueable code.
2015-03-05 22:41:47 -06:00
Alexander von Gluck IV
8a06abf132 bcm2708: Convert framebuffer driver over to new format
* Remove from raspberry_pi bootloader (which should die soon)
* Change to use new arm device layout
* Create arch_mailbox to check arm mailboxes (WIP)
2015-03-05 22:41:47 -06:00
Adrien Destugues
1736cb1d59 driver_settings: fix allocating an empty settings
I misread the condition and broke this in 0687a01. Thanks to Axel for
reviewing!
* Refactor the code again to move all the error checking at the top of
the function, to make it easier to read.
2015-01-14 13:39:35 +01:00
Adrien Destugues
bcb793d37b Fix driver_settings in kernel mode outside of drivers.
The API allows to create driver settings which are not added to the
global list, however those were left partially uninitialized, and there
was no way to cleanly delete them.

Tag such unattached settings with a ref_count of -1, and have
delete_driver_settings check for this and handle the case correctly.

Note: #10494 comment 2 says the settings for packagefs shouldn't be
added to the kernel driver settings list, which is why I went with this
solution. An alternative would be always using the list and the
reference counting, but I don't know what the consequences are.

Fixes #10494.
2015-01-14 11:53:19 +01:00
Adrien Destugues
0687a01b53 driver_settings: don't strdup(NULL)
* This is not allowed by strdup POSIX specs and GCC may use its builtin
strdup which doesn't check for it.
* also refactor parse_driver_settings_string to create the
settings_handle using settings_new, to reduce code duplication.
2015-01-14 11:53:18 +01:00
PulkoMandy
98731302d8 fssh_api_wrapper: fix build on non-Haiku.
* I'm not sure why strings.h needs to be included before <new>, but it
wouldn't work otherwise.
2015-01-14 10:16:32 +01:00
Adrien Destugues
749bd21c45 rootfs: fs_shel build fix attempt.
Sorry, I can't test all cases when building from Haiku.

Including <new> after the fs shell wrapper makes the compiler fail
because new needs a size_t argument (not an fssh_size_t). But including
it before also fails because it includes C++ typedefs without the fssh
wrapper, leading to conflicts.

Undefining size_t just for the include of <new> isn't very clean, but
seems to work. new gets a size_t argument as it should and the other
typedefs aren't conflicting.
2015-01-13 16:21:14 +01:00
Adrien Destugues
a7d444d145 Remove old block cache implementation
This was not used anywhere except the tests written for it (which is
also removed).
2015-01-13 15:48:59 +01:00
Adrien Destugues
ace74964f1 Remove khash from the sources.
Fixes #9552.
2015-01-13 15:48:58 +01:00
Adrien Destugues
bb3092b298 rootfs: convert to BOpenHashTable.
* Add an fs-shell compatible version of BOpenHashTable in the fs_shell
to keep it working. The header is renamed to KOpenHashTable to avoid a
conflict with the OpenHashTable.h available in private/shared which is
not API compatible.
2015-01-13 15:48:58 +01:00
Adrien Destugues
9d1c3b8d4b block cache: convert to BOpenHashTable. 2015-01-13 15:48:56 +01:00
Rene Gollent
be60c04c89 modules: Fix #11746.
- When normalizing paths of the preloaded modules to their final mounted
  path, remove them from the hash table before updating their path. Otherwise,
  the remove would fail due to the hash no longer matching, which in turn
  would cause the code in question to introduce an infinite loop in the
  hash table's internal link list due to manually rewriting the next link.
2015-01-12 19:08:24 -05: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
f9defd4526 VFS: migrate to BOpenHashTable. 2015-01-12 18:23:45 +01:00
Adrien Destugues
6235b4967b More useless inclusions of khash.h 2015-01-12 18:23:45 +01:00
Adrien Destugues
79b12613f5 legacy_drivers: convert to BOpenHashTable. 2015-01-12 18:23:44 +01:00
Adrien Destugues
887be0ac6a kernel/module: fully convert to BOpenHashTable 2015-01-12 18:23:44 +01:00
Adrien Destugues
c4718ea973 Missing std::nothrow on new
Forgot to add this when migrating to BOpenHashTable.
2015-01-12 09:46:40 +01:00
Rene Gollent
6e9704175e kernel: Style fix. 2015-01-09 19:49:52 -05:00
Rene Gollent
d05a5a70e0 kernel: Fix ELF hashtable iterator handling.
As a result of the refactoring for OpenHashTable, the iterator semantics
have changed a bit, such that the end of the table is no longer signalled
by the iterator returning NULL. This wasn't taken into account during
refactoring, which would lead to various places returning the last item
in the list in the case where no matching item was found, causing e.g.
drivers not to be loaded properly. This fixes the boot hang regressions
introduced in hrev48640.
2015-01-09 14:42:13 -05:00
Adrien Destugues
3b3cad8468 kernel elf: Fix Compare function
I forgot to change the function to return true on equality, instead of
returning the difference as khash required. Fixes a panic on boot.
2015-01-09 21:31:34 +01:00
Adrien Destugues
271ac910a4 Remove useless includes of khash.h
* These files were already converted to BOpenHashTable.
* For #9552.
2015-01-09 18:09:12 +01:00
Adrien Destugues
6a89f8040f devfs: migrate to BOpenHashTable
For #9552.
2015-01-09 18:09:10 +01:00
Adrien Destugues
69ff01cb9e Migrate image hash table to BOpenHashTable.
For #9552.
2015-01-09 18:09:09 +01:00
Adrien Destugues
57f933d348 CID603224: missing break in parsedate.
Could lead to wrongly setting the TYPE_MINUTE flag for an invalid (>59)
number of minutes. Harmless, as that flag is never used.
For completeness, also set the flag for seconds (also never used).

Fixes #11552.
2014-12-18 15:55:47 +01:00
Puck Meerburg
c038f26da8 Import div.c patch by Tri-Edge AI
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-12-14 18:06:21 +01:00
Puck Meerburg
a5f30beaad Fix #7008: Add a64l and l64a from glibc, and add some missing definitions in wchar.h and stdlib.h
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-12-14 18:06:09 +01:00
Adrien Destugues
38ec030ace FileDevice: implement icon ioctls
Fixes #9320.
2014-12-02 09:04:56 +01:00
Adrien Destugues
56abf4aa37 Fix std::isnan and friends for gcc2.
gcc2 was relying on the c99 functions being there, but they are not in
the std namespace.
* Disable the C99 functions and macros in C++ mode
* Redefine them as inline functions in cmath in the std namespace.

Fixes #7396.
2014-11-27 10:58:49 +01:00
Jérôme Duval
f3e381dd0c bios_ia32: for correctness, add clobber memory for asm invlpg.
* generated code is the same for x86_gcc2 and x86_64.
* fixed TRACE build for mmu.cpp.
2014-11-17 20:17:30 +01:00
PulkoMandy
8068b64b5c Fix build with guarded heap on x86_64
* Type mismatch.
2014-11-14 12:55:50 +01:00
Adrien Destugues
db214549c5 guarded_heap: fix build (volatile + atomic ops)
Unfortunately, the package manager uses more kernel memory and it's not
possible to boot to the desktop with the guarded heap anymore.
2014-11-12 16:20:24 +01:00
Adrien Destugues
7b4084f717 reject partitions with negative offset
I had a KDL when trying to read an audio CD which apparently uses this
as a copy protection scheme.
I don't know if this is the right place to do this, the KDL would happen
further down when the intel partitionning system or bfs would try to
read data from the disk at offset -2048.
2014-11-11 17:13:03 +01:00
Alexander von Gluck IV
57bc65034a Everything: Update lots of code to use B_COUNT_OF macro
* Likely not everything, but the obvious uses of B_COUNT_OF
2014-11-09 14:52:19 -06:00
Michael Lotz
9a6331459f kernel: Fix build with KDEBUG_LEVEL < 2.
The lock caller info isn't available in such a configuration.
2014-11-04 23:00:59 +01:00
François Revol
76b8f002e1 Implement lseek(SEEK_END) on devices
While the partitioning system does publish partitions as block
devices and report their size in stat(), the old BeOS-style
drivers have no means of reporting it this way.
So we fall back to ioctl(B_GET_GEOMETRY) to find out the size.
2014-11-04 20:47:04 +01:00
François Revol
b7ff6340ae U-Boot: always initialize args.arguments_count 2014-11-04 16:01:16 +01:00
François Revol
361f5a857f ARM: OMAP3: dynamically allocate the framebuffer
It seems to work on overo at least, which has only 128MB by default in QEMU.
2014-11-03 21:06:20 +01:00
François Revol
1cac4300c3 ARM: Add an mmu_get_virtual_mapping() call to bootloader
Will be needed to figure out the framebuffer address
once we allocate it properly instead of hardcoding.
2014-11-03 20:49:01 +01:00
François Revol
cb3ea122d3 U-Boot: delay checking /chosen:bootargs after remapping FDT
This avoids having to copy the strings.
For now we disregard argv[] as it is not remapped before
being used in add_stage2_driver_settings() and is not used
by the linux entry point.

This makes the overo loader panic at the same place as
the beagle xm one now, even though it fails to display
anything with the default RAM size since we allocate
the framebuffer beyond 128MB...
2014-11-03 19:41:38 +01:00
Michael Lotz
eac94f5db9 kernel: Also push lock caller in acquire_spinlock_nocheck. 2014-11-02 00:04:28 +01:00
Michael Lotz
41418981f4 kernel: Sync panic messages across acquire_spinlock versions.
* Always include last caller and lock value on both UP and MP path.
* Change lock value printing to hex format, as 0xdeadbeef is more
  obvious than its decimal counterpart.
2014-11-02 00:04:27 +01:00
Jessica Hamilton
22ea34153f access: fix to be POSIX compliant 2014-11-02 08:51:24 +13:00
François Revol
564a073b01 ARM: move uEnv.txt content to BoardSetup file
That's really where it belongs. Not all boards will need it,
but for now it's always created.
2014-11-01 19:57:48 +01:00
François Revol
95e9515c4b U-Boot: drop the bind on the flash image action 2014-11-01 19:08:57 +01:00
François Revol
92fcf262ff ARM: Check for RAM size in FDT
We skip the check when we already have ranges inserted,
like from the raspberry Pi start code, and we fall back to
32MB at SDRAM_BASE is not found.
2014-11-01 18:53:48 +01:00
François Revol
8d8bda071f U-Boot: generate a separate uImage for the boot tgz as well
We need this when using the linux entry point.
2014-11-01 17:11:01 +01:00
François Revol
d1ebf9716d U-Boot: ARM: Add a linux entry point to asm shell code
While the NetBSD entry point is handy as we can use a single uImage
with all 3 blobs, it bypasses U-Boot's own patching of the FDT since
it's not visible to it, so we won't get the RAM size and other things
through it.
2014-11-01 17:09:09 +01:00
François Revol
5de5d59d78 U-Boot: move gUImage and gFDT back to BSS section
No need for this trick anymore.
2014-11-01 16:39:44 +01:00
François Revol
909a14bb55 U-Boot: introduce a start_gen() catch-all entry
So we can pass it all the optional stuff instead of playing tricks
to initialize them outside of BSS.
2014-11-01 16:39:44 +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
François Revol
1309cdade9 U-Boot: rework flash image rule to be more flexible
We can now specify arbitrary content and offsets for each.

Change the default block size to 1k.
2014-11-01 05:37:06 +01:00
François Revol
f680a1a723 U-Boot: skip flash-image targets if no U-Boot image is passed
When building flash images we want a U-Boot binary for now.
Testing for it avoids dd waiting for input on stdin
instead leaving no clue.
2014-11-01 02:15:09 +01:00
François Revol
88d51506d0 Move ARM device tree files to an arch-specific subfolder
FDT are also used on PPC at least, and at least skeleton.dtsi
might clash since there is a different one for PPC.
2014-10-31 16:28:48 +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
Ithamar R. Adema
5d8ce4733c ARM: u-boot: Generate DTB and include in uImage 2014-10-31 12:08:03 +01:00
Ithamar R. Adema
a52dd58d2d ARM: kernel: introduce SoC abstraction
This introduces InterruptController and HardwareTimer classes to
handle the SoC specific implementations of timers and ints for
the ARM platform.

These could be improved and moved to a more 'generic' level once
we're confident they are 'good enough'.

NOTE: The OMAP timer implementation is fully untested and probably
      completely non-functional....
2014-10-31 11:37:02 +01:00
Ithamar R. Adema
1628632584 ARM: u-boot: fixup FDT handling
If we find an FDT (either from uImage or otherwise) we make sure
we map it after mmu_init() and use kernel_args to pass it to the
kernel (so it is available at all times there).
2014-10-31 11:21:38 +01:00