Skip to content

Commit a704f28

Browse files
committed
fix: some s8000 crap
1 parent 902eb91 commit a704f28

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

hw/arm/apple-silicon/boot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static const char *KEEP_COMP[] = {
117117
"otgphyctrl,s8000\0otgphyctrl,s5l8960x\0$",
118118
"pmgr1,s8000\0$",
119119
"pmgr1,t8030\0$",
120-
"pmu,d2255\0$", // problematic on S8000 (if AIC configed for T8030?)
120+
// "pmu,d2255\0$", // buggy
121121
"pmu,spmi\0pmu,avus\0$",
122122
"roswell\0$",
123123
"sart,coastguard\0$",

hw/arm/apple-silicon/s8000.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ static void s8000_load_classic_kc(S8000MachineState *s8000_machine,
306306
tz1_virt_high);
307307
AddressSpace *sas =
308308
cpu_get_address_space(CPU(s8000_machine->cpus[0]), ARMASIdx_S);
309+
if (kvm_enabled()) {
310+
sas = nsas; // HACK for KVM, but also works for TCG.
311+
}
309312
g_assert_nonnull(sas);
310313
hwaddr tz1_entry =
311314
arm_load_macho(s8000_machine->secure_monitor, sas,
@@ -478,17 +481,41 @@ static void pmgr_unk_reg_write(void *opaque, hwaddr addr, uint64_t data,
478481

479482
static uint64_t pmgr_unk_reg_read(void *opaque, hwaddr addr, unsigned size)
480483
{
484+
S8000MachineState *s8000_machine = S8000_MACHINE(qdev_get_machine());
485+
// AppleSEPState *sep;
481486
hwaddr base = (hwaddr)opaque;
482487

488+
uint32_t security_epoch = 1; // On IMG4: Security Epoch ; On IMG3: Minimum
489+
// Epoch, verified on SecureROM s5l8955xsi
490+
bool current_prod = true;
491+
bool current_secure_mode = true; // T8015 SEPOS Kernel also requires this.
492+
uint32_t security_domain = 1;
493+
bool raw_prod = true;
494+
bool raw_secure_mode = true;
495+
uint32_t sep_bit30_current_value = 0;
496+
bool fuses_locked = true;
497+
uint32_t ret = 0x0;
498+
483499
switch (base + addr) {
484500
case 0x102BC000: // CFG_FUSE0
485-
return (1 << 2);
501+
// // handle SEP DSEC demotion
502+
// if (sep != NULL && sep->pmgr_fuse_changer_bit1_was_set)
503+
// current_secure_mode = 0; // SEP DSEC img4 tag demotion active
504+
ret |= (current_prod << 0);
505+
ret |= (current_secure_mode << 1);
506+
ret |= ((security_domain & 3) << 2);
507+
ret |= ((s8000_machine->board_id & 7) << 4);
508+
ret |= ((security_epoch & 0x7f) << 9);
509+
// ret |= (( & ) << );
510+
return ret;
486511
case 0x102BC200: // CFG_FUSE0_RAW
487-
return 0x0;
512+
ret |= (raw_prod << 0);
513+
ret |= (raw_secure_mode << 1);
514+
return ret;
488515
case 0x102BC080: // ECID_LO
489-
return 0x13371337;
516+
return s8000_machine->ecid & 0xffffffff; // ECID lower
490517
case 0x102BC084: // ECID_HI
491-
return 0xDEADBEEF;
518+
return s8000_machine->ecid >> 32; // ECID upper
492519
case 0x102E8000: // ????
493520
return 0x4;
494521
case 0x102BC104: // ???? bit 24 => is fresh boot?
@@ -1037,6 +1064,8 @@ static void s8000_create_usb(S8000MachineState *s8000_machine)
10371064
s8000_machine->soc_base_pa +
10381065
((uint64_t *)prop->data)[0]);
10391066
}
1067+
// no-pmu is needed for T8015, and is also necessary for S8000.
1068+
dtb_set_prop_u32(complex, "no-pmu", 1);
10401069

10411070
sysbus_realize_and_unref(SYS_BUS_DEVICE(otg), &error_fatal);
10421071

0 commit comments

Comments
 (0)