📄 boot.c
字号:
&OSinfo2, ¶m); LogInfo(LOG_BOOT, ("boot_handler: message received: reason 0x%08x (%s), " "debugID 0x%08x, OSinfo1 0x%08x, OSinfo2 0x%08x, param 0x%8x\n", reason, log_adpname(reason), debugID, OSinfo1, OSinfo2, param)); if (!(reason & TtoH)) { /* We always take the precaution of setting the default dev * when we get a HBOOT message. */ angel_ChannelSelectDevice(devid); if (reason != ADP_ParamNegotiate) { LogInfo(LOG_BOOT, ( "boot_handler: release request buffer.\n")); angel_ChannelReleaseBuffer(buffer); } switch (reason) { case ADP_Booted: { if ( boot_state == BS_RESETTING#if (LATE_STARTUP > 0) && !defined(ICEMAN_LEVEL_3) || boot_state == BS_AVAILABLE#endif ) { LogInfo(LOG_BOOT, ( "Received ADP_Booted ACK.\n")); Angel_InitChannels(); Angel_InitBuffers(); boot_state = BS_CONNECTED; boot_completed = 1; /* see commentary in send_booted_message(). This call * reenables normal operation of the packet code. */ LogInfo(LOG_BOOT, ( "(Re)Enable Packet FLOW:\n")); booted_flow_controlled = 0; angel_DeviceControl(devid, DC_RX_PACKET_FLOW, (void*)1); } else LogWarning(LOG_BOOT, ( "ADP_Booted ACK received, " "state not BS_RESETTING.\n")); break; } case ADP_Reboot: { int err; LogInfo(LOG_BOOT, ( "Received ADP_Reboot request.\n")); if ((err = msgsend(CI_HBOOT, "%w%w%w%w%w", ADP_Reboot | TtoH, ADP_HandleUnknown, ADP_HandleUnknown, ADP_HandleUnknown, REBOOT_ACK)) != 0) { LogWarning(LOG_BOOT, ( "Cannot ACK Reboot: Error %d; " "aborting request\n", err)); } else { LogInfo(LOG_BOOT, ( "----------------------------------\n" "--- Rebooting...\n\n\n")); Angel_EnterSVC(); __rom(); /* should never return */ } break; } case ADP_Reset: { int reset_ack, err; bool do_reset = FALSE; LogInfo(LOG_BOOT, ( "Received ADP_Reset request.\n")); switch (boot_state) { case BS_STARTUP: { LogInfo(LOG_BOOT, ( "Deferring ADP_Reset request.\n")); reset_ack = AB_LATE_ACK; boot_state = BS_STARTUP; break; } case BS_RESETTING: { LogWarning(LOG_BOOT, ( "Already resetting.\n")); /* fall through to... */ } case BS_AVAILABLE: case BS_CONNECTED: { LogInfo(LOG_BOOT, ( "Actioning ADP_Reset_request.\n")); reset_ack = AB_NORMAL_ACK; do_reset = TRUE; boot_state = BS_RESETTING; boot_completed = FALSE; break; } default: { LogError(LOG_BOOT, ( "ERROR: bad case.\n")); reset_ack = AB_ERROR; break; } } if ((err = msgsend(CI_HBOOT, "%w%w%w%w%w", ADP_Reset | TtoH, ADP_HandleUnknown, ADP_HandleUnknown, ADP_HandleUnknown, reset_ack)) != 0) { LogWarning(LOG_BOOT, ( "Cannot ACK Reset: Error %d; " "aborting request\n", err)); } if (do_reset) { /* Initialise the the target dependant debug code. * This is needed as the debugger tool box does not * tidy up after itself and expects the target to be * initialised when the debugger starts up. */ /* Take note of the endianess of the host debugger */ LogInfo(LOG_BOOT, ( "----------------------------------\n" "--- Resetting...\n\n")); angel_debugger_endianess = param;#if LATE_STARTUP == 0 || defined(ICEMAN_LEVEL_3) angelOS_Initialise();#endif /* * Originally, the code reinitialised channels, etc, here. * However, the host code doesn't until after the booted * message is sent. As we already reinit after the booted * msg is received in the target, the initialise here can * just be deleted. */ send_booted_message(); } break; } /* end case ADP_Reset */ case ADP_ParamNegotiate: { param_negotiate(devid, buffer + (4 * 4)); LogInfo(LOG_BOOT, ( "boot_handler: release param request.\n")); angel_ChannelReleaseBuffer(buffer); break; } case ADP_LinkCheck: { LogInfo(LOG_BOOT, ( "LinkCheck Received, disable rx packet flow\n")); /* disable packet input until reinit has completed. */ angel_DeviceControl(devid, DC_RX_PACKET_FLOW, (void*)0); msgsend(CI_HBOOT, "%w%w%w%w", ADP_LinkCheck | TtoH, 0, ADP_HandleUnknown, ADP_HandleUnknown); Angel_ReinitChannels(); /* reinit ok, continue... */ LogInfo(LOG_BOOT, ( "Enable rx packet flow\n")); angel_DeviceControl(devid, DC_RX_PACKET_FLOW, (void*)1); LogInfo(LOG_BOOT, ( "LinkCheck: Reinit Channels complete.\n")); break; } default: LogWarning(LOG_BOOT, ( "boot_handler: Reason code not recognised.\n")); break; } } else LogWarning(LOG_BOOT, ( "boot_handler got TtoH message!")); return;}/*---------------------------------------------------------------------------*/voidangel_BootInit(void){ void *stateptr = NULL; ChanError err = CE_OKAY; /* Error value */ static bool registered = FALSE; LogInfo(LOG_BOOT, ( "Enter: angel_BootInit\n")); /* Register our message handler for both channels: */ /* TODO: check return value */ if (!registered) { LogInfo(LOG_BOOT, ( "registering boot handlers\n")); err = angel_ChannelReadAll(CI_HBOOT, boot_handler, stateptr); err = angel_ChannelReadAsync(CH_DEFAULT_DEV, CI_TBOOT, boot_handler, stateptr); registered = TRUE; } /* Originate the ADP_Booted message to notify the host that the * system is alive. This allows the host to start generating * standard messages. NOTE: The "debugID" field is set to unknown * here, since we have not yet had a communication from the host. */ if (boot_state == BS_AVAILABLE) { (void)send_booted_message(); } return;}voidangel_LateBootInit(unsigned int swi_code, angel_LateStartType type){ ASSERT(swi_code == angel_SWIreason_LateStartup, ("bad SWI reason %d", swi_code)); if (boot_state != BS_STARTUP) { LogError(LOG_BOOT, ( "late startup already called.")); } else { LogInfo(LOG_BOOT, ( "angel_LateBootInit\n")); switch (type) { case AL_CONTINUE: { /* do nothing other than sending the boot message */ break; } case AL_BLOCK: { Angel_BlockApplication(1); break; } default: { LogError(LOG_BOOT, ( "Unknown LateStartType %d.\n", type)); break; } } boot_state = BS_AVAILABLE; send_booted_message(); Angel_Yield(); /* to ensure BlockApplication() takes effect */ }}/* EOF boot.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -