Commit graph

686 commits

Author SHA1 Message Date
Hector Martin
f61e5d4958 cpu_regs: Add more chicken bit names
These are from a public Apple source that shall remain unidentified
(because it's utterly silly that they keep trying to hide these).

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-17 03:17:13 +09:00
Hector Martin
ee0667e190 chickens_avalance: Add missing HID11_DISABLE_LD_NT_WIDGET
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-17 01:43:32 +09:00
Hector Martin
ffc38f84ac kboot: Grab kblang-calibration for M2
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:44:48 +09:00
Hector Martin
9769200f60 nvme: Reset ANS as well as ANS2
M2 machines call it that...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:08:28 +09:00
Hector Martin
a5a57c230e pmgr: Add pmgr_adt_reset()
This isn't actually useful for NVMe, but let's keep it...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:04:42 +09:00
Sven Peter
aacbfc04e9 kboot: swap BD address
Unlike the MAC addresses Bluetooth addresses have to be stored
in little-endian byte order (see devicetree/bindings/net/bluetooth.txt)

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-11 19:56:42 +09:00
Hector Martin
b1ad2d340f asc: Do not clear ASC run bit while running
Some ASCs will get stuck if we do that. Instead, explicitly clear it
after an RTKit shutdown.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-11 19:02:21 +09:00
Hector Martin
4555cc5148 dapf: Initialize DAPFs from the ADT
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-03 23:27:50 +09:00
Hector Martin
ecfed3e100 pcie: Add t8112 support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-01 23:37:00 +09:00
Hector Martin
bf09fcd286 asc: Add retries and a timeout to asc_send
Fixes: #211
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-01 18:03:42 +09:00
Sven Peter
481e4ceefc kboot: use 'local-bd-address' for bluetooth mac address
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-01 17:58:02 +09:00
Sven Peter
2c37105412 kboot: propagate bluetooth calibration blob
Depending on the chip stepping (stored in the OTP) either the blob for
beamforming or the normal calibration blob has to be used.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-01 17:58:02 +09:00
Hector Martin
b1f9d72554 hv: Don't touch DCP on laptops
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:47:02 +09:00
Hector Martin
1ac6c7659d smp: Add T8112 support
PMGR cpustart offset moved...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:47:02 +09:00
Hector Martin
55ca4855a5 cpufreq: Add T8112 clusters
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
b077c08181 dart: Add dart,t8110 support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
bfd03cf428 mcc: Add t8112 support
This is compatible with t8103.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
ece84e0acb mcc: Make more robust
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
c481c0799b main: Fix version number message
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
22adc922f7 chickens: Add T8112 chickens
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
b16a19715a chickens: Split off core sequences into separate files
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
d9c1ef7d49 cpu_regs: Add new defines for T8112 chickens
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
8a607f049f soc: Add T8112 defines
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
c947b600c7 main: Add a BRINGUP define to disable ~everything but UART
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Vincent Duvert
66a85593db AFK: limit number of tries in start_interface
Signed-off-by: Vincent Duvert <vincent@duvert.net>
2022-06-21 17:20:54 +09:00
Hector Martin
f3ce8a68d0 smp: Fix pathological thrashing with the hypervisor
Writing to the IPI register causes a trap, which sets the event...
causing every CPU to go into a tight loop of traps contended on the BHL.

We don't need to clear IPIs in WFE mode, so don't do that.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 21:53:42 +09:00
Hector Martin
849729f0c0 memory: Add GRE and nGRE mappings for experiments
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 21:53:06 +09:00
Hector Martin
c95189ba2e memory: Normalize naming of Normal-NC memory attributes
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 16:12:16 +09:00
Hector Martin
ee2949e744 smp: Use stronger barriers around wfe/sev
Not sure if this fixes anything, but it looks more correct.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 15:21:59 +09:00
Asahi Lina
ffe2f4104e fb: Support XBGR pixel format for fb_blit()
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-06-19 01:36:41 +09:00
Akihiko Odaki
bcbe26d79b m1n1.hv: Always continue on the stepped thread
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
2022-06-04 20:20:21 +09:00
Asahi Lina
b48e33a333 hv: More instructions
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-06-02 22:50:52 +09:00
Hector Martin
17abe8f94b display: Report time spent modesetting
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 02:03:32 +09:00
Hector Martin
714420a694 display: Put DCP to sleep if display is external
This stops DCP from killing our modeset if the connection cycles.

Also force a (potential) configure cycle if the display is external;
this makes sure updated stage2s will have a chance at fixing issues of
old stage1s. Modesetting is fast when it's the same mode as before.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 01:54:11 +09:00
Hector Martin
9748b5525e dart: Only allocate a max of 2 L2 tables
This is what iBoot normally does, and >2 will panic macOS

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 01:49:59 +09:00
Hector Martin
abd48b0b5c rtkit: Always wake up/boot IOP unconditionally
Get rid of asc_cpu_stop() which was never a thing. The CPU start bit
should always be off in the steady state, it is only used momentarily to
start the CPU.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
7023e247bb rtkit: Align naming with Linux version
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
06ec66e2a9 proxy: Export pmgr_reset()
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
0472bc05cd proxy: Export display functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
09013da441 display: Don't crash if shutdown is called twice
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Akihiko Odaki
8163883252 utils: Use exclusive load to wake up from WFE
Commit 9c795fbdbf introduced the pair of
WFE and SEV for spinlock, but it caused delays of tens of seconds. A
possible explanation for the delay is lack of data synchronization
barrier between the store instruction and SEV instruction.
Arm Architecture Reference Manual for A-profile architecture (issue H.a)
says:
> Arm recommends that software includes a Data Synchronization Barrier
> (DSB) instruction before any SEV instruction. The DSB instruction
> ensures that no instructions, including any SEV instructions, that
> appear in program order after the DSB instruction, can execute until
> the DSB instruction has completed.

However, inserting a DSB instruction still didn't resolve the delay.

The exclusive load is an alternative to the SEV instruction. The manual
says:
> ...However, in Armv8, when the global monitor for a PE changes from
> Exclusive Access state to Open Access state, an event is generated.

> This is equivalent to issuing an SEVL instruction on the PE for which
> the monitor state has changed. It removes the need for spinlock code
> to include an SEV instruction after clearing a spinlock.

As an additional benefit, the exclusive load is local to the PE and
eliminates spurious events for other PEs.

Trusted Firmware-A v2.6 also employs the same algorithm.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
2022-05-31 21:49:37 +09:00
Janne Grunau
8147c2d374 display: Add 'retina' flag to display_parse_mode
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
7f4347ebe8 display: Reallocate framebuffer if required for wanted display mode
If an explicitly specified display mode exceeds the allocated
framebuffer allocate a new one from the top of RAM.

Note: macOS panics immediately with a realloced framebuffer.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
1ea31ae996 dart: Add setup of pre-allocated L2 tables for dcp/disp0
DART nodes for dcp and disp0 have pre-allocated L1 and L2 tables which
are annotated in the ADT. The pre-allocated memory is specified in
"pt-region-${DEVICE}". The first page is used as L1 table and the
following pages are used as L2 tables. The number of valid L2 tables is
specified in "l2-tt-${DEVICE}". The first entry identifies the region
and the second entry is the number of valid L2 tables.

iboot (macOS 12.3) inits just 2 L2 tables. Larger framebuffers require
more. By using the pre-allocated page tables we do not have worry about
keeping the memory mapped after m1n1 executes the next target.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
079659dfea display: Move dcp iboot swap into its own function
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
d08793a456 dcp: Free iovad_dcp including dart L2 tables on shutdown
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
9356e60803 dcp: Limit dcp iovad to 256M
Does not make a difference but avoids effort on shutdown.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
645152e849 dart: Make dart translation error logs more informative
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
c577e94d75 display: limit timing modes by framebuffer size
The reserved framebuffer on the Mac Studio is 0x854000 bytes. This is
too small for 1920x1200 with 4 byte per pixel. Setting 1920x1200 as
mode crashes dcp but not the actual display controller. The display
remains working and even comes back after display hotplug/power cycle.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
65199c63da kboot: support multi die machines in dt_disable_missing_devs
The device tree for multi die SoCs as the M1 Ultra has its devices
under "/soc/dieX" instead of directly under "/soc".

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 22:56:12 +09:00
Hector Martin
8eeb7966aa hv: Refactor CPU switch logic, make hv.cpu() not exit shell
Get rid of the hv_rearm() thing (which was always a bit dodgy) and
instead properly make sure that all CPUs rendezvous when needed and
switch the active proxy thread without ever exiting exception context.

The Python side can now switch proxy context (by waiting directly for
a proxy boot) without having to exit out of the hypervisor callback,
so cpu() now works as a normal Python method.

Add a cpus() iterator so you can do things like:

>>> for i in cpus(): bt()

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 22:33:44 +09:00
Hector Martin
01a1a0f597 hv: Make time stealing run-time configurable
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:37:23 +09:00
Hector Martin
908f263f22 proxy: Fix warning in P_MCC_GET_CARVEOUTS
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:29:51 +09:00
Hector Martin
9c795fbdbf utils: Use WFE/SEV in spinlock
This should reduce memory traffic spam and power usage from lock
contention when threads are blocked on a spinlock.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:22:55 +09:00
Hector Martin
ad659daa6d payload: Fix spurious variable detection on EOF
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-23 20:40:07 +09:00
Asahi Lina
25d33aa4c7 hv_vm: Implement more opcodes
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
5b534cbf31 hv_vm: Add more SIMD ops to emulation
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
c746549c2e hv: Map RAM via tracer infra, handle carveouts in Python
Previously RAM was mapped ad-hoc, but this can end up interacting
poorly with the tracer infrastructure which we are now using for RAM
too. Move to mapping guest RAM via the tracer infra, and also unmap the
TZ carveouts in the Python side so it knows about them.

This is a HV ABI break.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
b88785fa58 hv_vm: Add 32-bit LDP emulation
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Hector Martin
52bb64b86c hv_exc: Do not forget to arm tick in fast path
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-20 00:38:22 +09:00
Hector Martin
e750dfcca1 hv_exc: Improve multi-core scalability
The HV tick polling now only runs on CPU#0. All CPUs have the 1000Hz
HV tick, but secondaries only use it to poll the FIQ state and that path
does not take the BHL if no other FIQ was pending.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-20 00:20:58 +09:00
Hector Martin
3020e26e00 dart: Announce real-time DARTs
Mostly just for reference.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 23:42:22 +09:00
Hector Martin
fabe27e3f1 memory: Remap some carveouts as uncached
This fixes display DART real-time cache hits causing AMCC exceptions.

The relevant carve-outs have flags 0x60004016; 0x60004002 is used for
DCP which is non-realtime, so I'm guessing the '16' means we should map
it uncached.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 23:41:17 +09:00
Janne Grunau
6df73d80ee cpufreq: Add support for t6002
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:39:52 +09:00
Janne Grunau
4aa4ff98b6 smp: Start CPU cores on the second t6002 die
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:39:52 +09:00
Hector Martin
8df40df17e nvme: Support nvme on die 1 for t6002
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 21:39:52 +09:00
Janne Grunau
6256baca04 pmgr: Add multi-die support for t6002
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:39:52 +09:00
Janne Grunau
76fd226f7c aic: Add support for multi-die AIC2 as seen on the M1 Ultra
Multi-die IRQs are coded as in the ADT: die * max_irq + num

Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:29:30 +09:00
Janne Grunau
524cb4a34f soc: Add target for t6002
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:29:30 +09:00
Janne Grunau
1b5dee2496 display: Map the framebuffer if it is not mapped
iboot on Mac Studio (M1 Ultra) does not map the framebuffer("/vram")
for dcp and disp0.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:29:30 +09:00
Janne Grunau
0104abbea7 dart: Add dart_find_iova() to find unused IOVA space
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:29:30 +09:00
Sven Peter
e9f36ad8b2 kboot: disable phys nodes as well
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-04-16 19:22:28 +09:00
Sven Peter
28103d9003 kboot: propagate ATC tunables to the FDT
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-04-16 19:22:28 +09:00
Janne Grunau
d0ce92a284 pcie: Set correct link speed for 10gb ethernet
The PCIe 4 link speed is only described as "target-link-speed" in the
"lan-10gb". This changed in macos 12.3 or earlier. Verified on Mac
Studio and with the template Mac Mini ADT.

Reported-by: Jeff Geerling <geerlingguy@mac.com>
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-16 19:14:00 +09:00
Janne Grunau
d05f92b18a hv: Hibernate DCP in hv_init
DCP will otherwise not be useable from the guest system.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-16 19:12:23 +09:00
Asahi Lina
e2f63a07b2 hv: Improve VM emulation for tracer
Adds support for up to 64-byte ops and more SIMD/paired operations.
This is good enough to trace a lot of GPU VM address space.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-04-16 19:06:22 +09:00
Hector Martin
1d19e74ca8 display: Implement mode selection
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 17:57:37 +09:00
Hector Martin
550e39913f string: Add atol
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 17:23:50 +09:00
Hector Martin
ebf1cf3aa3 display: Reinit FB if resolution changed 2022-03-27 17:02:00 +09:00
Hector Martin
d937483067 fb: Add fb_reinit() 2022-03-27 17:01:42 +09:00
Hector Martin
3248c91aef display: Allow forcing re-config via payload (WIP)
Doesn't actually let you specify a mode yet.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 16:46:53 +09:00
Hector Martin
780c0644d4 display: Fix HPD detection bug
Turns out it's just an 8-bit bool, not 32 bits, and when cast to int
the top bits can cause it to be interpreted as an error randomly...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 16:46:23 +09:00
Hector Martin
8af401ade1 display: Also prefer <4K modes in the vertical dimension
Apparently 2:1 scaled modes like 1920x2160 are a thing?

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 16:08:39 +09:00
Sven Peter
0a1a9348c3 kboot: try SEPROM for the random seeds first
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-03-19 02:33:54 +09:00
Sven Peter
4c62ef47ad kboot: split off dt_set_rng_seed
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-03-19 02:33:54 +09:00
Sven Peter
4e5a949382 sep: add simple SEP TRNG API
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-03-19 02:33:54 +09:00
Hector Martin
bad5aebc7d kboot: Forward kblang code to asahi,kblang-code
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-18 06:56:57 +09:00
Hector Martin
d4635f60e2 chainload: Properly reserve memory for everything up to bootargs
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-16 01:56:57 +09:00
Hector Martin
3331d9e1e1 kboot: Properly prune cpu-map and IRQ affinities for missing CPUs
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-14 21:09:20 +09:00
Hector Martin
d580963043 smp: Guard CPU indexes > MAX_CPUS
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-14 21:08:07 +09:00
Hector Martin
29adf670b5 payload: Fix /chosen arg setting
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-11 22:12:22 +09:00
Hector Martin
d161de0037 nvme: Stop CPU properly on shutdown
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-10 04:01:15 +09:00
Hector Martin
82ec1695ba payload: Fix broken chosen var handling
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-10 00:30:31 +09:00
Hector Martin
4575b35479 rust: Initial Rust-based EFI FAT32 chainloader
This code is gated behind the CHAINLOADING define. To build a
release-style m1n1 with chainloading for use with the installer
or kmutil, use:

make CHAINLOADING=1 RELEASE=1

To tell m1n1 to chainload another binary, use this var payload:

chainload=<ESP partition UUID>;<file path>

e.g.

chainload=a17b7e46-e950-bb4f-bc82-8ab1047a058e;m1n1/m1n1.bin

Closes: #154
Co-authored-by: Finn Behrens <me@kloenk.dev>
Co-authored-by: Joey Gouly <joey.gouly@arm.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 22:01:42 +09:00
Hector Martin
e386e17550 chainload: Add new m1n1-side chainloader (raw images only)
This basically duplicates the chainload.py logic, minus the mach-o
handling.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
0a8a593cdc payload: Support passing arbitrary /chosen arguments
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
78c8c4d7d6 payload: Skip hypothetical m1n1 signatures
Tentative header format: 'm1n1_sig' followed by u32 total size (inclusive).

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
6a1a9bfc3c utils: Expand vector_args from 4 to 5 arguments
This also expands the usual call/next stage functions to match.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
963b74765c adt: Add adt_setprop()
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
123d1df1a7 kboot: Replace kboot_set_bootargs with kboot_set_chosen
This allows setting arbitrary /chosen string props

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-09 20:55:34 +09:00
Hector Martin
adb1cb943e proxy: Export smp_set_wfe_mode
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-08 00:02:06 +09:00
Hector Martin
a2944fa123 clk: Initialize MCA clock muxes
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-08 00:02:06 +09:00
Hector Martin
616fedaf62 nvme: Shut down the controller cleanly
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-07 23:59:25 +09:00
Hector Martin
bb7c7dd0ce proxy: Pass through nvme retvals properly
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-07 23:59:25 +09:00
Hector Martin
191cb157fb rtkit: Better error handling
Now failures during init/shutdown won't cause a hang.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-07 23:59:25 +09:00
Hector Martin
287a963bcc kboot: Hide the notch
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-22 01:04:55 +09:00
Hector Martin
5531b9ae32 display: statify local functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-22 00:54:17 +09:00
Hector Martin
5aaedef975 main: Add RELEASE mode features
- Hide console by default unless booting in verbose mode.
- In verbose mode, enable USB early and poll for connection before
  launching payloads.
- Show console on fallback to proxy.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-22 00:30:54 +09:00
Hector Martin
a9088e2278 fb: Add the ability to defer FB console activation
This differs from removing the IODEV usage in that console contents
are still buffered.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-21 16:06:14 +09:00
Hector Martin
d1dcf16c66 display: Update boot args in place for HV guests
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-21 16:03:23 +09:00
Hector Martin
50a9593034 mcc: Add mcc_hv_unmap_carveouts() and proxy op
This is necessary to stop the guest from speculating into carveouts.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-21 15:30:21 +09:00
Martin Povišer
7bab3d0fc3 exception: Fix silent mode
Do not forget to clear the L2C_ERR flags in silent mode also. This is
necessary for proper recovery.

Signed-off-by: Martin Povišer <povik@protonmail.com>
2022-02-14 11:47:04 +09:00
Hector Martin
6f525fc0f1 smp: Skip missing CPUs and continue
This will probably fix missing CPUs on low-binned machines

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-08 13:35:49 +09:00
Janne Grunau
1903dbd17e kboot: reload dt offset after dt_set_uboot_dm_preloc
Fixes adding "u-boot,dm-pre-reloc" to all required power-management
nodes on t600x.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-02-07 01:02:21 +09:00
Hector Martin
7697e992b0 fb: Fix init message pointer
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-06 15:41:30 +09:00
Hector Martin
e1a7deb2d5 i2c: Increase low-level timeouts to 50ms.
Hopefully this will cover all corner cases of the Ace2s being slow.

Issue: #101
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-06 15:36:22 +09:00
Sven Peter
cad8df30ce nvme: delete IO SQ/CQ when shutting down
This should not be required but it looks like the 12.1 ANS2 firmware
complains when NVME_CC.EN is cleared before the IO queues have been
deleted.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-02-02 22:57:54 +09:00
Sven Peter
768be5bd58 sart: fix sart3_set_entry
writel_relaxed(val, addr) inside Linux but write32(addr, val) inside
m1n1 confused my muscle memory.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-02-02 22:57:54 +09:00
Sven Peter
2ee920d229 sart: fix for 12.1
Looks like Apple decided to change the compatible to sart,coastguard and rely
on the sart-version ADT property to differentiate between M1 and M1 Pro/Max
instead. sart-version is already present in the 11.x ADT so let's just
always decide based on that.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-02-02 22:57:54 +09:00
Hector Martin
fbc15bd77c payload: Consider an IMG4 blob as the end of payloads
When loading m1n1.bin, SEPFW follows m1n1 and thus will show up at
the payload offset if there are no payloads.

Fixes: #158
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-01 15:52:08 +09:00
Sven Peter
ccf4b20a1d proxy: add nvme_{read,flush}
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Sven Peter
5f17b4743e nvme: bring up controller and implement nvme_read
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Sven Peter
54ff538df9 asc: use timeout_*
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Sven Peter
2bbf994089 utils: add timeout_{calculate,expired}
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Sven Peter
21fec139bf utils: add write64_lo_hi
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Sven Peter
bbea5167d5 rtkit: fix RTKIT_SYSLOG
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-26 15:38:40 +09:00
Mark Kettenis
30d6c6374d kboot: Add u-boot,dm-pre-reloc properties
These properties are needed such that U-Boot can enable the
serial port in its early pre-relocation phase.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2022-01-26 15:37:47 +09:00
Sven Peter
2bd7bf4020 afk: use version 3 for epic_sub_hdr
This drops the tx/rxcookie and accepts TYPE_NOTIFY in addition to
TYPE_REPLY for command replies to make the DCP code also work on 11.x.

It'll still complain about an unexpected message during init but work.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-19 03:24:20 +09:00
Hector Martin
f20a0fbcd5 rtkit: Do not ack prealloc'd buffers
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-19 03:23:42 +09:00
Sven Peter
2c28e13d25 rtkit: add rtkit_{hibernate,sleep} and use them for DCP and ANS2
s/IDLE/HIBERNATE/ to keep in sync with the Linux driver and then
hibernate DCP but send ANS2 to sleep to allow reusing both.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-18 11:35:45 +09:00
Sven Peter
00404e9bc3 afk: propagate failures in afk_epic_rx correctly
If the co-processor crashes afk_epic_poll will always fail which results
in afk_epic_rx getting stuck in an infinite loop calling afk_epic_poll
again and again.
This happens with e.g. old/incompatible DCP firmware.
Make sure the m1n1 proxy still works in those cases by propagating the
error correctly.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-01-18 11:33:57 +09:00
Janne Grunau
b2cb605832 display: Retry dcp_ib_get_hpd() for up to 2 seconds
After boot DCP will need some time to detect connected displays.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-01-17 23:12:49 +09:00
Vincent Duvert
6736368275 rtkit.c: Add config.h include
Needed for the RTKIT_SYSLOG optional define.

Signed-off-by: Vincent Duvert <vincent@duvert.net>
2022-01-17 23:11:27 +09:00
Hector Martin
b9a7827900 main: Drop copyright year from copyright statement
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 14:41:44 +09:00
Hector Martin
f1033a97b2 afk: Fix error return for bad queue entry
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 14:33:27 +09:00
Hector Martin
1c2a2db1dd display: Add logic to initialize the Mac Mini HDMI display
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
eaadc43fbb dcp: Add DCP and iBoot protocol support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
3f9bd38b6f afk: Add AFK/EPIC subsystem
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
ae1d7c4348 rtkit: Fix bug with version selection
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
476710410c rtkit: Change initial power state to 0x220
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
ca77566441 rtkit: Make rtkit_recv() return an int
This allows distinguishing between error and no message conditions.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
15bce29775 rtkit: Add basic crashlog support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
9b5cb569e4 rtkit: Buffer handling refactor
This adds support for using preallocated buffers & more

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
8f3118d99f rtkit: Add syslog support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
94bc563433 rtkit: Add dummy OSLog support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
7fc207eb35 iova: Add range arguments to iovad_init()
This allows restricting the IOVA range so as to not overlap with
prealloc'd ranges.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
847036b2ce iodev: Bump console buffer to 8K
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
18ceb3b3ff asc: Use 0x8000 offset for mbox regs
Not sure where 0x4000 came from?

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
a4c5b64655 asc: Add asc_get_iop_node()
The IOP child node in the ADT contains properties that the RTKit driver
needs to handle it properly.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00
Hector Martin
42c4334675 dart: Add dart_translate() & dart_search()
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00