Commit Graph

6744 Commits

Author SHA1 Message Date
Augustin Cavalier
df9bc792e0 runtime_loader: Set sSearchPathSubDir on first image, not on app image.
Under normal conditions this will behave identically. But when using LD_PRELOAD
or the like, some shared objects (and dependencies) are loaded before the
app image is, and on the secondary arch on hybrid builds, will fail to load
any of their dependencies due to sSearchPathSubDir not being set.

Fixes #12214, which had plagued users of libroot_debug for a long time now.
2017-11-22 17:55:36 +01:00
François Revol
dd1454bd96 Defer calling arch_debug_console_init_settings
when we can actually read driver settings :-)
2017-11-20 18:16:54 +01:00
Alexander von Gluck IV
2dce5eecef build/arm: Correct missing sources in search
* Group into local var to prevent recurrence.
2017-11-20 09:36:56 -06:00
Alexander von Gluck IV
a42249db2d arm: Add 8250 omap variant uart driver
* Untested, someone with an omap3,4,5 could though.
2017-11-20 09:16:58 -06:00
François Revol
0835170c80 Actually use the serial port and speed from the kernel settings
Turns out we just reused the already set values, disregarding the new ones.
2017-11-20 11:44:43 +01:00
Alexander von Gluck IV
f6c47144a6 kernel/uart: Refinements to irq and FIFO management 2017-11-18 13:20:53 -06:00
Jérôme Duval
f57e467bd8 Update libroot stubs. 2017-11-18 17:28:06 +01:00
Jérôme Duval
edfefa187b libroot/posix: remove useless keyword extern. 2017-11-18 17:28:06 +01:00
Alexander von Gluck IV
1d3d336a97 libbsd: Move lutimes to bsd compat
* Rework be149e8ccf since lutimes isn't posix
2017-11-17 14:27:26 -06:00
Augustin Cavalier
7d8eb4d7f9 time: Address review comments.
* Use ENOSYS not B_DONT_DO_THAT (thanks korli)
 * Use unsigned long not uint64 (thanks axeld)
2017-11-16 20:53:14 +01:00
Jérôme Duval
0e9000201f POSIX: shm_open: set the FD_CLOEXEC file descriptor flag...
on the new file descriptor.
Fixes #13774.
2017-11-16 16:46:37 +01:00
Alexander von Gluck IV
be149e8ccf libroot/posix: Add lutimes for better posix compatibility
* Didn't exist on BeOS, but exists most other places.
* Update times of a file, not following symbolic links.
2017-11-16 00:38:54 -06:00
Augustin Cavalier
9a50e01ea6 set_real_time_clock: Change parameter from uint32 to uint64.
This should have been done along with the time_t change, but I forgot
to check this then.

Technically this breaks ABI against BeOS, but:
  1. BeOS used an int32, so we'd already slightly broken ABI here
  2. Only one thing at HaikuArchives (VMwareAddons) and one recipe at HaikuPorts
     (samba) uses this function at all.

If it turns out some critical BeOS app uses this, then I guess we can enclose
GCC2 guards around it, but since I can't find any evidence of that, I'm
pushing it without them for now.
2017-11-15 18:28:04 +01:00
Augustin Cavalier
a7c323c633 libroot/time: set_timezone is deprecated and does nothing, so don't return B_OK. 2017-11-15 18:11:33 +01:00
Augustin Cavalier
304f594da1 De-wire net_stack_cleanup from boot/loader/main.cpp
This reverts commit 2960780faa.
Sorry for the noise; I thought I'd run a compile but apparently it was
only a partial one.

It seems that the netboot core is linked into the main bootloader
no matter the build configuration, which means that since this one
function was called, the linker tried to resolve all the other symbols
from that static library. Which of course failed.
2017-11-13 21:17:45 +01:00
Andreas Faerber
2960780faa Wire up net_stack_cleanup()
The NetStack.h header is currently not usable from C code. So while
net_stack_init() is called from platform code, we cannot call
net_stack_cleanup() from OpenFirmware's platform_start_kernel().
Thus call it directly from main()'s cleanup TODO, having assured
that the function is a no-op when no network stack was initialized.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:48:26 +01:00
Andreas Faerber
ce6fdd33ef Detach UDP sockets on cleanup
The UDP service does not own the UDP sockets. When shutting down,
inform the bound sockets that the service is no longer available.
This allows subsequent method calls to error out cleanly.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:48:09 +01:00
Andreas Faerber
74077e46e1 Add net_stack_cleanup()
Add a cleanup function net_stack_cleanup() that calls a new NetStack::ShutDown() method.
Make sure this method works even if the network stack was never initialized.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:47:27 +01:00
Andreas Faerber
9037351c6c Don't double-free the Ethernet interface
It is currently done in both ~EthernetService() and ~NetStack().

Since NetStack is where it's added and where an explicit accessor function is provided,
choose that location.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-11-13 16:46:32 +01:00
Jérôme Duval
4bb883d9bf posix_spawn(): use MAX_SIGNAL_NUMBER instead of NSIG.
* fish now works with posix_spawn().
2017-11-04 17:25:42 +01:00
Jérôme Duval
04dabcfdf3 posix_spawn(): close the pipe read fd in the parent.
* also enable close-on-exec for the eventually dupped pipe write fd in the child.
2017-11-03 23:13:49 +01:00
jua
1769813948 x86-64: handle stack fault for non-canonical address access
* With the amd64 architecture, the stack fault exception got a new
  meaning: it is raised when an instruction tries to access a
  non-canonical address, and the stack is referenced in the
  instruction (e.g. by its addressing mode).
  So unlike on x86, this is not a fatal exception and shouldn't
  trigger a KDL -- instead, it is to be treated like a general
  protection fault, terminating the team which caused it.

* Fixes #13744
2017-11-02 18:55:03 +01:00
Jérôme Duval
87e6718233 POSIX: have sysconf(_SC_OPEN_MAX) return the rlimit value.
* we use this value in posix_spawn_file_actions_adddup2() for instance, ninja then
fails with "Bad file descriptor".
2017-11-01 13:07:11 +01:00
Alexander von Gluck IV
403baf656d u-boot: mmc single case volume label
* Makes parsing slightly easier in tools like rune-image.
* Mixed case introduces some extra encoding the WIP Rust
  FAT driver doesn't support (yet)
2017-10-18 11:43:54 -05:00
Jérôme Duval
a295d3f46e wait4(): retrieve dead team entries usage information.
* This adds a parameter to the wait_for_child syscall. I extended the test case
to show the actual retrieved information.
* fix #13546
2017-10-10 17:20:46 +02:00
Augustin Cavalier
6aff37d1c7 Move SHA256 class to libroot instead of linking libshared into libroot.
Discussed with PulkoMandy and on the haiku-commits mailing list.

Thanks to @jessicah for compile-testing and fixing 2 small issues I missed.
2017-10-03 20:18:26 -04:00
Jérôme Duval
2976cf85a4 libroot.so: make first parameter of dladdr() const.
This follows up on a mail from 2011:
https://www.freelists.org/post/haiku-development/Changing-dladdr-to-take-const-void-for-first-parameter
2017-09-15 23:09:24 +02:00
Jérôme Duval
ccd42320c4 libroot: add posix_spawn(). 2017-09-12 19:42:57 +02:00
Jérôme Duval
31e6a56fb3 kernel/fs: fix warning on x86_64. 2017-08-24 18:01:12 +02:00
Jérôme Duval
26740b2889 POSIX: F_DUPFD_CLOEXEC support (POSIX.1-2008).
* fix #12187.
2017-08-24 17:54:50 +02:00
Jérôme Duval
c35666602f libroot: mktemp.c: fix gcc5 warnings. 2017-08-13 22:32:39 +02:00
Philippe Houdoin
22b7e29bc6 libroot: mktemp.c: use rand_r() and set seed only on first call
This avoid to break caller's own srand() and having the same seed
if called twice very quickly.
Thanks david.given for a better fix for #13660.
2017-08-10 10:33:41 +00:00
Philippe Houdoin
c7a3a80cc6 libroot: make mktemp() more random
... by seeding rand() with process id, user id and current time.
This fix #13660
2017-08-09 19:33:36 +00:00
Philippe Houdoin
2a081b42a9 fifo: revert broken fix 2017-08-03 16:53:17 +00:00
Philippe Houdoin
65abebfaa7 fifo: wakeup readers not checking POLLHUP/B_SELECT_DISCONNECTED
For readers waiting in select() or simply in read(),
B_SELECT_DISCONNECTED notification didn't wake them anymore.
Now, cascade notifications to be sure to wake them, either
on POLLHUP, POOLERR/B_SELECT_ERROR or, at worst, from read().

