@@ -245,6 +245,7 @@ __attribute__((noinline)) void pongo_entry_cached()
245245 {
246246 default : // >4
247247 case BOOT_FLAG_RAW : // 4
248+ case BOOT_FLAG_M1N1 : // 3
248249 break ;
249250
250251 case BOOT_FLAG_HOOK : // 2
@@ -291,7 +292,7 @@ __attribute__((noinline)) void pongo_entry_cached()
291292*/
292293extern void set_exception_stack_core0 ();
293294extern void lowlevel_set_identity (void );
294- extern _Noreturn void jump_to_image_extended (uint64_t image , uint64_t args , uint64_t tramp , uint64_t original_image );
295+ extern _Noreturn void jump_to_image_extended (void * image , void * args , void * tramp , void * original_image );
295296extern uint64_t gPongoSlide ;
296297
297298_Noreturn void pongo_entry (uint64_t * kernel_args , void * entryp , void (* exit_to_el1_image )(void * boot_args , void * boot_entry_point , void * trampoline ))
@@ -308,23 +309,32 @@ _Noreturn void pongo_entry(uint64_t *kernel_args, void *entryp, void (*exit_to_e
308309 set_exception_stack_core0 ();
309310 gFramebuffer = (uint32_t * )gBootArgs -> Video .v_baseAddr ;
310311 lowlevel_cleanup ();
311- if (gBootFlag == BOOT_FLAG_RAW )
312+
313+ // Unused space above kernel static area
314+ void * boot_tramp = (void * )((gTopOfKernelData + 0x3fffULL ) & ~0x3fffULL );
315+ if (gBootFlag == BOOT_FLAG_RAW || gBootFlag == BOOT_FLAG_M1N1 )
312316 {
313317 // We're in EL1 here, but we might need to go back to EL3
314- uint64_t pfr0 ;
315- __asm__ volatile ("mrs %0, id_aa64pfr0_el1" : "=r" (pfr0 ));
316- if ((pfr0 & 0xf000 ) != 0 )
318+ if ((__builtin_arm_rsr64 ("id_aa64pfr0_el1" ) & 0xf000 ) != 0 )
317319 {
318320 __asm__ volatile ("smc 0" ); // elevate to EL3
319321 }
322+ uint64_t entryOff = 0x800 ;
323+ if (gBootFlag == BOOT_FLAG_RAW )
324+ {
325+ boot_tramp = NULL ;
326+ entryOff = 0 ;
327+ }
320328 // XXX: We should really replace loader_xfer_recv_data with something dedicated here.
321- jump_to_image_extended (((uint64_t )loader_xfer_recv_data ) - kCacheableView + 0x800000000 , (uint64_t )gBootArgs , 0 , (uint64_t )gEntryPoint );
329+ void * image = (void * )((uint64_t )loader_xfer_recv_data - kCacheableView + 0x800000000 + entryOff );
330+ jump_to_image_extended (image , gBootArgs , boot_tramp , gEntryPoint );
322331 }
323332 else
324333 {
325334 xnu_boot ();
326- exit_to_el1_image (gBootArgs , gEntryPoint , ( void * )(( gTopOfKernelData + 0x3fffULL ) & ~ 0x3fffULL ) );
335+ exit_to_el1_image (gBootArgs , gEntryPoint , boot_tramp );
327336 }
337+
328338 screen_puts ("didn't boot?!" );
329339 while (1 )
330340 {}
0 commit comments