Commit Graph
37 Commits
Author SHA1 Message Date
Sam Roberts 6db74d85be efi: Base framebuffer info on selected video mode
Fixes regression introduced in c216360337
where the framebuffer info passed to the kernel came from
whatever video mode was highest numbered, rather than what
was actually selected.

Should fix #20161

Change-Id: I06c800bd8e941ed7f6b20998c1ff66cd6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11197
Reviewed-by: waddlesplash <[email protected]>
2026-06-30 02:02:43 +00:00
Sam Roberts 6a3298c918 BStringList: Invoke qsort_r with different argument order on macOS
Change-Id: I542be695bf42827f0ac8fde403bcbb5c6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11147
Reviewed-by: waddlesplash <[email protected]>
2026-06-17 18:02:41 +00:00
Sam Roberts c1bea23ef3 arm64: Correct MaxPagesNeededToMap computation
This would underestimate the number of pages needed to map an address
range resulting in too-small page table page reservations, causing a crash

Change-Id: I34513621b36ecd60de71e128912950b66a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11129
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-06-17 18:01:51 +00:00
Sam Roberts 1938377e5d arm64: Synchronize icache when mapping pages & changing page protection
Change-Id: Ib11b46fa0003e6a3a68154b8109c5d6a6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11125
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2026-06-17 18:01:51 +00:00
Sam Roberts dad765a43b arm64: Track per-cpu MPIDR in arch_cpu_info
Apple's interrupt controller needs to know the MPIDR of the
CPU you want to send an ICI to

Change-Id: I81d1c25d5977140aaa4349fa83b7235e6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11124
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-06-17 18:01:51 +00:00
Sam Roberts c216360337 kernel/interface: 30-bit RGB pixel format support
On Apple ARM platforms, iBoot sets up a 30-bit framebuffer

Change-Id: I6c03937303a3363fde511c8b8b7f8fd66a6a6965
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11128
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-06-17 18:01:51 +00:00
Sam Roberts 26b5e6d4a1 acpi: Initialize embedded controller from ECDT
Some systems need embedded controller access during their _INIs,
so we need to use the ECDT to initialize the embedded controller
during ACPI init.

Since we can now initialize the EC during ACPI module init, we can't go through
the ACPI module anymore, and instead call its functions directly

This should fix
"KERN: ACPI Error: Region EmbeddedControl (ID=3) has no handler"
seen in a few ACPI-related tickets, including:
#19602, #19407, #18864

Change-Id: Ia648ee8036b68416ed1ca1c51dd1daea6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11058
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-06-03 09:35:23 +00:00
Sam Roberts 700dc49d83 boot/efi: Do not allow insert_physical_allocated_range to fail
Change-Id: Id10b81ae869b62bf94ace3a9f2482e076a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11051
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-06-02 07:44:24 +00:00
Sam Roberts ce692ecc03 intel_extreme: Clear all framebuffer tile mode bits
Some newer architecture added Y tiling

Maybe fixes #17688

Change-Id: I048c2523b8a804e53752f12cfed436616a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11027
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-05-28 12:20:19 +00:00
Sam Roberts 588830e92d acpi: Always read EC_DATA after burst enable command
It's possible for the EC to disable burst mode (maybe because
we're taking too long and it's impatient) before we check 
the status register to see if burst mode is enabled. If that
happens, we consider the burst enable command to have failed,
even though it succeeded and put EC_BURST_ACK in the data register.
So, the next time we read the data register for a subsequent
command, we'll read that EC_BURST_ACK.

This fixes ACPI battery & shutdown on 2015 MacBook Pro

Change-Id: I49711b224fee027e28825674d9c845bf6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11019
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-05-27 16:48:18 +00:00
Sam Roberts f6d3a6f6c7 intel_extreme: Disable framebuffer tiling
On some Intel MacBooks, system firmware configures the framebuffer
as X-tiled and uses the "Graphics Memory Fence Table Register"s to
transparently convert linear framebuffer accesses by the CPU to tiled
accesses. If you change the framebuffer base address or stride, you get
a garbled display since the "fence" configuration no longer matches
the framebuffer.

