Commit Graph
100 Commits
Author SHA1 Message Date
David Karoly e5165df648 docs/arm: remove TODO item for soft-float
soft-float/hard-float mismatch issues are tackled by introducing
libgcc-boot, libgcc_eh-boot, libsupc++-boot libraries in the
gcc_bootstrap package

Change-Id: I4d3eff12c4c78804cd1dd32d6c1c5c8a9b5ad51a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5238
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-23 18:17:19 +00:00
David Karoly 745a40d78a kernel/arm: implement memory attributes
Set AP[2:0] and XN flags based on page attributes.
PXN is not implemented as it seems to be available only
in L1 descriptors on ARMv7.

Set TEX, B, C flags based on memoryType:
* B_MTR_UC is mapped to Strongly Ordered (TEX=0, B=0, C=0)
* B_MTR_WC is mapped to Shareable Device Memory (TEX=0, B=1, C=0)
* B_MTR_WT is mapped to Outer and Inner Write-Through, no Write-Allocate (TEX=0, B=0, C=1)
* B_MTR_WB is mapped to Outer and Inner Write-Back, no Write-Allocate (TEx=0, B=1, C=1)
* B_MTR_WP has no direct equivalent on the ARM so it's mapped as B_MTR_WB
* default is Write-Back

Implement ARMPagingMethod32Bit::AttributesToPageTableEntryFlags()
for mapping from page attributes to AP[2:0] and XN flags.

Implement ARMPagingMethod32Bit::PageTableEntryFlagsToAttributes()
for the reverse mapping used in Query() and QueryInterrupt()
i.e. recover page attributes from AP[2:0] and XN flags.

Implement ARMPagingMethod32Bit::MemoryTypeToPageTableEntryFlags()
fr mapping from memoryType to TEX, B, C flags.

Implement ARMVMTranslationMap32Bit::Protect() which used to be commented out.

Accessed and modified flags are not implemented yet, so no such
flags are returned from Query() and QueryInterrupt().

Also because of this, we just invalidate TLB on any call to Protect()
without checking whether the page has been accessed.

Change-Id: I027af5c02bd6218d9f92a58044aeb26373e1956b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5236
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-23 12:52:59 +00:00
David Karoly ba0c49863a docs/arm: add info on Raspberry Pi 4
Change-Id: Ic8cc47394c9e49f05e30b5ba54ff70557b1e2c47
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5237
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-23 09:18:03 +00:00
David Karoly adc32659fb arm: enable enforcing memory access permissions
Bootloader:
* set permissions to kernel read/write, no user access
  for initially mapped memory areas
* set permissions to kernel read/write, no execute,
  no user access for UART

Kernel:
* physical memory mapper uses kernel read/write mapping
  with no-execute bit enabled
* all other pages are mapped as read/write/execute for
  kernel and user
* proper access permissions and memory types to be
  implemented later

Enforce memory access permissions by setting DACR to
client mode for domain #0, no access for other domains.

see ARM Architecture Reference Manual, section B3.7 Memory access control
and in particular the following subsections:
B3.7.1 Access permissions
B3.7.2 Execute-never restrictions on instruction fetching
B3.7.3 Domains, Short-descriptor format only

Change-Id: I8127b4c72dc516d013cb9751d80d6f3a9ec835e6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5233
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-22 12:20:01 +00:00
David Karoly 097f72e92c docs/arm: update info for Raspberry Pi 2
Change-Id: I968752c3eae56bee099f3cec5db7856dbe007592
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5232
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-22 10:50:59 +00:00
David Karoly f8a9b57cbd kernel/arm: move exception handler stacks to data segment
Exception handler stacks used to be defined in the text segment
which doesn't work very well once we enable memory access permissions
as the text segment is read-only.

Change-Id: I6b28bae09507f23293ede80034db81f5344de4c2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5231
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-04-22 10:15:08 +00:00
David Karoly 9b592446a0 kernel/arm/paging: adjust page table entry flags
Map physical memory by default as Normal Memory,
Outer and Inner Write-Back, no Write-Allocate