See #7859 for details.
2017-08-03 11:48:02 +00:00
Philippe Houdoin
216574f371 fifo: fix #7859 2017-08-01 18:37:38 +00:00
Jérôme Duval
6c9e01265b pthread_rwlock: use a mutex for process-private locks.
* instead of a benaphore.
* define PTHREAD_RWLOCK_INITIALIZER.
* adjust Init(), Destroy(), StructureLock() and StructureUnlock().
2017-07-27 18:33:53 +02:00
hyche
9f9ba0bdc1 btrfs_shell: Support AVLTree 2017-07-25 09:34:46 +07:00
Axel Dörfler
a1eceb4610 rootfs: directories must not be opened writable.
* Also added support for O_DIRECTORY while at it.
* This fixes bug #13573.
2017-07-20 10:10:20 +02:00
Jérôme Duval
2d4d0f0ac1 Revert "vfs.cpp: Fix gcc6 crash."
This reverts commit 5b55f6dba9.
2017-07-12 17:36:24 +02:00
Alexander von Gluck IV
0cc293cf32 raspberrypi_arm: Drop old Raspberry Pi 1 boot loader.
* We transitioned to u-boot quite some time ago
* We also are dropping < ARMv7 support
2017-07-11 14:39:13 -05:00
Murai Takashi
5b55f6dba9 vfs.cpp: Fix gcc6 crash.
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2017-07-11 17:24:07 +02:00
Alexander von Gluck IV
a01d0e5ae5 arm: Enable mmu tracing. (We're going to need it for a while) 2017-07-10 15:16:55 -05:00
Alexander von Gluck IV
aba7320584 u-boot/arm: Add missing floppyboot to mmc 2017-07-10 14:53:04 -05:00
Alexander von Gluck IV
f5d7446b5b u-boot: Correct loader base naming 2017-07-10 13:34:29 -05:00
Alexander von Gluck IV
1b3c81feeb u-boot: Fix mmc build without target boards 2017-07-10 09:02:56 -05:00
Alexander von Gluck IV
1e82d7bd25 kernel/arm: Work out more board_config's via fdt 2017-07-10 08:19:44 -05:00
Alexander von Gluck IV
e40cea64bd u-boot/arm: Initial steps to drop target board requirements 2017-07-09 22:51:50 -05:00
Alexander von Gluck IV
855fc5a0d3 platform/u-boot: Build all fdt's and include in u-boot mmc
* Eventually BoardSetups and target boards will go away.
* Include all known fdt's in the mmc image
* This gets us closer to target board-less arm
* Changing hardware is as simple as plugging a new fdt
  into u-boot's startup script.
* Drop my original rpi1 work.  We're targetting ARMv7
  minimum.
2017-07-09 22:19:51 -05:00
Alexander von Gluck IV
144e404b2d libroot/ppc: Add missing stack_trace 2017-07-04 19:28:13 -05:00
Alexander von Gluck IV
b3d3ee5a2f libroot/ppc: Stub out emitted GCC atomics on ppc32
* gcc will emit 64-bit (_8) atomic functions on 32-bit
  powerpc architectures. This stubs them out for now
  with a warning.
* We could do more here, but i'm just getting PPC
  bootstrapped to get the nightly builds going again.
* We could also just completely drop PPC.. but it was
  pretty close pre-pm... so I'd hate to lose that work.
2017-07-03 13:05:47 -05:00
Alexander von Gluck IV
9c8119e02c kernel/smp: Add a comment for some obsecure knowledge
* I was ready to rip this out until PulkoMandy set me stright.
* Add a comment so others understand the impact here.
2017-07-03 09:43:07 -05:00
Alexander von Gluck IV
7f47ae44c2 openfirmware: Fix build post get_boot_partitions changes
* Thanks jessicah!
2017-07-02 22:57:53 -05:00
Pedro Pinto
856da1f3ff Add missing include with Partition class definition
* Fixes a compilation error while compiling the u-boot loader for
  the ARM platform.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-06-23 17:30:27 -04:00
Augustin Cavalier
6ad3d25212 real_time_clock: Change _user_{get|set}_timezone argument to int32.
Both the user-mode syscalls.h and the kernel-mode one define it
as an int32, not a time_t, and as it's a timezone offset not
an actual time, there's no reason it needs to be one.
2017-06-06 17:38:17 -04:00
Augustin Cavalier
affb4e25fe runtime_loader: Remove EXEMODE hack.
This reverts commit 6af29d4f83.
I'll have a look at our buildbot config and see if it needs fixing.
2017-05-28 12:42:12 -04:00
Augustin Cavalier
6af29d4f83 runtime_loader: Ensure EXEMODE is set.
Stopgap solution for #12373.
2017-05-26 15:31:55 -04:00
James Woodcock
d7b12f71ea kernel/fs: Fix permissions on symlinks in root directory.
Various symbolic links (/bin, for example) in the root directory have
no read, write or execute permissions. This prevents non-privileved users
from logging in.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Fixes #13530.
2017-05-26 15:10:18 -04:00
Rahul Jain
7ce3cbfbe8 "fail-safe video mode" is confusing.
The same wording was used for two unrelated things: using the VESA
driver, and forcing a specific resolution. Relabel the menu items to
make it clear that they are not related.

fixes #8887

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2017-05-25 11:46:02 +02:00
Alexander von Gluck IV
d8219f96da bootloader/bios: Add tracing of real-mode bios interrupt calls 2017-05-24 08:18:54 -05:00
Alexander von Gluck IV
9d9f76edff bootloader/hpet: Fix tracing on x86_64 2017-05-23 21:54:10 -05:00
Jessica Hamilton
f286626cd0 pxe_ia32: add missing include for boot::Partition 2017-05-17 23:21:40 +12:00
Jessica Hamilton
e888217124 loader: fetch all potential boot partitions for boot device.
This allows the loader to skip BFS partitions that don't contain
a bootable system. Useful when you have a BFS data partition that
comes before the system partition when iterated over.

Currently, only the UEFI loader actually returns more than one
possible partition.
2017-05-17 12:51:09 +12:00
Axel Dörfler
655aae6a79 KPathTest: Fix build for GCC 5.
* Also fixed a warning in KPath.
* Sorry, again!
2017-04-30 18:17:51 +02:00
Axel Dörfler
16825fd976 VFS: Pass on NULL for NULL paths, if allowed.
* Uses the new KPath::LAZY_ALLOC feature.
* This closes ticket #9625.
2017-04-30 17:37:17 +02:00
Axel Dörfler
e9843da357 KPath: Added LAZY_ALLOC flag.
* This allows KPath to not allocate a buffer when initialized
  without path.
* Added test cases for this.
* Added test for LockBuffer().
* Enhanced tests to allow building them in debug mode.
* Moved calling vfs_normalize_path() into own private method.
* Improved error codes; B_NO_MEMORY is now only returned if the
  allocation actually failed.
* If used with LAZY_ALLOC, Path() and LockBuffer() are now allowed
  to return a NULL path.
2017-04-30 17:14:45 +02:00
Axel Dörfler
f94671c33d KPath.Adopt(): Fixed path length.
* Issue was hidden due to inappropriate test values; changed test
  to uncover it.
2017-04-30 17:13:45 +02:00
Axel Dörfler
eac83fb33e KPath: Replaced booleans with flags field.
* No functional change intended; I chose the flags in a way that it
  should still work even if I missed a reference.
2017-04-30 17:13:39 +02:00
Axel Dörfler
e1b4aed0cb KPath: Fixed Normalize() return code, changed Leaf().
* Normalize() now returns the error code that vfs_normalize_path()
  returns.
* Leaf() now returns "" instead of "/" for the root. It's not used
  outside of KPath.
* Adapted RemoveLeaf() to deal with this correctly.
* "KPath = string" no longer changes the buffer size.
* Added missing operator tests for =, ==, and !=.
2017-04-30 17:13:33 +02:00
Axel Dörfler
4be518758d KPath.Adopt() fixed incorrect path/buffer length.
* The other object was left in an inconsistent state.
* This lets the unit test for Adopt() pass.
2017-04-29 19:03:16 +02:00
Axel Dörfler
3582d4fe85 Minor style cleanup. 2017-04-29 14:37:56 +02:00
Jessica Hamilton
10a1d9102e bootloader/efi: use B_PAGE_SIZE 2017-04-25 00:06:01 +00:00
Augustin Cavalier
17f5ac9149 libroot: Restore exit() call after debugger().
Thanks PulkoMandy for the review.
2017-04-14 18:29:29 -04:00
Augustin Cavalier
a5d208c7d6 libroot: abort() should behave like a crash, not just a 'failure' exit.
Calling debugger() means that the crash dialog will be shown, and so
users will not be left wondering why an app just spontenously disappeared.
2017-04-14 16:07:02 -04:00
Adrien Destugues
743088d40b Fix users of PAGE_SIZE
- Replaced by B_PAGE_SIZE where possible
- Enabled the _XOPEN_SOURCE feature define otherwise
2017-04-13 21:32:08 +02:00
Axel Dörfler
99ccb18d97 Kernel IOBuffer: Fixed potential memory leak.
* IOBuffer::FreeVirtualVecCookie() did not put the last physical page
  back. This was only an issue in case GetNextVirtualVec() wasn't
  iterated through the end, for example in case of an error.
* Fixed the condition when to put back a physical page; the current
  solution will also work with the generic page mapper implementation.
* This fixes the low hanging fruits of Ingo's comment in #5777.
2017-04-06 23:31:48 +02:00
Axel Dörfler
742b85c1f1 vfs: Let new_vnode() and publish_vnode() wait for busy vnodes.
* Both functions need to wait when encountering a busy vnode, in order
  not to create a race condition in combination with get_vnode().
* This should fix both #5262, and #9839.
* I did not implement Ingo's suggestion to burden the file systems with
  solving the problem for the following reasons:
  - I think the file system interface should be as simple as possible.
  - I can't think of a possible locking issue at least for BFS.
  - The solution on the file system side would look pretty similar to
    what the VFS already does or has to do (minus controlling the locking
    directly), so it would cause quite a functional duplication.
2017-04-02 14:30:45 +02:00
Alexander von Gluck IV
d8ce1a9fad x86/irq_routing: Convert panic into warning. Solves #13388
* Solves #13388 and likely a bunch of other bug reports.
* While this *is* an issue that can potentially be serious,
  there really isn't a risk of data loss or a system
  instability, only broken PCI devices. Show warning and
  keep going.
2017-03-20 14:10:14 -05:00
Alexander von Gluck IV
8eee7007cf x86/irq_routing: More tracing around fill_pci_info_for_entry 2017-03-19 17:44:11 -05:00
Alexander von Gluck IV
acdfec1189 x86/irq_routing: Improve trace information 2017-03-19 16:29:11 -05:00
Augustin Cavalier
59bdca5dd4 kernel/x86/arch_int: Style fixes.
Thanks Axel for the review.
2017-02-27 18:14:26 -05:00
Augustin Cavalier
0414166a29 kernel/x86/arch_int: Move cast after NULL check.
Spotted by Lioncash (via IRC). No functional change intended.
2017-02-25 15:28:25 -05:00
Lioncash
7c6caa8939 load_driver_settings: Add missing kernel_args_free() call to load_driver_settings_file()
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-02-25 15:16:07 -05:00
Jérôme Duval
85566e032d posix: add _POSIX_SEM_NSEMS_MAX.
* have _SC__SEM_NSEMS_MAX return _POSIX_SEM_NSEMS_MAX, a per team limit
instead of the global limit.
2017-02-21 20:17:16 +01:00
Jérôme Duval
0bec83a85a pthread: add const for pthread_mutex*_get*()
according to the spec. Fixes #13324.
* code style clean up.
2017-02-21 20:05:02 +01:00
Jérôme Duval
4f10ef40b9 pthread: check parameters for pthread_barrierattr_*pshared().
* fixes #13323.
2017-02-21 20:05:02 +01:00
Jérôme Duval
90acbbfecb pthread: have pthread_setschedparam return 0 on success.
* fixes #13299.
2017-02-14 20:48:43 +01:00
Augustin Cavalier
b6f76ebe71 s/OpenBeOS License/MIT License/ universally, as they're the same thing.
Fixes #8681.
2017-02-09 22:09:56 -05:00
Freeman Lou
aa3083e086 Style fixes to various parts of the system.
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

This patch was never applied after GSoC 2012. Rebase the parts that
still apply so we can close the ticket.

Fixes #9490.
2017-01-29 22:47:28 +01:00
Andrew Aldridge
f31b1a2faf Implement scrypt-based password hashing
Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
2017-01-17 23:09:04 +01:00
Jessica Hamilton
92b9c8649b MultibyteToWchar: correctly handle UTF-16 surrogate pairs.
* Whilst in WcharToMultibyte, we correctly convert our UTF-32
  wchar characters to multibyte, the same wasn't done in
  MultibyteToWchar. Now, if we detect a leading surrogate,
  we'll re-read the multibyte sequence with space for a UTF-16
  pair, which allows U16_GET to correctly convert the UTF-16
  byte sequence into the needed UTF-32 codepoint.

Fixes #13184.
2017-01-12 06:39:55 +13:00
Jessica Hamilton
d2423e4b3c ICUCtypeData.cpp: format string fixes for tracing. 2017-01-12 03:33:11 +13:00
Jessica Hamilton
079ab7f0b1 ICU add-on: validate mbState->converter before attempting to close.
This resolves crashes in gawk with multibyte support.

Fixes #12515, #13103.
2017-01-12 03:33:04 +13:00
Jessica Hamilton
3d870da3cb UEFI: leave runtime memory identity mapped.
* We don't have kernel/userspace access to UEFI at this point
  either, and with some firmware, if we don't keep the
  runtime memory identity mapped, then the loader dies. This
  will fix booting on such machines, and shouldn't have any
  impact on already working machines.
2017-01-08 21:43:53 +13:00
Jessica Hamilton
6b4cbec040 UEFI: identify the boot partition to check that it's valid.
* Also modified EFI::Header to return the efi_table_header so
  that we can compare it to boot device partition table.
2017-01-07 21:26:25 +13:00
Jessica Hamilton
42e718f041 UEFI: improve boot support in devices.cpp
* Maintain a list of all MESSAGING_DEVICE_PATH and
  MEDIA_DEVICE_PATH handles, so we can avoid adding devices
  multiple times.
* Split up platform_add_boot_device() into separate functions
  for better readability (add_cd_devices, add_boot_device_for_image,
  etc.).
2017-01-07 21:26:23 +13:00
Jessica Hamilton
35b38c392e loader: get_boot_file_system() iterate over all devices found.
* This is useful for UEFI, as we can then add the device that
  contains the UEFI loader, as well as all CD devices. As a
  result, if the device with the UEFI loader doesn't contain
  a bootable BFS partition, it will then attempt the same for
  CD devices.
2017-01-07 21:25:23 +13:00
Jessica Hamilton
445b080ea3 UEFI: support selecting video resolution & vesa settings file. 2017-01-07 15:39:35 +13:00
Fredrik Holmqvist
1d8306654a Rewrote device handling in EFI boot-loader
This allows me to find and boot disks and cds(*)
platform_add_boot_device tries to find the disk of the EFI partition
As on other platforms if boot disk isn't found platform_add_block_devices
will be called.
platform_add_block_devices will find all block devices that arn't partitions as
they are handled by Haiku already.
Currently first found suitable partition will be selected.

TODO:
 * pass in partition UUID's as boot-loader arg to setup boot for
any partition.
 * Better cd detection
 * Better disk_identifier

*) vfs_boot.cpp is very restrictive when it comes to booting cds.
It either do very Anyboot check where boot partition should be at offset 0,
which isn't true for EFI. In my case it's not even on that disk.
Or it only allow data session partition types.
This is currently failing as the Anyboot partition type is BFS.
2017-01-06 19:43:08 +01:00
Fredrik Holmqvist
57b59d47c5 memset was done twice 2017-01-06 19:39:58 +01:00
Murai Takashi
57db30a752 find_paths.cpp: fix memory leak
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

