I have a simple bootloader, which initializes and prepares SDRAM. Then it loads an application from the Flash and starts it at some address in the RAM. After the application has finished its execution, the system does restart. There is no system stack.
Now, I would like this bootloader receives control back after an application finished its execution. The bootloader (let's call it OS) must also read an application's return code.
How can an application return a value to the calling OS and how the calling OS gets control back? I suppose, it can be done using interrupts - OS has a special resident function joined with some interrupt and every application just calls this interrupt at the end of its own execution. But how can a return code be read by OS if there is no system stack?