This corresponds to the following flags:
TEX=0, B=1, C=1

AP flags are not filled in at this point
as access permissions are not enforced.

see also ARM Architecture Reference Manual, section B3.8.2,
Short-descriptor format memory region attributes, without TEX remap

Change-Id: I90bc95a8feb9f22583d41135f4cbd03489fd1b72
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5230
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-04-22 10:14:48 +00:00
David Karoly be7333a8d7 docs/arm: add info on Raspberry Pi 3
Change-Id: Iee7bd2f99dfc11930a97683c2cf30c51110d6726
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5229
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-22 10:00:39 +00:00
David Karoly 2ba1112f62 docs/arm: remove TODO item for KDL hangman
It seems to be already implemented.

Welcome to Kernel Debugging Land...
Thread 14 "main2" running on CPU 0
frame            caller     <image>:function + offset
 0 801bc898 (+2145662824) 801b9734   <kernel_arm>  (nearest) + 0x00
kdebug> kdlhangman
word> ____
hangman> e
word> ___e
hangman> t
  ____
  |   |
  |   O
  |
  |
  |
word>

Change-Id: I40aa484a69a76482ddd8508d493b6c52c11558fb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5228
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-22 09:46:30 +00:00
David Karoly 2b943e564a kernel/arm: hush memory type warnings
arch_vm_set_memory_type() seems to be x86-specific (cf. MTRR) and
on other architectures it's enough to respect memoryType argument
passed to Map() and Protect()

Change-Id: Ic898b0659c73552d705593dbc3f315dbf504013d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5217
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2022-04-20 15:52:59 +00:00
David Karoly ab78f824da boot/efi/arm: handle unaligned ranges in map_range_to_new_area()
Change-Id: Ia6c707bf8381b77aa8b256a007fb51f1c32e9e17
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5183
Reviewed-by: Jérôme Duval <[email protected]>
2022-04-20 13:38:23 +00:00
David Karoly 6886114066 boot/efi/arm: flush caches before jump to trampoline
Change-Id: Ia7af285f1c3b988828482ff0cd78a416cf51c2c2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5196
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-18 15:27:10 +00:00
David Karoly 9501bd1241 arm64: update linker script for kernel
Change-Id: Icf53d6ce1940dedebf218a6b68531aebf4c896b5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5207
Reviewed-by: X512 <[email protected]>
Reviewed-by: <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-17 08:26:41 +00:00
David Karoly 3be705841c arm: remove config_manager_arch.c
config_manager_scan_hardcoded() is never invoked
and there's nothing else in config_manager_arch.c

Change-Id: Iddd0648efa15ffe4a1621b74dbdd1db16039bfe8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5206
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-04-13 20:30:22 +00:00
David Karoly c4b8af3b6f kernel/arm64: enable 8250 UART driver
Change-Id: If8195e5e1032a172b3365f8771c4d87a2f0657ad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5191
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: <[email protected]>
2022-04-13 20:00:11 +00:00
David Karoly 21ac6f6b75 arm64: remove config_manager_arch.c
config_manager_scan_hardcoded() is never invoked
and there's nothing else in config_manager_arch.c

Change-Id: Id3ec90f670de3517cfc9c1d6710c0fa688e5d48b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5205
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-04-13 19:57:20 +00:00
David Karoly 4b1d94b435 debug_uart fixup for arm64
Change-Id: I872e822c48d0b4675064991ba890ce6d74d15118
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5186
Reviewed-by: <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-09 14:52:35 +00:00
David Karoly 2b5b228442 boot/efi: implement ranges property for simple-bus
see Devicetree Specification, section 2.3.8

Change-Id: I788bbaa67c8e8f9b57f138418eb1c3131bbe2010
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5188
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-04-09 14:51:47 +00:00
David Karoly ab3c8bea07 gensyscalls: alignment fixup for ARM
ARM ABI has different alignment requirements based on parameter size:
* parameters not larger than 4 bytes are aligned on 4 bytes
* parameters larger than 4 bytes are aligned on 8 bytes