fixes #13136
2017-01-01 11:38:13 +01:00
Dmytro Shynkevych
0e0f49e799 libroot: Implemented pthread barriers
This is an implementation of pthread barriers pursuant to the relevant specification.

Barriers are essentially a special case of conditional variables,
such that all threads waiting on one are woken up when the number of
waiters reaches a number provided at the initialization of the barrier.
In view of that, this implementation mimics the implementation of pthread_cond,
except it is more specialized and self-contained.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2016-12-30 11:32:04 +01:00
Jessica Hamilton
d2e18d6462 efi/video.cpp: style fix. 2016-12-23 18:58:26 +13:00
Jessica Hamilton
4419d699ec partitioning: pass along reference to parent when uninitializing.
* Fixes problems with setting the partition name after uninitializing
  a partition in DriveSetup. Previously, UninitializeJob() was
  followed by SetStringJob(), but the kernel was updating the
  change counter for the parent partition when uninitializing a
  partition, leading to SetStringJob() having an incorrect change
  counter for the parent partition. Now the parent change counter
  will be correct when SetStringJob() runs.
2016-12-23 18:53:15 +13:00
Jessica Hamilton
4ff3f10852 UEFI: improve setting up of the framebuffer.
* Even if we get dropped into the boot menu, we still want
  to have the framebuffer enabled, else we never switch
  back into graphics mode.