Might fix #17688

Change-Id: Iaf9ea7641f7809acb9b8fbf14b88ed656a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11016
Reviewed-by: Adrien Destugues <[email protected]>
2026-05-25 18:01:29 +00:00
Sam Roberts 1ca6acfaf9 arm64: SMP & CPU startup improvements
- Add more secondary CPU startup methods:
  PSCI using EL3 secure monitor calls (used on most ARM64 CPUs)
  Spin tables (used on Apple CPUs, which lack EL3)
- Secondary startup code was rewritten to pass all needed info
  to secondaries using static variables, since we can't
  pass any info to secondaries when using spin tables
- Setup MMU state to known good values as early as possible
  instead of relying on the values set by the bootloader.

  This also requires generating new page tables, since we're
  (potentially) changing MAIR as well as the address space sizes
  (which determine the number of page table levels we need)

Change-Id: I3b90aab04090fa0c6a8ad82a01df7fee6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10984
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-05-18 15:36:55 +00:00
Sam Roberts f76d1033cc arm64: GICv2 fixes for booting on Pi 5
- GICv2 _PerCpuInit and _EnableInterrupt were called twice,
  before and within the call_all_cpus_sync
- GICv2 addresses were truncated to 32-bits
- Add "arm,gic-400" compatible

Change-Id: I34d62cb77f7ac002459c931ac750c8306a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10983
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-05-18 15:36:55 +00:00
Sam Roberts 1fe7ef443c arm64: Don't truncate result of arch_mmu_generate_post_efi_tables
Change-Id: I5a8ba6bc21f1cfa31ca3c3b20f0e5a2b6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10819
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-04-16 15:48:06 +00:00
Sam Roberts 1c9ceae42a arm64: Handle PC alignment fault
Change-Id: I7ab88356c6b0cd0ee029317a0bba65596a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10818
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-16 15:48:06 +00:00
Sam Roberts 115b33ee3f arm64: Use the same system_time for kernel and userspace
The kernel version previously differed from the userspace
version by sBootTime, which causes issues including:
- configure scripts thinking the build environment is broken
- an sBootTime-long delay between the desktop appearing 
  and the user gaining control
- apparent time travel

Change-Id: I8e616772631df1c40958db4f23b10cbe6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10808
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-04-13 23:48:58 +00:00
Sam Roberts 8eea980706 arm64: System info fixes
* Implement arch_fill_topology_node
* Change uname to return 'arm64' in utsname.machine instead 
  of 'aarch64' to match what is used for packages (otherwise,
  on startup, package daemon thinks every package has the
  wrong architecture)

Change-Id: Ibba8784fca826023e0e13fef4222bdba6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10684
Reviewed-by: waddlesplash <[email protected]>
2026-04-07 20:44:44 +00:00
Sam Roberts bf61d8be93 arm64: Move kernel sp back to the top when entering userspace
When we exec, we push 2 iframes to the kernel stack: the one in
EXCEPTION_ENTRY, and the one in arch_thread_enter_userspace.
EXCEPTION_RETURN only pops one of these back off, so every time
we would exec, we were permanently reducing a thread's kernel stack
pointer, which would eventually lead to the kernel stack
overflowing.

Also, some redundant zeroing of registers in _eret_with_iframe
was removed.

Change-Id: I1e3e33f08bd05a3876f00d94cccb35fa6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10683
Reviewed-by: waddlesplash <[email protected]>
2026-04-07 20:44:44 +00:00
Sam Roberts 00b9933841 efi/arm64: Don't bail out when mapping TTBR1 in map_range
mingw EDK2 gives us a memory map containing a one-page-long
entry that happens to be TTBR1. Because we were bailing out
in map_range, we couldn't update that page after entering
the kernel

Change-Id: Ie38fc593da268ab2a1f3ca98f3bffce36a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10658
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2026-04-04 20:26:46 +00:00
Sam Roberts 777cfcfb8b arm64: PSCI+GICv2 SMP support
* SCTLR register definitions made 64-bit
* isb added after writing to SCTLR, to ensure we don't execute
  instructions requiring the MMU prior to the MMU being enabled