see:
Procedure Call Standard for the Arm Architecture
sections 5.1, Fundamental Data Types
and 6.5, Parameter Passing

Therefore the following changes are introduced in gensyscalls tool:
* new optional define SYSCALL_LONG_PARAMETER_ALIGNMENT_TYPE is introduced
* it's defined only on ARM
* on other architectures it takes on the value of SYSCALL_PARAMETER_ALIGNMENT_TYPE as a default
* constants kLongParameterAlignmentType and kLongParameterAlignmentSize are introduced
* Syscall::AddParameter uses this value for aligning parameters larger than 4 bytes

Change-Id: I7e766e0ea9d07001643e813722b462b1f044921a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5112
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-08 15:30:06 +00:00
David Karoly 5e6e52cfd4 boot/efi/arm: enable caches before jump to kernel
Set bits 12 and 2 in SCTLR to enable i-cache and d-cache.
Set cacheability flags in TTBR0 to enable coherent page table walks.

Change-Id: I7f62255b9e49035524ecf87bed12a60dd405f3c8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5178
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-05 10:49:46 +00:00
David Karoly fdaa57a70d boot/efi: handle /chosen/stdout-path
Change-Id: I08ebadf274448e1319cc8b0666beaf709382c00f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5143
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-04-05 10:49:19 +00:00
David Karoly c5d3ca339c runtime_loader: ignore PT_ARM_UNWIND sections
Change-Id: I966e366c73d495c3b3396f0dd4b44bafaf5c77c5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5136
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-03-29 07:10:41 +00:00
David Karoly d232643ed8 boot/efi/arm: add debug logs for initial CPU state
Change-Id: I08df563ef6967f5f9734bbe11ac643c3b68f504f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5151
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-03-29 07:09:14 +00:00
David Karoly 7fdf6e8639 boot/efi/arm: switch serial output to legacy after exiting EFI boot servieces
Change-Id: If7ba007d24cc95ce0a43adc320932e3e1678c25b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5159
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-03-29 07:08:48 +00:00
David Karoly a3ef09d41e boot/efi/arm: implement PL2 to PL1 transition
Change-Id: Ib30a943f68430ecbe33d8c7fe88c67267f9deff9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5150
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-03-29 07:08:24 +00:00
David Karoly 5ba6ef84ef boot/efi: use 8250 driver for bcm2835 mini-UART
Change-Id: I1f42447e537ea7522ac299f028d530beb5067350
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5142
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-03-24 13:24:55 +00:00
David Karoly 9d65dbf1cb boot/efi: rework address-cells and size-cells handling
see Devicetree Specification,
section 2.3.5 #address-cells and #size-cells

The #address-cells and #size-cells properties may be used in any
device node that has children in the devicetree hierarchy and
describes how child device nodes should be addressed.

The #address-cells and #size-cells properties are not inherited from
ancestors in the devicetree. They shall be explicitly defined.

If missing, a client program should assume a default value of 2
for #address-cells, and a value of 1 for #size-cells.

Change-Id: Iafed49358540f8ac7aa673c3dc0191c9b580250b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5144
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-03-24 13:24:22 +00:00
David Karoly 6804f6c764 kernel/arm: implement entering userspace
Change-Id: Icf3945db979a8f4444856fc7157649f48b297c29
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5037
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-03-02 22:38:25 +00:00
David Karoly 289b735673 arm: fallback to icu-57.2 for haikuportscross
Change-Id: Iad87ab9675314d52cf1748afb1bd9017ec911178
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5036
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-03-02 19:28:50 +00:00
David Karoly fdb459132e boot/efi/x86: implement SMP detection and bootup
* move common SMP initialization code to x86/arch_smp.cpp

* factor out arch-specific SMP initialization to
  arch_smp_32.cpp resp arch_smp_64.cpp

* implement smp_trampoline for x86 32-bit EFI loader

* rename SMP trampoline for x86_64 to long_smp_trampoline

* add new argument virtKernelArgs to arch_smp_boot_other_cpus
  as the kernel args are not identity mapped on 32-bit architectures