2016-12-19 20:18:31 +13:00
Jérôme Duval
9969137ced fork(): Follow-up fix to 17b2a3cfc.
* Ingo rightly noticed that the defer_signals counter is reinitialized on
  thread's user area creation. Setting the flag THREAD_CREATION_FLAG_DEFER_SIGNALS
  indeed gives the expected behavior, deferring signals until undefer_signals() is
  called in the child thread. Thanks for the review and fix suggestion.
* Added a simple test showing the values of the defer_signals counter after fork().
2016-12-18 09:44:03 +01:00
Jessica Hamilton
941c240ab0 libroot/fork: fix gcc2 compilation. 2016-12-18 14:42:06 +13:00
Fredrik Holmqvist
9e487d8d74 UEFI: serial debugging support.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-12-18 14:41:54 +13:00
Jérôme Duval
17b2a3cfcb fork(): Defer signals and lock the heaps while _kern_fork().
* Also defer signals while registering fork hooks.
* While malloc provides fork heap hooks which lock the heaps and unlock/reinit,
  malloc_debug provides empty hooks.
* Ideas suggested by Ingo, patch reviewed by him. Thanks a lot!
* Also call fork parent hooks on failure.
* Solve locks-up when combining multithreading and process forking, should help
  with #13111.
2016-12-17 21:11:15 +01:00
Henry Harrington
e2b610b4b3 UEFI: CR0.WP must be set before entering the kernel.
If WP is not enabled then the kernel can freely write to read-only user
pages, which breaks copy-on-write.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-12-14 06:02:19 +13:00
Jessica Hamilton
b521a45ec2 Revert "vm: Try harder to allocate early physical pages."
This reverts commit 21e3ac6cf5,
which was accidentally applied twice, missed during rebase.

