bootx_init.c 16 KB

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