Change-Id: I30d0bb1fa9bfb08f6784a2af34eb83d6b64afa57
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4869
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-03-01 17:39:19 +00:00
David Karoly 4c6e7a4bca kernel/arm: implement prefetch abort handler
Change-Id: I39c330a44ad36ede41c7727017dd733d07288be9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4983
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-26 22:08:57 +00:00
David Karoly 883858e60b implement TLS for arm
Use the User Read-only Thread ID Register aka TPIDRURO to store
TLS pointer.

The User Read-only Thread ID Register is read-only in User mode,
and read/write in privileged modes.

see: ARMv7 Architecture Reference Manual,
section B3.12.46 CP15 c13 Software Thread ID registers

Change-Id: I7bff2fd66f41d7bf1a8a247151bcd02b32733c1b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4994
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-26 11:41:40 +00:00
David Karoly 1b895c8371 kernel/arm: implement syscall handler
Change-Id: I75f2fb7808f55a460835276ca66cce8a26e8403d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4980
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-25 15:35:50 +00:00
David Karoly 0fea9fec6f Update gcc_bootstrap package for ARM
Change-Id: Ica8b714252925460c612f934cc2a7300a397ec47
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4993
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-24 20:23:06 +00:00
David Karoly b22c6f6f29 kernel/arch/arm: swap TTBR on thread context switch
Change-Id: Ie85742d077866c10ba57b46848d5acaef932615e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4982
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-24 16:49:58 +00:00
David Karoly f06e0279a5 implement glue for arm
Change-Id: I2752fb8b1c8843e8344a10295caf82e9603ed5e2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4973
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-24 16:39:15 +00:00
David Karoly 4ddef6e701 kernel/arm: detect read/write access in data abort handler
Use Data Fault Status Register's bit 11 to initialize isWrite.

see: ARMv7 Architecture Reference Manual,section B3.9.5
Distinguishing read and write accesses on Data Abort exceptions

Change-Id: I7da6702fc0e9579e5cb09cba3c5c89f004ec268a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4972
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-02-23 22:42:02 +00:00
David Karoly 24b174f4f9 runtimer_loader/arm: implement relocations
Change-Id: Ibda978e37d6dbdaf33ac054adbbda70768fe0d97
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4975
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-02-23 22:41:26 +00:00
David Karoly f98f9bccb8 libroot/arm: implement syscalls
Change-Id: Id9b37d29b802b7f469fb109054ec6446f93511b5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4979
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-02-23 22:40:31 +00:00
David Karoly acb424c8b7 boot/arm: move system_time and spin to platform
Add fake implementation for system_time()
Implement spin() using EFI boot services

Change-Id: Ib69b851780bd03624ce4e19d725dd319f6640601
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4964
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-19 15:35:21 +00:00
David Karoly 38d4a2edf7 virtio: add VIRTIO_FEATURE_ANY_LAYOUT in virtio.h
Change-Id: Ib8bc3639b4330dc1fb61ddbb6a3e8237cc6814ca
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4971
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-02-18 21:27:47 +00:00
David Karoly a21676b669 runtime_loader: adjust MAX_PAGE_SIZE for ARM
gcc generates binaries with segments aligned on 0x10000
because this is the max page size defined in bfd

This change allows runtime_loader to load ARM binaries
without complaining for unreasonable amount of space
between segments.

Change-Id: Iec345980ca7ff72786173772a6deb40f5ca0b0ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4974
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-02-18 21:25:54 +00:00
David Karoly a18ff64517 boot/arm: remove unused arch_mmu.h
This file is used only by the u-boot raw bootloader and
it has identical content to platform/u-boot/mmu.h.

Therefore we can use mmu.h in the u-boot loader and remove
this header.

EFI platform has its own arch_mmu.h in
headers/private/kernel/boot/platform/efi

