On Fri, May 19, 2023 at 08:53:34AM +0200, Ahmad Fatoum wrote: > On 17.05.23 16:39, Sascha Hauer wrote: > > On Wed, May 17, 2023 at 03:58:01PM +0200, Ahmad Fatoum wrote: > >> On 17.05.23 11:03, Sascha Hauer wrote: > >>> Instead of relying on a variable for the location of the TTB which we > >>> have to initialize in both PBL and barebox proper, just read the value > >>> back from the hardware register. > >> > >> Why not initialize on first call to get_ttb()? > > > > get_ttb() doesn't have access to endmem which we would need to get the > > address for the ttb. > > > > Also we have the value in the hardware register, why not use it? > > I meant initialization using the hardware register. You mean something like: static uint32_t *ttb; static inline uint32_t *get_ttb(void) { if (!ttb) ttb = (uint32_t *)(get_ttbr() & ~0x3fff); return ttb; } If yes, I don't know what this is good for. If no, please explain, I don't seem to understand what you mean. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |