bootx_init.c 16 KB

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