Change-Id: Ie77774fbcf4855f9bc643176c179670f6169b3b6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4929
Reviewed-by: Adrien Destugues <[email protected]>
2022-02-04 11:42:45 +00:00
David Karoly 478279116b boot/efi/arch: remove comments related to ConvertPointer
Change-Id: I1c0ebe04c180f3c50ac07c7d043a33d2c4563a18
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4924
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-02-02 16:36:14 +00:00
David Karoly 4f912a8b33 enable building EFI loader for x86
Change-Id: Ic7d2c3194b8555f7b6704131f5fc2bce3b139ee4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4918
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-31 14:22:57 +00:00
David Karoly a7b50febfa kernel/x86: use proper phys_addr_t field for storing ACPI root pointer
Change-Id: I475b7b3f9bd0711ecd037043e86559ab691a82a7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4881
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-31 14:15:46 +00:00
David Karoly bfd5d56283 boot/efi/mmu: fix sign extension issues
Conversion from pointer to phys_addr_t (i.e. uint64) results
in a sign extension on x86.

Therefore we first convert to addr_t and then convert from
addr_t to phys_addr_t.

Change-Id: Id9d9db03d9940a11ea3892841c271e12fad3975a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4872
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-31 14:14:12 +00:00
David Karoly 4ca2120531 boot/efi/x86: take care of PAE flags during MMU initialization
UEFI specification states that on IA-32 paging may or may not be
enabled during startup. If paging is enabled, PAE might be active.

During jump to kernel and early kernel initialiation we use paging
without PAE.

Therefore the following initialization sequence is introduced:
* disable paging
* disable PAE
* load page directory
* enable paging

Change-Id: Ife9a631b914dd5867f6673713e20e8abfce1ea44
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4919
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-30 13:39:43 +00:00
David Karoly 5e5299336b boot/efi/x86: implement MMU initialization and jump to kernel
Change-Id: Ie42c69f3851acae3a8184aa97ab2dd01c9485f46
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4850
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-28 15:31:07 +00:00
David Karoly 20c0887491 boot/efi/arm64: implement arch_convert_kernel_args()
Empty function for now as no arch-specific calls to
fix_address() needed on arm64.

Change-Id: Ifef100c132eac29a2b763e06bf1efd695b284851
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4894
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-01-28 15:28:03 +00:00
David Karoly 36e8ac9d41 boot/efi/x86: implement timer initialization
Change-Id: Ida16e63d2b8f87b90897892faf0e6db92b185d34
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4851
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-28 10:25:29 +00:00
David Karoly 367beefadc boot/x86: move HPET initialization to arch folder
Change-Id: Iac3f4923f132c4c3328fde5af1dad75af5b2efbd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4864
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-28 10:25:29 +00:00
David Karoly 8d743ebd60 docs/arm: remove TODO item for bootloader memory map handling
Change-Id: Iabcada696eb87500dbcdb03cf742607e0e525707
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4892
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-01-27 20:25:22 +00:00
David Karoly d283a8c58a kernel/arm: add range checking for early page tables
Change-Id: Ibbd367475482eb0cf839314014c8bf68612c5d6a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4891
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-27 16:29:48 +00:00
David Karoly 79ee00628f boot/efi/arm: don't add ranges below KERNEL_LOAD_BASE to virtual_allocated_ranges
Change-Id: I9dbb1c46bcfcdea6fe3e8287673557e54a29c008
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4889
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-27 16:28:45 +00:00
David Karoly a2d528242a boot/efi/arm: code cleanup
* Use TRACE() for logging
* Use B_PRI format strings
* Reformat local variables and function arguments to use camelCase
* Remove comment related to ConvertPointer
* Fix indentation for switch statements
* Remove variable sFirstPageTable as it's not really used

Change-Id: Iace275e5a3311f13a5018f497c3132e472a20848
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4885
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-27 14:11:27 +00:00
David Karoly f991c7ee03 boot/efi/dtb: fix signedness of dtb_get_interrupt_parent()
Change-Id: Ic3a28ff003cb82dc9166200594dbf3fc58e76b51
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4884
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-27 02:02:22 +00:00
David Karoly f06c2e7f5c docs/arm: remove TODO item for early page tables
Page directory and early page tables are allocated using
platform_allocate_region() and they don't need to be identity mapped
since commits 9103470bd and a7c69a4b1.

