Commit Graph

10212 Commits

Author SHA1 Message Date
Augustin Cavalier
9708b08060 KPath: Use a default buffer size of B_PATH_NAME_LENGTH without + 1.
B_PATH_NAME_LENGTH == PATH_MAX, and PATH_MAX is inclusive of the final
NULL terminator, so we don't need a + 1 here.

The original KPath default was to not use + 1, but that was changed in
42e3c6f978 due to all the consumers that did.

But all those consumers are wrong, it appears; they should just be
using the default length instead. So now we do that.
2024-11-22 16:56:15 -05:00
Augustin Cavalier
cc9ea55c59 file_systems/QueryParser: Coerce types up front, and handle B_TIME_TYPE better.
* If we coerce types inside the switch(), then the "type already converted"
   check at the beginning will fail every time, causing us to reconvert,
   which is surely bad for performance.

 * B_TIME_TYPE should be INT32 or INT64 depending on what its size is.

May help with #19080.
2024-11-21 23:19:09 -05:00
Jérôme Duval
fbdac8d61e headers: Don't define static_assert for C23 and C++
Change-Id: I1e67b09b2a310de5cf41c4eef9af46f78b4e9de0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8586
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-21 19:26:51 +00:00
Augustin Cavalier
f72d1684e5 kernel/debug: Initialize the frame buffer console much earlier, if possible.
Previously it was not initialized until "post-VM", but there are
a number of ways VM initialization can go wrong that it would
be nice to know about without needing a serial port.

On arches which map the whole physical memory into the kernel
address space (x86_64, at least), we can get the bluescreen facility
initialized using KERNEL_PMAP_BASE. On other architectures, we
just fail to init then, and do the usual setup later on.

A slight bit of extra code cleanup in blue_screen_init_early:
we now just call module->info.std_ops() rather than a
frame-buffer-console specific method.
2024-11-19 21:35:31 -05:00
Augustin Cavalier
a9b5f684f1 kernel/fs: Make io_context rw_lock'ed.
Applications that don't call open() or like functions too often,
and call many FD-related methods across multiple threads at once
(like "git status") now don't wait on the context lock as much.

("git status" performance isn't much improved because threads just
hit the "unused vnodes" lock instead.)
2024-11-18 13:25:43 -05:00
PulkoMandy
344ded80d4 ioctl: Document in Haiku book and in comments
- Convert libroot from a page to a group, so that it can list the
  included file and functions in the generated book (like the kits)
- Add unistd.dox and move the relevant part of ioctl details there
- Make sure to use C89-compatible comments only in POSIX headers

Change-Id: I8f0412e4c75de6f48018a0436909f8b0076342a4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6369
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-11-18 17:12:04 +00:00
Gustaf Alhäll
b08fdcde6f PadBlocker: Avoid blocking non-trackpad devices
Exposes a new field on mouse events named "device" that specifices what
type of device the event originates from. This is then used in
PadBlocker to ignore events that don't originate from trackpads.

This field should also be exposed to the public API in case any program
in userspace want to use it, as it may be useful for other purposes.

Fixes #19238 and #17821

Change-Id: Ic0f8c088cf5d2b0414a8e69498b48f2a3e370d73
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8557
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-18 16:45:04 +00:00
PulkoMandy
d05ff048a2 uvc_webcam: use shared USB_video.h
The driver had its own header file with definitions from the USB video
specification. Use the system ones already in place for use in listusb.

Also recognize devices which advertise themselves as "miscellaneous" in
the device descriptor, this is the recommended way in the specification
as the usb_video interface may be only part of a device, with other
interfaces and endpoints used for audio or for HID for example.

Change-Id: I7e2e45328dcc1e81c407937e8dd3d77209c5c52a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8581
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-18 16:44:46 +00:00
Jim906
9bb1816c14 block_cache: enable prefetching
* Allocate blocks and add them to the hash table so they are
  available for a future block_cache_get call.
* Make use of prefetching in FAT driver.
* A client filesystem may request to prefetch a block run that
  contains some blocks that are already cached.  The request will
  be truncated at the first such block in the run.
* Fixes #19186.