Originally applied in 601b2f7eda.
2016-12-13 22:24:12 +13:00
Jessica Hamilton
48494219eb Add a dumb framebuffer driver.
This is separate to the VESA driver, as the VESA driver requires
using the VBE BIOS. Under UEFI, we don't have the VBE BIOS, nor
are we able to switch modes after leaving UEFI Boot Services, so
a dumb framebuffer driver seemed like the easier way to approach
the problem.

The framebuffer & vesa drivers now test for the presence of the
VESA_MODES_BOOT_INFO boot item to distinguish between which driver
to use. Also added check for the VESA mode count to determine
whether to add the VESA_MODES_BOOT_INFO item.

UEFI video updated to explicitly zero out the VESA and EDID
boot data.
2016-12-13 21:41:10 +13:00
Michael Lotz
1f7e5bde38 kernel: Fix NULL dereference in ThreadTimeUserTimer::Schedule().
The SpinLocker was always initialized to fThread->time_lock even though
fThread may be NULL. This looks like a simple oversight as the rest of
the method handles fThread being NULL and the team variants of these
timers have very similar logic and do the NULL check as well.

This fixes the last remaining KDL in the posixtestsuite.
2016-12-12 11:55:06 +01:00
Jessica Hamilton
25fa3b1b8a loader: fix defines affecting elf.cpp for other platforms 2016-11-14 23:46:10 +13:00
Jessica Hamilton
04f0d02a8f Jamfiles: fix TARGET_BOOT_PLATFORM tests to use = efi 2016-11-14 23:45:22 +13:00
Jessica Hamilton
f4ff9cb02c Merge branch 'uefi-support' 2016-11-14 03:21:59 +13:00
Nick Smallbone
a99a0c003d EFI: add support for SMP.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 03:21:41 +13:00
Jessica Hamilton
ec239abcf5 EFI: implement mmu_map_physical_memory & mmu_free.
Also move cpu, acpi, hpet init into platform_start_kernel, as we
need an initialised heap for alllocating memory for recording
the mapped regions.
2016-11-14 03:21:41 +13:00
Jessica Hamilton
a7142a5037 EFI: add cpu.cpp from bios_ia32 2016-11-14 03:21:40 +13:00
Jessica Hamilton
a1d0102ee4 EFI: add support for HPET 2016-11-14 03:21:40 +13:00
Jessica Hamilton
6e6efaecdc EFI: add ACPI support
Also add support in the kernel to get the ACPI RSDP from the
bootloader, and pass onto the ACPI driver using get_boot_item.
2016-11-14 03:21:36 +13:00
Henry Harrington
82dcc31606 bootloader: Translate kernel args before adding them to kernel_args_range.
Chunks may be physically contiguous, but virtually disjoint. Adding
physical addresses may cause ranges to be merged incorrectly.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 01:00:00 +13:00
Henry Harrington
21e3ac6cf5 vm: Try harder to allocate early physical pages.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 01:00:00 +13:00
Henry Harrington
34a6dd6728 EFI: Initialize/load the GDT.
Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 00:59:59 +13:00
Henry Harrington
b3215a6275 EFI: preliminary support for starting the kernel.
Enough to let the kernel to print hello, but not much beyond that.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-11-14 00:59:56 +13:00
Jérôme Duval
33e68be479 Update libroot stubs. 2016-11-01 08:44:04 +01:00
Adrien Destugues
b5c858aa75 strptime: allow dates before 1900.
While struct tm makes things more confusing than they need to be,
nothing in the API prevents handling those. So let's just accept them.