Change-Id: Ia7fcf1dd2fa34262e013f651139ad252a1ac9113
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4886
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-27 02:01:41 +00:00
David Karoly 8fea4985b5 bus_managers/fdt: implement interrupt-cells handling
Change-Id: Id0ff78ce51fb64065c2a6398115e3a3dd12693da
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4658
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-01-26 00:06:28 +00:00
David Karoly 9a573968a2 boot/efi/arm: use insert_address_range for virtual_ranges_to_keep
Change-Id: Iaf67838e8ef3d9a9494791945bd777b92315a948
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4877
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-25 11:39:14 +00:00
David Karoly cc69b20bb1 boot/efi/arm: move arch_enter_kernel to identity mapped region
First try to allocate a page below 2GB.

If it fails, try to allocate a physical page at the address
returned by get_next_virtual_address so that we get an address
that is available in both virtual and physical space.

Finally try to allocate any available page. At this point
it's highly likely that it will be above 0x88000000 so it can be
used for trampoline code.

Change-Id: I3100a3e09efcd938bc630a52dcce74dc5f24beb5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4878
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-23 08:50:46 +00:00
David Karoly b57ffe4006 kernel/arm/paging: zero out the bottom portion of the new pgdir
Change-Id: I899f288f451dd4c413403cd0e14a855f68355050
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4866
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-23 08:50:46 +00:00
David Karoly 933430df22 boot/efi/arm: remove identity mapping for EFI code and data segments
All the regions allocated via platform_allocate_region() are mapped to a
high virtual address so there's no need to do identity mapping for them
any more.

Copy kernel_args to a region allocated via platform_allocate_region() so it
will be mapped similarly.

Identity mapping is still needed for trampoline code for jumping to the kernel

Change-Id: I844a7a789b440a38521db49adc077bb77e658ddf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4865
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-23 08:50:46 +00:00
David Karoly 01cb3ed58e boot/efi: add stubs for x86
Change-Id: I8d3dfa7cc07679a8b024df24f7cddb3a5bcec02c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4747
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2022-01-17 16:04:47 +00:00
David Karoly 31f5f4d339 boot/efi/arm: remove identity mapping of EFI runtime services
EFI runtime service memory areas are remapped to a high virtual address
allocated with get_next_virtual_address() to avoid any address space
collision.

They are also added to virtual_ranges_to_keep so that the kernel knows
that these ranges should be reserved.

Change-Id: I63e1a2450fceff3b2404154907a2cf59dd1b373b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4863
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-01-13 22:43:32 +00:00
David Karoly a7c69a4b1f boot/efi/arm: remove identity mapping of initial page tables
Change-Id: I37cb756c32e05a585ff224c1e48d1a40c83e5e2e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4858
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-01-13 22:43:32 +00:00
David Karoly 9103470bd3 kernel/arm: don't require identity mapping of initial page tables
Remove the dependency on identity mapping for the initial page tables
used in MapEarly / _EarlyQuery.

The initial page tables have to satisfy the following conditions instead:
* the inital page tables shall be allocated in the same region as the initial page directory
* this region shall be mapped contiguously
* the page tables shall be mapped at a higher address than the page directory

Change-Id: I34854ef93826aa48f5d90582b52905e553f3d275
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4857
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-13 22:43:32 +00:00
David Karoly dc3e1761e6 docs/arm: remove TODO item for serial port mapping
UART is mapped to kernel virtual address range since commit f5f10a9ec
so it does not overlap with user address range any more.

Change-Id: If8e18904fcddcbef1ccdc91e526d0e581f61e085
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4856
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-01-12 12:21:11 +00:00
David Karoly 4ddb4993c8 kernel/x86: fix HPET ACPI table alignment
vendor_id shall come after the bitfields

Move hpet_address to separate struct definition so we can apply
the correct packed flags.

see also: https://wiki.osdev.org/HPET