Change-Id: I8d2e3cff15e5b46569438e0dc085e2b391aa57a5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8525
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-16 18:26:21 +00:00
Augustin Cavalier
de8d5cfb5f bootloader & kernel: Unify computation of splash logo and icons placement.
Removes some more code duplication.

Change-Id: I9423be740015bef996b77bf2c30652fdadbd8a50
2024-11-12 23:51:52 -05:00
Augustin Cavalier
029e447bde bootloader & kernel: Unify bitmap blitting routines.
They were more-or-less duplicated between the two.
2024-11-12 23:44:31 -05:00
Augustin Cavalier
e4efb705e4 libroot: Add parentheses around third argument of ioctl.
So that the cast applies to the right part in case an expression
is passed.
2024-11-11 13:39:25 -05:00
Augustin Cavalier
bbb069a1a7 libroot: Use use variable argument count macro for ioctl.
Based on X512's original change, but with more modifications:

 * Don't use _ in macro parameter names to appease GCC 2.

 * Get rid of ioctl_args struct. We don't need it anymore,
   and just adding parameters of the same types has the
   exact same ABI on x86 and x86_64, so this doesn't break
   any existing compiled code.

 * Add (void*) cast to third parameter.

 * Enable for _KERNEL_MODE also.

Change-Id: Id4ad8b85f54836fd26dc6278226954d0a081d5f0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8533
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-11 18:29:58 +00:00
X512
8776466030 BRect: add 2 argument width, height constructor
Left top position will be set to zero.

It is a common pattern to define `BRect` value with only width and height so it allow to simplify code a bit.

Change-Id: Ie14644843324c9e5bcc55e7cfbd557a8884559d3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8535
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-11 16:56:19 +00:00
X512
2b0aa4245b BShape: use BShape::Private class to access private methods.
Avoid declaring random friend classes in public header. Allow to access
private methods from arbitrary source if needed.

Change-Id: Iac2cf0ca59e483aa0657e3fe1fc47080c661cf8b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8534
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-11 16:56:19 +00:00
X512
e892302909 BShape: add move construction and assignment support
GCC 2 support is also provided with `MoveFrom` method.

Change-Id: Ifedaf0b1406a5a2cb6bf3465249cea0f360e06d6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8531
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-11 16:56:19 +00:00
X512
80fcf2df19 BRegion: add move construction and assignment support
GCC 2 support is also provided with `MoveFrom` method.

Change-Id: Ibd062f501fdeb5538ade6c84dcafb61cff70cc32
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8529
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-11 16:56:19 +00:00
X512
4bfc14b6c7 libroot: add posix_devctl() from POSIX.1-2024
Change-Id: I2ae748b2febcdeca0256e9033119dcf9988ccc74
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8556
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2024-11-10 20:08:54 +00:00
Augustin Cavalier
14744074dd Revert "unistd.h: Add cast to (void*) for first argument in C mode."
This reverts commit c4497fa258.

Breaks 2-argument ioctl, it seems.
2024-11-05 22:03:58 -05:00
Augustin Cavalier
36708e6ab8 network: Let modules process all ancillary data at once, and adjust UNIX.
This way, modules can decide to do different things based on having
all the ancillary data available. In particular, the UNIX module will
now post only one message header for all the FDs, even if they came
from multiple sets of ancillary data.

This should fix "Message needs unreceived descriptors" from the Chromium
IPC code (which is used by Firefox).
2024-11-05 15:23:24 -05:00
Augustin Cavalier
6e1bd12f74 locked_pool: Delete.
The SCSI module was the only thing using it, and now it isn't
used at all.
2024-11-05 14:05:04 -05:00
Augustin Cavalier
e9c9b2e448 kernel/condition_variable: Make the debug type fetcher a static function.
No behavioral change intended.
2024-11-05 13:46:53 -05:00
Augustin Cavalier
7746364088 SCSI: Use an object_cache for the CCB pool.
Same as for the scatter/gather pool. This also changes CCBs
to use condition variables instead of semaphores for completion,
which means they're now C++-only. A few C files still include
<SCSI.h>, but none use CCBs directly, so this works out fine.