* GICv2 has per-cpu registers for IRQs < 32, so enabling or
  disabling those IRQs needs to be done on all cores
* MMU setup code in kernel and bootloader made per-cpu
* Signiture of arch_smp_boot_other_cpus is now the same on all
  architectures, with an addr_t page table

Change-Id: I13bef7ca4efc5504d643833664560a9a6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10649
Reviewed-by: waddlesplash <[email protected]>
2026-04-04 20:26:46 +00:00
Sam Roberts f8895f962c libroot/arm64: Don't change jmp_buf pointer in setjmp & longjmp
Previously, we would increment the jmp_buf pointer in x0
while storing registers and then pass that adjusted pointer
to __setjmp_save_sigs, which would clobber whatever
happened to be after the jmp_buf

Change-Id: I5c466dbc6aa4fa9c69535ad5a5044af46a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10642
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-31 17:03:40 +00:00
Sam Roberts bace3a82c5 arm64: Handle signals after all types of interrupts
This is what other architectures do :)

Previously, we only handled signals after system 
calls, which could result in a funny sequence of events:
- Thread gets spawned with spawn_thread
- Thread gets resumed with resume_thread, which sends
  SIGNAL_CONTINUE_THREAD
- Thread's very first syscall is a read(), which promptly
  gets interrupted by SIGNAL_CONTINUE_THREAD and the thread
  has no idea why, and doesn't bother to read() again since
  it never expected to receive a signal
^^^ PtyReader fell victim to this and Terminal was broken

Change-Id: I32c4c73be21c60cab97add2bb7052dc56a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10608
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-30 22:16:51 +00:00
Sam Roberts 6e590a51a2 arm64: Miscellaneous kernel fixes
* Ensure some bits in TCR have known values, since the bootloader
  might have configured something weird which causes problems for us
  (such as configuring a virtual address space that's smaller than
  we expect).
* ==NULL check in VMSAv8TranslationMap::UnmapPage was backwards
* Don't receive the number of syscall parameters from userspace. We were
  previously reading twice as many arguments as needed when handling
  a syscall.
* Save FP/SIMD registers as early as possible, since we can't know when
  they might get used
* Reset iframe stack index to 0 upon arch_thread_enter_userspace.
  Otherwise, when we exec, we push an iframe and never pop it off
  again

Change-Id: I4bc7dcc9303b9103a97226cd7ece4c9b6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10607
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:16:51 +00:00
Sam Roberts e78a97d381 arm64: Add timekeeping
Change-Id: Idc64a00e4dcc787e35afc560acd06a606a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10606
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:16:51 +00:00
Sam Roberts 1b4044fde1 arm64: Add signal handling and forking
Change-Id: I8fd41bf5c540bcb2b9347aae47ad8bb86a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10605
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-30 22:16:51 +00:00
Sam Roberts 7981c1d1c7 arm64: Add runtime_loader support + TLS
Change-Id: Ic462c6b08e6949039457e6141c83468e6a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10604
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-30 22:16:51 +00:00
Sam Roberts f833d107c6 arm64/uart_samsung: Don't do anything in InitPort
* It was actually disabling the UART
* I forgot this was C++ and not Rust and put a ! instead of
  a ~, so this wasn't doing what I intended anyway

Change-Id: I0b7c3d44f3e041cc70cb933ccba886346a6a6964
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10548
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-19 15:33:11 +00:00
Sam Roberts 593f25d6f1 arm64: Fixes for booting in EL2 w/ E2H
* E2H (EL2 Host) is enabled by default and usually can't be disabled
  on CPUs with FEAT_VHE. Since EL2 becomes a superset of EL1 with
  E2H, we can simply do nothing and everything that expects EL1
  will Just Work
* Changed some register bits numbers to avoid C integer promotion
  issues
* sEmptyTable needs to be filled in earler, before the kernel team
  is created. Otherwise, we put the uninitialized value of sEmptyTable
  in TTBR0, which immediately pends SError on Apple M1

Change-Id: I84ff7fd9134448f27315dadfd12bdd9df8c75b10
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10547
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-19 15:33:11 +00:00
Sam Roberts 13abea7517 arm64: Map only physical memory in memory map
On Apple platforms, there are regions of memory not mentioned in
the memory map that are protected by the system. If the MMU
happens to encounter one of these regions while performing a table
walk, it will trigger a fault (even if you are not accessing
those regions).

So, we simply need to stick to what's in the memory map.

This also required fixing the memory mapping code, since it had a few
issues, including walking past the end of a page table and putting PTEs
in adjacent memory as well as mapping more memory than requested

Change-Id: I9166c909d510c82943cd15a9e62799b820ec53ed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10546
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-19 15:33:11 +00:00
Sam Roberts 83be3b3da0 arm64: Clear fp before entering kernel
Otherwise, when crashing, the kernel could continue its
stacktrace back into memory which is no longer mapped.

Change-Id: Ifda337a08c476a18c7dbdd530e4236541d49d3bd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10531
Tested-by: Commit checker robot <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2026-03-16 20:35:19 +00:00
Sam Roberts c0374aed39 freebsd_network: Add missing check for endpoint direction.
Signed-off-by: Augustin Cavalier <[email protected]>
2026-03-16 08:54:00 -04:00
Sam Roberts b249bfc563 usb_ecm: Use appropriate langid when fetching MAC address
The AX88179A has an English MAC address and will STALL if you
don't remind it of this fact.

Change-Id: Id4b1d9b8ff69327787d826ce42e6d78bc3cbcc30
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10529
Reviewed-by: waddlesplash <[email protected]>
2026-03-16 12:28:46 +00:00
Sam Roberts e438946e25 kernel/arm64: Add kernel support for Samsung UART
Tested on M1 MacBook Air.

Change-Id: Idda9b2a168642b55a9e30336be1c4f4936670035
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10487
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-13 08:34:54 +00:00
Sam Roberts 013f25498a arm64: Correct kernel base address
* KERNEL_BASE differed from the base the kernel was linked for
* arch_mmu_is_kernel_address was off-by-one

Change-Id: Ic5a4a509e330bba2503532cc75f1fdaa85ad4f07
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10488
Reviewed-by: waddlesplash <[email protected]>
2026-03-12 19:16:54 +00:00
Sam Roberts d2819f9e83 arm64: Add apple,s5l UART driver
This is the debug UART found in Apple SoCs. Tested on M1 MacBook Air.

Registers definitions were taken from:
  - https://github.com/AsahiLinux/m1n1/blob/18eb02fa92789dfcdab8e00e8b1cace7ab002718/src/uart_regs.h
  - https://www.sistemasorp.es/blog/S3C2410%20-%20datasheet.pdf

Change-Id: I2e4c8b7927fc823cedca421e1a2623b91f5ef112
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10480
Reviewed-by: waddlesplash <[email protected]>
2026-03-11 23:38:03 +00:00
Sam Roberts 5bb69a0f33 build: Fixes for arm64 macOS
* macOS ships an ancient version of GNU Bison which wants
  an '=' after %name-prefix

* macOS awk doesn't support strftime, so try to find a working
  awk.

* _haiku_build_{open,openat,fcntl} are declared and defined with
  different prototypes (variadic vs non-variadic). This is bad
  on its own, but it "happens to" work on most platforms since
  variadic parameters are usually passed in registers, same as other
  arguments. On arm64 macOS, variadic parameters are always passed
  on the stack, so you get weird and confusing bugs when using
  these functions.

Change-Id: I8cee9ecac0ac9b039be6b7e35ceaf8ad7c0f4c44
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10468
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-11 02:21:34 +00:00
Sam Roberts 262dd3c9d9 unzip: Compile with std=c99
Allows building with GCC >=15, which defaults to c23 and disallows
function declarations without parameters and old-style function
declarations.

Fixes #19584

Change-Id: Idb141b804e80d3909558abecd2c74538cb3766ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9684
Reviewed-by: waddlesplash <[email protected]>
2025-10-09 16:39:23 +00:00