Change-Id: Iced005846fedd4b895910e9b61137d5349db5b41
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4859
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2022-01-12 12:20:25 +00:00
David Karoly ddb70de4d2 kernel/x86/hpet: fix build with TRACE enabled
Change-Id: I8b1d8f0e8ba7e800fe458135197080617be731bd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4860
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2022-01-11 21:45:01 +00:00
David Karoly 6f62f45641 boot/efi/arm: initialize TTBCR when starting the kernel
Change-Id: I5ecaa0a91c8677f7d1ac6a512de6de8b2eaa597c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4852
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-01-08 17:58:29 +00:00
David Karoly 023a36024d boot/efi: introduce arch_dtb
Change-Id: Iff9e4198aca706097889faf51e9559fe551126ad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4782
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2022-01-05 16:22:35 +00:00
David Karoly fbc211a255 efi: fix alignment for block device protocol
efi_block_io_media struct needs padding on x86.
uint64_t is aligned on 4 bytes in Haiku toolchain for 32-bit EFI loader.
But the EFI firmware expects it to be aligned on 8 bytes.

Same padding in u-boot:
https://github.com/u-boot/u-boot/blob/v2021.10/include/efi_api.h#L638

and in Illumos:
https://github.com/illumos/illumos-gate/commit/feff18a41e45afb02478e67d56fad5027334f115

Change-Id: I1b95cbe4cc1e7d96fde3ba52862a05f8a94aab79
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4840
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-01-04 17:56:41 +00:00
David Karoly 6117e0c29c boot/loader: relocate kernel to virtual address space on 32-bit architectures
Change-Id: Ic86ca6874f358df8755a0c691cccb155d145e06c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4675
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2022-01-01 11:35:28 +00:00
David Karoly a7c2c5f842 Update bootstrap package versions for ARM
Change-Id: I33f690355455561cb3faa55bccbfe73d24d2a32e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4842
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-31 16:03:11 +00:00
David Karoly 235aa994d7 boot: rework 32-bit/64-bit kernel load base selection
Change-Id: I0aed05c0ef2ff1a162581e4f988bf24ed1e521e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4816
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-27 15:44:56 +00:00
David Karoly b9a0a02382 arch/x86: select between 32-bit and 64-bit ELF based on arch and platform
arch_elf is reused between the kernel and boot loader

No change for kernel mode compilation.

How to select 32-bit or 64-bit when building boot loader:
* build both when building BIOS loader
* build only 32-bit when building 32-bit EFI loader
* build only 64-bit when building 64-bit EFI loader

Change-Id: I9caa1248c7eb24318911a0c369137cedb638e4e4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4817
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-27 15:17:54 +00:00
David Karoly 182eaee962 boot/loader/x86: select between 32-bit and 64-bit ELF support based on arch and platform
Build both when building BIOS loader.
Build only 32-bit ELF support for 32-bit EFI loader.
Build only 64-bit ELF support for 64-bit EFI loader.

Change-Id: I88bb287fbb9a4b6618b365b2d03f85f64021f499
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4818
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-27 15:17:17 +00:00
David Karoly 18e885db51 boot/efi: implement convert_kernel_args for 32-bit
Change-Id: I528d6f8ca576b38c50dc314972636e7156d24705
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4784
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-17 08:58:57 +00:00
David Karoly af90bfd3bb boot/efi: introduce arch_convert_kernel_args
Change-Id: Iabb321564d6733c6cf481ec2548fa287e308ae89
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4796
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-17 08:58:57 +00:00
David Karoly c1e0007eea virtio-mmio: add initialization for legacy mode (version 1)
Change-Id: I4dcfca8cfabafad592b638b28215225b1cca35d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4657
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2021-12-15 15:55:50 +00:00
David Karoly f0adfe2a54 boot/efi: fix dummy reloc for x86
Change-Id: Ia61d593c8d131bd6780688ea932b5b92bd629764
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4748
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 19:56:21 +00:00
David Karoly 1a7afaa45b boot/efi: fix for garbled first item returned by mmu_next_region()
Change-Id: Ic9d02800bccbb5508eeb0b2c1ee1ed1326d0829f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4783
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 19:48:38 +00:00
David Karoly 20efe26dfa boot/efi/arm: fix printout of kernel entry address on startup
Change-Id: If3d592983e1c22210c6b4d3a6ceaf2a7641e7e7a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4785
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 19:46:50 +00:00
David Karoly 1f6e2499db ldscripts/x86: add ldscript for EFI loader
Linker script is adapted from elf_ia32_efi.lds in GNU-EFI.
see:
https://sourceforge.net/p/gnu-efi/code/ci/master/tree/gnuefi/elf_ia32_efi.lds