A quick check with a compile benchmark didn't show a performance regression.
2024-11-05 13:43:48 -05:00
Augustin Cavalier
6101e74932 SCSI: Remove unused sim_priv fields.
Whatever "compatibility layer" these were for, nothing in-tree
uses them anymore.
2024-11-04 15:14:47 -05:00
Jérôme Duval
7190c0f117 libroot: add tcgetwinsize() and tcsetwinsize() for POSIX.1/2024
Change-Id: I46c0b7b5b9c8e7c74278a6e10e9b83142db21d94
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8520
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Jérôme Duval
7a4e12b7b8 libroot: add ptsname_r for POSIX.1/2024
Change-Id: I9996ff998b2b52a65a101cf7075a3ffb37220962
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8519
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Jérôme Duval
8b5cc9cf52 libroot: move memmem for POSIX.1/2024
Change-Id: I1b051586c993cd0e3d43abaa22a3722699f7134e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8517
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Jérôme Duval
6beff0d163 kernel/libnetwork: add accept4() from POSIX.1/2024
* add SOCK_NONBLOCK and SOCK_CLOEXEC
* also extends the type parameter on socketpair() and socket()

Change-Id: I73570d5bfb57c2da00c1086149c9f07547ba61ce
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8515
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Jérôme Duval
966076b273 kernel/libroot: add dup3() from POSIX.1-2024
this adds a parameter to the dup2 syscall. Adjust strace.

Change-Id: Icc2d0e054365865d38e5d596843a47c95100ca59
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8514
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-04 17:55:40 +00:00
Jérôme Duval
11cd4af6e1 kernel/libroot: add pipe2() from POSIX.1-2024
this adds a parameter to the create_pipe syscall. Adjust strace.

Change-Id: I83e9f039eb28c862458654b66c03e2e21a258822
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8513
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-04 17:55:40 +00:00
Jérôme Duval
30179dd326 libroot: add reallocarray() from POSIX.1-2024
Change-Id: I75d469ad9a01eb221ca607830589a7794eff71e8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8512
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-04 17:55:40 +00:00
Augustin Cavalier
7ee61327ce sys/select.h: Cleanup.
* Always declare FD_SET rather than conditionally. This matches
   the behavior of the glibc, musl, FreeBSD headers.

 * Simplify comments.

 * Leave the custom FD_SETSIZE possibility in place for now. Neither
   glibc nor musl permit this, but FreeBSD still does.
2024-11-01 23:29:22 -04:00
John Scipione
406f30c616 Tracker: Commands.h (and tracker_private.h) updates
* Add kDeleteSelection command alias in Commands.h, keep kDelete.
* Add kMoveSelectionToTrash and use it in place of kMoveToTrash.
  - kMoveToTrash in kept in tracker_private.h for use outside.
* Create a new constant kRestoreSelectionFromTrash for Tracker.
  - Move kRestoreFromTrash to tracker_private.h

Change-Id: I3cdefe97e8359fb53bacfc3319b046b051c6f7db
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8225
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-10-17 16:21:51 +00:00
Augustin Cavalier
8fbb862695 fs_shell: Adjust following block_cache API change. 2024-10-17 12:15:11 -04:00
Augustin Cavalier
16ecdb595b kernel: Drop base, length parameters from block_cache...etc methods.
They were ignored and unused; and in fact can't be made to work
properly since the block_cache always operates on exactly block-sized
buffers, and doesn't have contiguous buffers of multiple blocks
to hand out at all.

No functional change intended.
2024-10-17 12:05:22 -04:00
Augustin Cavalier
086f997e50 kernel/vm: Move most kernel debugger routines to a new vm_debug.cpp.
Reduces the size of vm.cpp by over 800 lines.
No behavioral change intended.
2024-10-16 14:43:20 -04:00
Augustin Cavalier
0a5c9ef0a4 kernel: Move get_mount_point from VMUtils to KPartition.
There's nothing VM-specific about it; it just builds paths
that partitions should be mounted at.

Also move the tests.
2024-10-16 14:25:17 -04:00
Augustin Cavalier
5f87420792 kernel: Add maxAddress constraint to vm_allocate_early_physical_page.
Needed by the x86 PAE code.