Fixes some strange cases in the cookie test suite (with a cookie set to
expire in year 101 B.C.)
2016-10-30 20:23:43 +01:00
Adrien Destugues
4bc43f4368 style fix. 2016-10-30 09:17:00 +01:00
Jérôme Duval
58fb6344ae libroot: getlogin_r(): 32 is a valid length.
* also use LOGIN_NAME_MAX for the max length.
2016-10-29 22:39:32 +02:00
Adrien Destugues
61987fe7a2 runtime_loader: allow the ABI version symbol to be local.
Some libraries buildsystems (eg. zlib) somehow prevent the symbol from
being exported. We should fix that, but binaries with missing symbols
are already out there, so we need to handle them in any case.
2016-10-29 10:16:29 +02:00
Adrien Destugues
09c4bc5bd3 runtime_loader: fix getting ABI from gcc .comment
The format for the .comment string changed at some point, and this
fallback code would always fail for files built only with "new" versions
of gcc.

Also consider gcc 5 to be ABI version 4, since it is still compatible
with the old ABI (and provides a new one side by side).

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
for infos on GCC ABI changes in GCC 5.
2016-10-23 22:23:06 +02:00
Ulrich Drepper
d2bd05420a glibc: (_IO_cleanup): Do not use locking when flushing ...
the buffers. Some thread might be using a stream.
2016-10-23 20:30:45 +02:00
François Revol
b1e2427d75 glibc: replace extern __inline with __extern_always_inline for ppc
As was done for x86 in hrev49774.
2016-10-22 15:53:57 +02:00
François Revol
72ddc912a6 PPC: make arch_framebuffer.h more like ARM version
Now the only difference is the physical address, which is returned as
phys_addr_t as should be.
2016-10-22 15:53:52 +02:00
François Revol
f4dc609dbe U-Boot: PPC: dump the start of the board_data struct
Not so useful but just in case...