The only significant change is the additions of ctors.

Change-Id: I1091f610129f806f124d714fd9a42cf932fa1c2d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4746
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 19:44:23 +00:00
David Karoly d223f9d9c2 boot/efi/serial: fix legacy mode for x86
Change-Id: I44fd33289da94e9520c6c202ac96c4ca8e511638
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4754
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 13:19:14 +00:00
David Karoly a857758352 boot/efi/x86: fix address for arch args
Change-Id: If9a3bb32cb8d290f97cee2e8e821dcbf8b8852a8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4789
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
2021-12-14 11:15:37 +00:00
David Karoly 3896dbcb1d kernel/arch/arm: fix missing return statement in rtc
Change-Id: Ib5a2e06884b6973ed102b30b1339a7b800c95418
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4781
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-13 14:47:10 +00:00
David Karoly 6e28efbb5f platform/efi/devices: fix build when TRACE is enabled
Change-Id: If9ea3212b7908aaa6c9c6774cb68a6dbf635a5ac
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4761
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-11 14:16:34 +00:00
David Karoly 1103466926 build ARM EFI bootloader with soft-float
Change-Id: If7feffafea4fc6d295d04f696127c8f0fbd8fb9d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4704
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Alex von Gluck IV <[email protected]>
2021-12-11 14:07:06 +00:00
David Karoly 69f4a74149 link bootloader with libgcc-boot.a and libsupc++-boot.a on ARM
Change-Id: Ia7f41191136db3ea34ed6abee97ae627bb7b1727
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4703
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-11 14:07:06 +00:00
David Karoly 123aa1325c boot/efi/arm: enable FPU before jumping to kernel
Change-Id: I37bb2146102a207e97355e099f6b4160d644c326
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4701
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-11 14:07:06 +00:00
David Karoly b3780b5658 kernel/arch/arm/int: enable OMAP3 and PXA intc drivers
Change-Id: I83ab8cd4c474bd374f66a39d9a60c778dd7033e8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4757
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-07 10:58:24 +00:00
David Karoly 36d65a7890 kernel/arch/arm/int: add initialization code for GICv2
Change-Id: I4f98a4e0277ce37e758cabbb04806cf13f351f1e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4674
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-07 10:58:24 +00:00
David Karoly 354655e136 boot/efi/dtb: implement interrupt controller detection
Change-Id: I045a94c5bcb7c16297bc6fdd1fa2981e5b3f3a62
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4756
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2021-12-07 10:58:24 +00:00
David Karoly f18aba2ca8 BootRules: use non-legacy ld
Change-Id: I0dc6a1c8731e710a9c43b6dfa5ea08c84fa5d3a6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4759
Reviewed-by: waddlesplash <[email protected]>
2021-12-06 03:08:27 +00:00
David Karoly 8032682c23 OverriddenJamRules: sort out build flags for .S files
Change-Id: I1ad67e1aab3911e7b66dc801923e8ba5cc1e087d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4755
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2021-12-06 03:08:27 +00:00
David Karoly 563ac51229 boot/efi: fix compile issue with format strings
Change-Id: I144afe78f73fed211ea1c72584fa5f12e4452454
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4751
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2021-12-02 12:50:54 +00:00
David Karoly e82b457883 boot/efi/devices: fix warning for comparison signedness
Change-Id: I2a329c91d229a8672536ccdaa2c94db109390308
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4752
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2021-12-02 12:50:37 +00:00
David Karoly c5d81c2739 build: prepare for x86 EFI loader
Change-Id: Ic9e4181042bf634cd590d8c95935a987a4871b0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4753
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2021-12-02 12:50:25 +00:00