Change-Id: I982dfa96427addfc903205f49f53a46462534843
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8457
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-10-16 16:17:13 +00:00
Greg Crain
8251b2c8f6 usb_audio: add missing descriptors for USB Audio 2.0 and update listusb.
Change-Id: Ic294ca78aaf9bd5ac8476595af5e4e223b07e25e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8372
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-10-14 18:16:10 +00:00
Augustin Cavalier
8bacd281ba sys/param.h: Cleanup.
* Minor tweaks to POSIX sys/param.h for style.

 * Don't redefine alignment macros in BSD sys/param.h even conditionally.
   And add a few more macros from the real BSD sys/param.h, for convenience.
   (Most of these are also declared in musl and glibc's sys/param.h)
2024-10-14 13:53:54 -04:00
Augustin Cavalier
e5f515c322 sys/select.h: Remove howmany() macros.
These aren't defined or used in this header under glibc or musl,
and after the previous commit, aren't needed in the kernel either.
2024-10-14 13:53:52 -04:00
Augustin Cavalier
916e681ca5 kernel.h: Add a HOWMANY macro and make use of it. 2024-10-14 13:53:50 -04:00
Augustin Cavalier
8f383fa10e ftw.h: Remove unneeded #include <features.h>. 2024-10-14 13:53:48 -04:00
Augustin Cavalier
50496cd3da BReferenceable: CountReferences() needs to use atomic_get. 2024-10-11 10:22:37 -04:00
Augustin Cavalier
875b13d582 bootloader: Overhaul heap region allocation.
Previously, there was only platform_init_heap/platform_release_heap,
which allocated a single static heap region for the heap to use,
and any subsequent heap allocations had to go through the standard
platform_allocate_region, which allocates regions visible both
to the bootloader and the kernel.

But as mentioned in previous changes, it isn't always easy to
release regions allocated that way. And besides, some bootloaders
(like EFI) use a completely separate mechanism to allocate
bootloader-local memory, which will never get "leaked" into
the kernel.

So instead, refactor all platforms to instead provide two
new methods: platform_{allocate,free}_heap_region. On EFI
this is easy to implement; on most other platforms we have
logic based more on the old platform_init_heap or allocate_region.

(On the BIOS loader in particular, we can only fully release
the memory if it's the last thing we allocated in the physical
addresses. If the "large allocation" threshhold is lowered
back to 16 KB, then we are unable to do this enough times
that we will run past the end of the 8 MB identity map and
thus fail to boot. But with the larger threshhold, we don't
leak nearly as much, and don't hit the threshhold.)

This should further reduce the amount of bootloader memory
permanently "leaked" into the kernel's used memory, though
on some platforms it may still be nonzero.

Change-Id: I5b2257fc5a425c024f298291f1401a26ea246383
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8440
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-10-10 16:13:11 +00:00
Augustin Cavalier
d1ef184af6 bootloader: Add remove_{physical|virtual}_allocated_range methods.
Will be used in following commits.

Change-Id: Ica89d28cbf6980aca8dc347dfdcb200a0e637e9a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8442
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-10-10 16:13:11 +00:00
Augustin Cavalier
1db0961121 kernel/vm: Remove an obsolete comment.
page_num_t is typedef'd to phys_addr_t, so it's 64-bits on 32-bit
platforms with PAE. In fact it's been so since the introduction
of phys_addr_t, so this comment was obsolete from the start...
2024-10-10 11:20:20 -04:00
Owen Anderson
df59dfec3b arm64: Set MMU granule sizes to a consistent value in bootloader.
Change-Id: Ia36885df6dec5ac0ac9ce41271115aa7a8c3e6df
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8418
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-09-30 15:48:51 +00:00
Owen Anderson
1fa60a5cda arm64: Fix TLB flushing in interrupts to handle kernel vs user space
Change-Id: Id19236345cf05284c8c5f02360a4a2b3f22fd16d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8365
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-09-30 15:48:51 +00:00
Augustin Cavalier
b28ed9e04a HaikuConfig: Don't define __HAIKU_BEOS_COMPATIBLE_TYPES in kernel mode.
This breaks kernel C++ ABI.

This mostly just changes the definition (not the size) of string types,
but in at least one case (daddr_t) it does change the size (from 32-
to 64-bit.)
2024-09-24 12:10:35 -04:00