Sadly, this struct is both compile-time and arch dependent :-(
2016-10-22 15:53:47 +02:00
François Revol
9e66f03165 U-Boot: PPC: Try to enable unaligned transfers
This however doesn't help with the 64bit float operations that
gcc emits when assigning the physical framebuffer address in kernel_args,
which is a packed struct...
2016-10-22 15:53:38 +02:00
François Revol
e57c83d9e4 U-Boot: PPC: make the shift calculation more obvious
It's the 11th bit, counting from the MSB, on the top 16 bits.
2016-10-22 15:53:24 +02:00
François Revol
1fe7e6711f PPC: call debug_uart_from_fdt with C++ linkage 2016-10-22 15:53:20 +02:00
François Revol
11642b7f2c PPC: arch_asm.S: style fix
Capitalize TODO & FIXME, gedit prefers those
2016-10-22 15:53:15 +02:00
François Revol
33c594f0c7 PPC: U-Boot: fix gUBootOS offset
Since the removal of some other variables we were overwriting some random function.
2016-10-22 15:53:07 +02:00
François Revol
ffb9ffb68d PPC: Use FUNCTION_END in arch_asm.S 2016-10-22 15:52:51 +02:00
François Revol
9d0098ec04 ppc/paging: Convert to new-style CPU management
* Aka, post-scheduler changes
* Luckily PPC paging code is very similar to x86 paging now
2016-10-22 15:52:46 +02:00
François Revol
f5f6d7e600 PPC: compile arch_exception*.S in cpu-specific objects 2016-10-22 15:52:38 +02:00
François Revol
8dc55498fa PPC: rename arch_exceptions_44x.S to arch_exceptions_440.S 2016-10-22 15:52:29 +02:00
François Revol
094525151d PPC: Split cpu-specific files into separate objects 2016-10-22 15:52:16 +02:00
François Revol
d66182742f PPC: Stub out 460 paging classes 2016-10-22 15:52:08 +02:00
François Revol
62caef87ce PPC: Restructure paging stuff to match other platforms
First attempt.

Totally untested.
2016-10-22 15:51:57 +02:00
Julian Harnath
b2ef1767a7 x86 kernel stack trace: make sure memcpy stays in bounds
* Commit 337c4ccf introduced usage of plain memcpy in
  get_next_frame_no_debugger(), when the frame is already
  known to be on the kernel stack. However, it also needs
  to check that the end of the frame is still within the
  stack bounds. Otherwise this can cause a KDL if bp does
  not point to a valid complete frame anymore and is
  near a page boundary. Although with commit e477b10c such
  cases should already be avoided, it's still safer to
  check this here in case of e.g. analyzing broken stacks.
2016-10-17 22:27:04 +02:00
Julian Harnath
e477b10cef x86 kernel stack trace: break when return address is zero
* No need to continue walking the stack when a zero return
  address is found, only bogus frames will follow

* Fixes KDLs seen when using the system profiler, due to
  a bug that will be fixed in the next commit...
2016-10-17 22:26:02 +02:00
Andreas Faerber
51777fe86c Revert r25895: Undo ppc linkhack workaround #6210 2016-10-16 12:52:02 -05:00
Jérôme Duval
e340f717a4 runtime_loader: add support for ELF init/term routine arrays.
* binutils 2.27 defaults to DT_INIT_ARRAY instead of DT_INIT.
2016-10-11 22:26:06 +02:00
Sergei Reznikov
766191919d Added stub for get_nth_pci_info.
BeRometer works now.

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

This is a private API, but some apps used it anyway. We don't need a
complete implementation to at least make BeRoMeter run.

Fixes #5146.
2016-09-26 21:44:21 +02:00
Adrien Destugues
ed1b81b72b Boot loader VFS: fix string termination error.
The code was resetting the pointer to NULL, instead of setting the
pointed char to null-terminate the string. The result was resolving the
current directory later on, instead of the parent as requested.

This only happened when calling open_from with O_CREAT, and a name with
sub-directories inside it. The boot loader never does that, so the code
wasn't used until now.

Fixes #12941.

Thanks to mt for spotting the problem.
2016-09-17 11:15:00 +02:00
Jessica Hamilton
2da1cb75a4 EFI: device support for anyboot CDs.
I have tried to get normal ISOs working, but the bootloader doesn't
seem to detect any bootable partitions.
2016-09-03 01:58:41 +12:00
Jessica Hamilton
325b1e3787 EFI: add support for graphics mode output
* We can now switch between graphics and text modes, and display
  the splash screen
2016-09-02 19:02:35 +12:00
Jessica Hamilton
dbf1363b41 EFI: naive platform_allocate_region() implementation 2016-09-02 19:02:35 +12:00
Jessica Hamilton
96f4d68b2b EFI: check for boot keys
* Only supports spacebar for the boot menu, and escape for
  enabling debug output. Shift keys will not work.
2016-09-02 19:02:34 +12:00
Jessica Hamilton
c0bdc8bef5 bootloader: build objects in $(TARGET_BOOT_PLATFORM)
This separates the objects required for the various boot
loaders, allowing the build system to be able to build
for different targets alongside each other. Currently
only done for bios_ia32 vs efi, as both loaders will be
needed for the x86_64 images.
2016-09-02 19:02:34 +12:00
Jessica Hamilton
c0002a79e7 EFI: Implement heap 2016-09-02 19:02:33 +12:00
Jessica Hamilton
e2e1558a02 EFI: stub functions so we can call loader's main() function. 2016-09-02 19:02:33 +12:00
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