bootx_init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*
  2. * Early boot support code for BootX bootloader
  3. *
  4. * Copyright (C) 2005 Ben. Herrenschmidt (benh@kernel.crashing.org)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/string.h>
  13. #include <linux/init.h>
  14. #include <generated/utsrelease.h>
  15. #include <asm/sections.h>
  16. #include <asm/prom.h>
  17. #include <asm/page.h>
  18. #include <asm/bootx.h>
  19. #include <asm/btext.h>
  20. #include <asm/io.h>
  21. #include <asm/setup.h>
  22. #undef DEBUG
  23. #define SET_BOOT_BAT
  24. #ifdef DEBUG
  25. #define DBG(fmt...) do { bootx_printf(fmt); } while(0)
  26. #else
  27. #define DBG(fmt...) do { } while(0)
  28. #endif
  29. extern void __start(unsigned long r3, unsigned long r4, unsigned long r5);
  30. static unsigned long __initdata bootx_dt_strbase;
  31. static unsigned long __initdata bootx_dt_strend;
  32. static unsigned long __initdata bootx_node_chosen;
  33. static boot_infos_t * __initdata bootx_info;
  34. static char __initdata bootx_disp_path[256];
  35. /* Is boot-info compatible ? */
  36. #define BOOT_INFO_IS_COMPATIBLE(bi) \
  37. ((bi)->compatible_version <= BOOT_INFO_VERSION)
  38. #define BOOT_INFO_IS_V2_COMPATIBLE(bi) ((bi)->version >= 2)
  39. #define BOOT_INFO_IS_V4_COMPATIBLE(bi) ((bi)->version >= 4)
  40. #ifdef CONFIG_BOOTX_TEXT
  41. static void __init bootx_printf(const char *format, ...)
  42. {
  43. const char *p, *q, *s;
  44. va_list args;
  45. unsigned long v;
  46. va_start(args, format);
  47. for (p = format; *p != 0; p = q) {
  48. for (q = p; *q != 0 && *q != '\n' && *q != '%'; ++q)
  49. ;
  50. if (q > p)
  51. btext_drawtext(p, q - p);
  52. if (*q == 0)
  53. break;
  54. if (*q == '\n') {
  55. ++q;
  56. btext_flushline();
  57. btext_drawstring("\r\n");
  58. btext_flushline();
  59. continue;
  60. }
  61. ++q;
  62. if (*q == 0)
  63. break;
  64. switch (*q) {
  65. case 's':
  66. ++q;
  67. s = va_arg(args, const char *);
  68. if (s == NULL)
  69. s = "<NULL>";
  70. btext_drawstring(s);
  71. break;
  72. case 'x':
  73. ++q;
  74. v = va_arg(args, unsigned long);
  75. btext_drawhex(v);
  76. break;
  77. }
  78. }
  79. va_end(args);
  80. }
  81. #else /* CONFIG_BOOTX_TEXT */
  82. static void __init bootx_printf(const char *format, ...) {}
  83. #endif /* CONFIG_BOOTX_TEXT */
  84. static void * __init bootx_early_getprop(unsigned long base,
  85. unsigned long node,
  86. char *prop)
  87. {
  88. struct bootx_dt_node *np = (struct bootx_dt_node *)(base + node);
  89. u32 *ppp = &np->properties;
  90. while(*ppp) {
  91. struct bootx_dt_prop *pp =
  92. (struct bootx_dt_prop *)(base + *ppp);
  93. if (strcmp((char *)((unsigned long)pp->name + base),
  94. prop) == 0) {
  95. return (void *)((unsigned long)pp->value + base);
  96. }
  97. ppp = &pp->next;
  98. }
  99. return NULL;
  100. }
  101. #define dt_push_token(token, mem) \
  102. do { \
  103. *(mem) = _ALIGN_UP(*(mem),4); \
  104. *((u32 *)*(mem)) = token; \
  105. *(mem) += 4; \
  106. } while(0)
  107. static unsigned long __init bootx_dt_find_string(char *str)
  108. {
  109. char *s, *os;
  110. s = os = (char *)bootx_dt_strbase;
  111. s += 4;
  112. while (s < (char *)bootx_dt_strend) {
  113. if (strcmp(s, str) == 0)
  114. return s - os;
  115. s += strlen(s) + 1;
  116. }
  117. return 0;
  118. }
  119. static void __init bootx_dt_add_prop(char *name, void *data, int size,
  120. unsigned long *mem_end)
  121. {
  122. unsigned long soff = bootx_dt_find_string(name);
  123. if (data == NULL)
  124. size = 0;
  125. if (soff == 0) {
  126. bootx_printf("WARNING: Can't find string index for <%s>\n",
  127. name);
  128. return;
  129. }
  130. if (size > 0x20000) {
  131. bootx_printf("WARNING: ignoring large property ");
  132. bootx_printf("%s length 0x%x\n", name, size);
  133. return;
  134. }
  135. dt_push_token(OF_DT_PROP, mem_end);
  136. dt_push_token(size, mem_end);
  137. dt_push_token(soff, mem_end);
  138. /* push property content */
  139. if (size && data) {
  140. memcpy((void *)*mem_end, data, size);
  141. *mem_end = _ALIGN_UP(*mem_end + size, 4);
  142. }
  143. }
  144. static void __init bootx_add_chosen_props(unsigned long base,
  145. unsigned long *mem_end)
  146. {
  147. u32 val;
  148. bootx_dt_add_prop("linux,bootx", NULL, 0, mem_end);
  149. if (bootx_info->kernelParamsOffset) {
  150. char *args = (char *)((unsigned long)bootx_info) +
  151. bootx_info->kernelParamsOffset;
  152. bootx_dt_add_prop("bootargs", args, strlen(args) + 1, mem_end);
  153. }
  154. if (bootx_info->ramDisk) {
  155. val = ((unsigned long)bootx_info) + bootx_info->ramDisk;
  156. bootx_dt_add_prop("linux,initrd-start", &val, 4, mem_end);
  157. val += bootx_info->ramDiskSize;
  158. bootx_dt_add_prop("linux,initrd-end", &val, 4, mem_end);
  159. }
  160. if (strlen(bootx_disp_path))
  161. bootx_dt_add_prop("linux,stdout-path", bootx_disp_path,
  162. strlen(bootx_disp_path) + 1, mem_end);
  163. }
  164. static void __init bootx_add_display_props(unsigned long base,
  165. unsigned long *mem_end,
  166. int has_real_node)
  167. {
  168. boot_infos_t *bi = bootx_info;
  169. u32 tmp;
  170. if (has_real_node) {
  171. bootx_dt_add_prop("linux,boot-display", NULL, 0, mem_end);
  172. bootx_dt_add_prop("linux,opened", NULL, 0, mem_end);
  173. } else
  174. bootx_dt_add_prop("linux,bootx-noscreen", NULL, 0, mem_end);
  175. tmp = bi->dispDeviceDepth;
  176. bootx_dt_add_prop("linux,bootx-depth", &tmp, 4, mem_end);
  177. tmp = bi->dispDeviceRect[2] - bi->dispDeviceRect[0];
  178. bootx_dt_add_prop("linux,bootx-width", &tmp, 4, mem_end);
  179. tmp = bi->dispDeviceRect[3] - bi->dispDeviceRect[1];
  180. bootx_dt_add_prop("linux,bootx-height", &tmp, 4, mem_end);
  181. tmp = bi->dispDeviceRowBytes;
  182. bootx_dt_add_prop("linux,bootx-linebytes", &tmp, 4, mem_end);
  183. tmp = (u32)bi->dispDeviceBase;
  184. if (tmp == 0)
  185. tmp = (u32)bi->logicalDisplayBase;
  186. tmp += bi->dispDeviceRect[1] * bi->dispDeviceRowBytes;
  187. tmp += bi->dispDeviceRect[0] * ((bi->dispDeviceDepth + 7) / 8);
  188. bootx_dt_add_prop("linux,bootx-addr", &tmp, 4, mem_end);
  189. }
  190. static void __init bootx_dt_add_string(char *s, unsigned long *mem_end)
  191. {
  192. unsigned int l = strlen(s) + 1;
  193. memcpy((void *)*mem_end, s, l);
  194. bootx_dt_strend = *mem_end = *mem_end + l;
  195. }
  196. static void __init bootx_scan_dt_build_strings(unsigned long base,
  197. unsigned long node,
  198. unsigned long *mem_end)
  199. {
  200. struct bootx_dt_node *np = (struct bootx_dt_node *)(base + node);
  201. u32 *cpp, *ppp = &np->properties;
  202. unsigned long soff;
  203. char *namep;
  204. /* Keep refs to known nodes */
  205. namep = np->full_name ? (char *)(base + np->full_name) : NULL;
  206. if (namep == NULL) {
  207. bootx_printf("Node without a full name !\n");
  208. namep = "";
  209. }
  210. DBG("* strings: %s\n", namep);
  211. if (!strcmp(namep, "/chosen")) {
  212. DBG(" detected /chosen ! adding properties names !\n");
  213. bootx_dt_add_string("linux,bootx", mem_end);
  214. bootx_dt_add_string("linux,stdout-path", mem_end);
  215. bootx_dt_add_string("linux,initrd-start", mem_end);
  216. bootx_dt_add_string("linux,initrd-end", mem_end);
  217. bootx_dt_add_string("bootargs", mem_end);
  218. bootx_node_chosen = node;
  219. }
  220. if (node == bootx_info->dispDeviceRegEntryOffset) {
  221. DBG(" detected display ! adding properties names !\n");
  222. bootx_dt_add_string("linux,boot-display", mem_end);
  223. bootx_dt_add_string("linux,opened", mem_end);
  224. strlcpy(bootx_disp_path, namep, sizeof(bootx_disp_path));
  225. }
  226. /* get and store all property names */
  227. while (*ppp) {
  228. struct bootx_dt_prop *pp =
  229. (struct bootx_dt_prop *)(base + *ppp);
  230. namep = pp->name ? (char *)(base + pp->name) : NULL;
  231. if (namep == NULL || strcmp(namep, "name") == 0)
  232. goto next;
  233. /* get/create string entry */
  234. soff = bootx_dt_find_string(namep);
  235. if (soff == 0)
  236. bootx_dt_add_string(namep, mem_end);
  237. next:
  238. ppp = &pp->next;
  239. }
  240. /* do all our children */
  241. cpp = &np->child;
  242. while(*cpp) {
  243. np = (struct bootx_dt_node *)(base + *cpp);
  244. bootx_scan_dt_build_strings(base, *cpp, mem_end);
  245. cpp = &np->sibling;
  246. }
  247. }
  248. static void __init bootx_scan_dt_build_struct(unsigned long base,
  249. unsigned long node,
  250. unsigned long *mem_end)
  251. {
  252. struct bootx_dt_node *np = (struct bootx_dt_node *)(base + node);
  253. u32 *cpp, *ppp = &np->properties;
  254. char *namep, *p, *ep, *lp;
  255. int l;
  256. dt_push_token(OF_DT_BEGIN_NODE, mem_end);
  257. /* get the node's full name */
  258. namep = np->full_name ? (char *)(base + np->full_name) : NULL;
  259. if (namep == NULL)
  260. namep = "";
  261. l = strlen(namep);
  262. DBG("* struct: %s\n", namep);
  263. /* Fixup an Apple bug where they have bogus \0 chars in the
  264. * middle of the path in some properties, and extract
  265. * the unit name (everything after the last '/').
  266. */
  267. memcpy((void *)*mem_end, namep, l + 1);
  268. namep = (char *)*mem_end;
  269. for (lp = p = namep, ep = namep + l; p < ep; p++) {
  270. if (*p == '/')
  271. lp = namep;
  272. else if (*p != 0)
  273. *lp++ = *p;
  274. }
  275. *lp = 0;
  276. *mem_end = _ALIGN_UP((unsigned long)lp + 1, 4);
  277. /* get and store all properties */
  278. while (*ppp) {
  279. struct bootx_dt_prop *pp =
  280. (struct bootx_dt_prop *)(base + *ppp);
  281. namep = pp->name ? (char *)(base + pp->name) : NULL;
  282. /* Skip "name" */
  283. if (namep == NULL || !strcmp(namep, "name"))
  284. goto next;
  285. /* Skip "bootargs" in /chosen too as we replace it */
  286. if (node == bootx_node_chosen && !strcmp(namep, "bootargs"))
  287. goto next;
  288. /* push property head */
  289. bootx_dt_add_prop(namep,
  290. pp->value ? (void *)(base + pp->value): NULL,
  291. pp->length, mem_end);
  292. next:
  293. ppp = &pp->next;
  294. }
  295. if (node == bootx_node_chosen) {
  296. bootx_add_chosen_props(base, mem_end);
  297. if (bootx_info->dispDeviceRegEntryOffset == 0)
  298. bootx_add_display_props(base, mem_end, 0);
  299. }
  300. else if (node == bootx_info->dispDeviceRegEntryOffset)
  301. bootx_add_display_props(base, mem_end, 1);
  302. /* do all our children */
  303. cpp = &np->child;
  304. while(*cpp) {
  305. np = (struct bootx_dt_node *)(base + *cpp);
  306. bootx_scan_dt_build_struct(base, *cpp, mem_end);
  307. cpp = &np->sibling;
  308. }
  309. dt_push_token(OF_DT_END_NODE, mem_end);
  310. }
  311. static unsigned long __init bootx_flatten_dt(unsigned long start)
  312. {
  313. boot_infos_t *bi = bootx_info;
  314. unsigned long mem_start, mem_end;
  315. struct boot_param_header *hdr;
  316. unsigned long base;
  317. u64 *rsvmap;
  318. /* Start using memory after the big blob passed by BootX, get
  319. * some space for the header
  320. */
  321. mem_start = mem_end = _ALIGN_UP(((unsigned long)bi) + start, 4);
  322. DBG("Boot params header at: %x\n", mem_start);
  323. hdr = (struct boot_param_header *)mem_start;
  324. mem_end += sizeof(struct boot_param_header);
  325. rsvmap = (u64 *)(_ALIGN_UP(mem_end, 8));
  326. hdr->off_mem_rsvmap = ((unsigned long)rsvmap) - mem_start;
  327. mem_end = ((unsigned long)rsvmap) + 8 * sizeof(u64);
  328. /* Get base of tree */
  329. base = ((unsigned long)bi) + bi->deviceTreeOffset;
  330. /* Build string array */
  331. DBG("Building string array at: %x\n", mem_end);
  332. DBG("Device Tree Base=%x\n", base);
  333. bootx_dt_strbase = mem_end;
  334. mem_end += 4;
  335. bootx_dt_strend = mem_end;
  336. bootx_scan_dt_build_strings(base, 4, &mem_end);
  337. /* Add some strings */
  338. bootx_dt_add_string("linux,bootx-noscreen", &mem_end);
  339. bootx_dt_add_string("linux,bootx-depth", &mem_end);
  340. bootx_dt_add_string("linux,bootx-width", &mem_end);
  341. bootx_dt_add_string("linux,bootx-height", &mem_end);
  342. bootx_dt_add_string("linux,bootx-linebytes", &mem_end);
  343. bootx_dt_add_string("linux,bootx-addr", &mem_end);
  344. /* Wrap up strings */
  345. hdr->off_dt_strings = bootx_dt_strbase - mem_start;
  346. hdr->dt_strings_size = bootx_dt_strend - bootx_dt_strbase;
  347. /* Build structure */
  348. mem_end = _ALIGN(mem_end, 16);
  349. DBG("Building device tree structure at: %x\n", mem_end);
  350. hdr->off_dt_struct = mem_end - mem_start;
  351. bootx_scan_dt_build_struct(base, 4, &mem_end);
  352. dt_push_token(OF_DT_END, &mem_end);
  353. /* Finish header */
  354. hdr->boot_cpuid_phys = 0;
  355. hdr->magic = OF_DT_HEADER;
  356. hdr->totalsize = mem_end - mem_start;
  357. hdr->version = OF_DT_VERSION;
  358. /* Version 16 is not backward compatible */
  359. hdr->last_comp_version = 0x10;
  360. /* Reserve the whole thing and copy the reserve map in, we
  361. * also bump mem_reserve_cnt to cause further reservations to
  362. * fail since it's too late.
  363. */
  364. mem_end = _ALIGN(mem_end, PAGE_SIZE);
  365. DBG("End of boot params: %x\n", mem_end);
  366. rsvmap[0] = mem_start;
  367. rsvmap[1] = mem_end;
  368. if (bootx_info->ramDisk) {
  369. rsvmap[2] = ((unsigned long)bootx_info) + bootx_info->ramDisk;
  370. rsvmap[3] = rsvmap[2] + bootx_info->ramDiskSize;
  371. rsvmap[4] = 0;
  372. rsvmap[5] = 0;
  373. } else {
  374. rsvmap[2] = 0;
  375. rsvmap[3] = 0;
  376. }
  377. return (unsigned long)hdr;
  378. }
  379. #ifdef CONFIG_BOOTX_TEXT
  380. static void __init btext_welcome(boot_infos_t *bi)
  381. {
  382. unsigned long flags;
  383. unsigned long pvr;
  384. bootx_printf("Welcome to Linux, kernel " UTS_RELEASE "\n");
  385. bootx_printf("\nlinked at : 0x%x", KERNELBASE);
  386. bootx_printf("\nframe buffer at : 0x%x", bi->dispDeviceBase);
  387. bootx_printf(" (phys), 0x%x", bi->logicalDisplayBase);
  388. bootx_printf(" (log)");
  389. bootx_printf("\nklimit : 0x%x",(unsigned long)klimit);
  390. bootx_printf("\nboot_info at : 0x%x", bi);
  391. __asm__ __volatile__ ("mfmsr %0" : "=r" (flags));
  392. bootx_printf("\nMSR : 0x%x", flags);
  393. __asm__ __volatile__ ("mfspr %0, 287" : "=r" (pvr));
  394. bootx_printf("\nPVR : 0x%x", pvr);
  395. pvr >>= 16;
  396. if (pvr > 1) {
  397. __asm__ __volatile__ ("mfspr %0, 1008" : "=r" (flags));
  398. bootx_printf("\nHID0 : 0x%x", flags);
  399. }
  400. if (pvr == 8 || pvr == 12 || pvr == 0x800c) {
  401. __asm__ __volatile__ ("mfspr %0, 1019" : "=r" (flags));
  402. bootx_printf("\nICTC : 0x%x", flags);
  403. }
  404. #ifdef DEBUG
  405. bootx_printf("\n\n");
  406. bootx_printf("bi->deviceTreeOffset : 0x%x\n",
  407. bi->deviceTreeOffset);
  408. bootx_printf("bi->deviceTreeSize : 0x%x\n",
  409. bi->deviceTreeSize);
  410. #endif
  411. bootx_printf("\n\n");
  412. }
  413. #endif /* CONFIG_BOOTX_TEXT */
  414. void __init bootx_init(unsigned long r3, unsigned long r4)
  415. {
  416. boot_infos_t *bi = (boot_infos_t *) r4;
  417. unsigned long hdr;
  418. unsigned long space;
  419. unsigned long ptr;
  420. char *model;
  421. unsigned long offset = reloc_offset();
  422. reloc_got2(offset);
  423. bootx_info = bi;
  424. /* We haven't cleared any bss at this point, make sure
  425. * what we need is initialized
  426. */
  427. bootx_dt_strbase = bootx_dt_strend = 0;
  428. bootx_node_chosen = 0;
  429. bootx_disp_path[0] = 0;
  430. if (!BOOT_INFO_IS_V2_COMPATIBLE(bi))
  431. bi->logicalDisplayBase = bi->dispDeviceBase;
  432. /* Fixup depth 16 -> 15 as that's what MacOS calls 16bpp */
  433. if (bi->dispDeviceDepth == 16)
  434. bi->dispDeviceDepth = 15;
  435. #ifdef CONFIG_BOOTX_TEXT
  436. ptr = (unsigned long)bi->logicalDisplayBase;
  437. ptr += bi->dispDeviceRect[1] * bi->dispDeviceRowBytes;
  438. ptr += bi->dispDeviceRect[0] * ((bi->dispDeviceDepth + 7) / 8);
  439. btext_setup_display(bi->dispDeviceRect[2] - bi->dispDeviceRect[0],
  440. bi->dispDeviceRect[3] - bi->dispDeviceRect[1],
  441. bi->dispDeviceDepth, bi->dispDeviceRowBytes,
  442. (unsigned long)bi->logicalDisplayBase);
  443. btext_clearscreen();
  444. btext_flushscreen();
  445. #endif /* CONFIG_BOOTX_TEXT */
  446. /*
  447. * Test if boot-info is compatible. Done only in config
  448. * CONFIG_BOOTX_TEXT since there is nothing much we can do
  449. * with an incompatible version, except display a message
  450. * and eventually hang the processor...
  451. *
  452. * I'll try to keep enough of boot-info compatible in the
  453. * future to always allow display of this message;
  454. */
  455. if (!BOOT_INFO_IS_COMPATIBLE(bi)) {
  456. bootx_printf(" !!! WARNING - Incompatible version"
  457. " of BootX !!!\n\n\n");
  458. for (;;)
  459. ;
  460. }
  461. if (bi->architecture != BOOT_ARCH_PCI) {
  462. bootx_printf(" !!! WARNING - Usupported machine"
  463. " architecture !\n");
  464. for (;;)
  465. ;
  466. }
  467. #ifdef CONFIG_BOOTX_TEXT
  468. btext_welcome(bi);
  469. #endif
  470. /* New BootX enters kernel with MMU off, i/os are not allowed
  471. * here. This hack will have been done by the boostrap anyway.
  472. */
  473. if (bi->version < 4) {
  474. /*
  475. * XXX If this is an iMac, turn off the USB controller.
  476. */
  477. model = (char *) bootx_early_getprop(r4 + bi->deviceTreeOffset,
  478. 4, "model");
  479. if (model
  480. && (strcmp(model, "iMac,1") == 0
  481. || strcmp(model, "PowerMac1,1") == 0)) {
  482. bootx_printf("iMac,1 detected, shutting down USB\n");
  483. out_le32((unsigned __iomem *)0x80880008, 1); /* XXX */
  484. }
  485. }
  486. /* Get a pointer that points above the device tree, args, ramdisk,
  487. * etc... to use for generating the flattened tree
  488. */
  489. if (bi->version < 5) {
  490. space = bi->deviceTreeOffset + bi->deviceTreeSize;
  491. if (bi->ramDisk >= space)
  492. space = bi->ramDisk + bi->ramDiskSize;
  493. } else
  494. space = bi->totalParamsSize;
  495. bootx_printf("Total space used by parameters & ramdisk: 0x%x\n", space);
  496. /* New BootX will have flushed all TLBs and enters kernel with
  497. * MMU switched OFF, so this should not be useful anymore.
  498. */
  499. if (bi->version < 4) {
  500. unsigned long x __maybe_unused;
  501. bootx_printf("Touching pages...\n");
  502. /*
  503. * Touch each page to make sure the PTEs for them
  504. * are in the hash table - the aim is to try to avoid
  505. * getting DSI exceptions while copying the kernel image.
  506. */
  507. for (ptr = ((unsigned long) &_stext) & PAGE_MASK;
  508. ptr < (unsigned long)bi + space; ptr += PAGE_SIZE)
  509. x = *(volatile unsigned long *)ptr;
  510. }
  511. /* Ok, now we need to generate a flattened device-tree to pass
  512. * to the kernel
  513. */
  514. bootx_printf("Preparing boot params...\n");
  515. hdr = bootx_flatten_dt(space);
  516. #ifdef CONFIG_BOOTX_TEXT
  517. #ifdef SET_BOOT_BAT
  518. bootx_printf("Preparing BAT...\n");
  519. btext_prepare_BAT();
  520. #else
  521. btext_unmap();
  522. #endif
  523. #endif
  524. reloc_got2(-offset);
  525. __start(hdr, KERNELBASE + offset, 0);
  526. }