ft_build.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /*
  2. * OF flat tree builder
  3. */
  4. #include <common.h>
  5. #include <malloc.h>
  6. #include <environment.h>
  7. #ifdef CONFIG_OF_FLAT_TREE
  8. #include <asm/errno.h>
  9. #include <stddef.h>
  10. #include <ft_build.h>
  11. /* align addr on a size boundary - adjust address up if needed -- Cort */
  12. #define _ALIGN(addr,size) (((addr)+(size)-1)&(~((size)-1)))
  13. static void ft_put_word(struct ft_cxt *cxt, u32 v)
  14. {
  15. if (cxt->overflow) /* do nothing */
  16. return;
  17. /* check for overflow */
  18. if (cxt->p + 4 > cxt->pstr) {
  19. cxt->overflow = 1;
  20. return;
  21. }
  22. *(u32 *) cxt->p = cpu_to_be32(v);
  23. cxt->p += 4;
  24. }
  25. static inline void ft_put_bin(struct ft_cxt *cxt, const void *data, int sz)
  26. {
  27. u8 *p;
  28. if (cxt->overflow) /* do nothing */
  29. return;
  30. /* next pointer pos */
  31. p = (u8 *) _ALIGN((unsigned long)cxt->p + sz, 4);
  32. /* check for overflow */
  33. if (p > cxt->pstr) {
  34. cxt->overflow = 1;
  35. return;
  36. }
  37. memcpy(cxt->p, data, sz);
  38. if ((sz & 3) != 0)
  39. memset(cxt->p + sz, 0, 4 - (sz & 3));
  40. cxt->p = p;
  41. }
  42. void ft_begin_node(struct ft_cxt *cxt, const char *name)
  43. {
  44. ft_put_word(cxt, OF_DT_BEGIN_NODE);
  45. ft_put_bin(cxt, name, strlen(name) + 1);
  46. }
  47. void ft_end_node(struct ft_cxt *cxt)
  48. {
  49. ft_put_word(cxt, OF_DT_END_NODE);
  50. }
  51. void ft_nop(struct ft_cxt *cxt)
  52. {
  53. ft_put_word(cxt, OF_DT_NOP);
  54. }
  55. static int lookup_string(struct ft_cxt *cxt, const char *name)
  56. {
  57. u8 *p;
  58. p = cxt->pstr;
  59. while (p < cxt->pstr_begin) {
  60. if (strcmp(p, name) == 0)
  61. return p - cxt->p_begin;
  62. p += strlen(p) + 1;
  63. }
  64. return -1;
  65. }
  66. void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz)
  67. {
  68. int len, off;
  69. if (cxt->overflow)
  70. return;
  71. len = strlen(name) + 1;
  72. off = lookup_string(cxt, name);
  73. if (off == -1) {
  74. /* check if we have space */
  75. if (cxt->p + 12 + sz + len > cxt->pstr) {
  76. cxt->overflow = 1;
  77. return;
  78. }
  79. cxt->pstr -= len;
  80. memcpy(cxt->pstr, name, len);
  81. off = cxt->pstr - cxt->p_begin;
  82. }
  83. /* now put offset from beginning of *STRUCTURE* */
  84. /* will be fixed up at the end */
  85. ft_put_word(cxt, OF_DT_PROP);
  86. ft_put_word(cxt, sz);
  87. ft_put_word(cxt, off);
  88. ft_put_bin(cxt, data, sz);
  89. }
  90. void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str)
  91. {
  92. ft_prop(cxt, name, str, strlen(str) + 1);
  93. }
  94. void ft_prop_int(struct ft_cxt *cxt, const char *name, int val)
  95. {
  96. u32 v = cpu_to_be32((u32) val);
  97. ft_prop(cxt, name, &v, 4);
  98. }
  99. /* start construction of the flat OF tree */
  100. void ft_begin(struct ft_cxt *cxt, void *blob, int max_size)
  101. {
  102. struct boot_param_header *bph = blob;
  103. u32 off;
  104. /* clear the cxt */
  105. memset(cxt, 0, sizeof(*cxt));
  106. cxt->bph = bph;
  107. cxt->max_size = max_size;
  108. /* zero everything in the header area */
  109. memset(bph, 0, sizeof(*bph));
  110. bph->magic = cpu_to_be32(OF_DT_HEADER);
  111. bph->version = cpu_to_be32(0x10);
  112. bph->last_comp_version = cpu_to_be32(0x10);
  113. /* start pointers */
  114. cxt->pres_begin = (u8 *) _ALIGN((unsigned long)(bph + 1), 8);
  115. cxt->pres = cxt->pres_begin;
  116. off = (unsigned long)cxt->pres_begin - (unsigned long)bph;
  117. bph->off_mem_rsvmap = cpu_to_be32(off);
  118. ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */
  119. ((u64 *) cxt->pres)[1] = 0;
  120. cxt->p_anchor = cxt->pres + 16; /* over the terminator */
  121. }
  122. /* add a reserver physical area to the rsvmap */
  123. void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
  124. {
  125. ((u64 *) cxt->pres)[0] = cpu_to_be64(physaddr); /* phys = 0, size = 0, terminate */
  126. ((u64 *) cxt->pres)[1] = cpu_to_be64(size);
  127. cxt->pres += 16; /* advance */
  128. ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */
  129. ((u64 *) cxt->pres)[1] = 0;
  130. /* keep track of size */
  131. cxt->res_size = cxt->pres + 16 - cxt->pres_begin;
  132. cxt->p_anchor = cxt->pres + 16; /* over the terminator */
  133. }
  134. void ft_begin_tree(struct ft_cxt *cxt)
  135. {
  136. cxt->p_begin = cxt->p_anchor;
  137. cxt->pstr_begin = (char *)cxt->bph + cxt->max_size; /* point at the end */
  138. cxt->p = cxt->p_begin;
  139. cxt->pstr = cxt->pstr_begin;
  140. }
  141. int ft_end_tree(struct ft_cxt *cxt)
  142. {
  143. struct boot_param_header *bph = cxt->bph;
  144. int off, sz, sz1;
  145. u32 tag, v;
  146. u8 *p;
  147. ft_put_word(cxt, OF_DT_END);
  148. if (cxt->overflow)
  149. return -ENOMEM;
  150. /* size of the areas */
  151. cxt->struct_size = cxt->p - cxt->p_begin;
  152. cxt->strings_size = cxt->pstr_begin - cxt->pstr;
  153. /* the offset we must move */
  154. off = (cxt->pstr_begin - cxt->p_begin) - cxt->strings_size;
  155. /* the new strings start */
  156. cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
  157. /* move the whole string area */
  158. memmove(cxt->pstr_begin, cxt->pstr, cxt->strings_size);
  159. /* now perform the fixup of the strings */
  160. p = cxt->p_begin;
  161. while ((tag = be32_to_cpu(*(u32 *) p)) != OF_DT_END) {
  162. p += 4;
  163. if (tag == OF_DT_BEGIN_NODE) {
  164. p = (u8 *) _ALIGN((unsigned long)p + strlen(p) + 1, 4);
  165. continue;
  166. }
  167. if (tag == OF_DT_END_NODE || tag == OF_DT_NOP)
  168. continue;
  169. if (tag != OF_DT_PROP)
  170. return -EINVAL;
  171. sz = be32_to_cpu(*(u32 *) p);
  172. p += 4;
  173. v = be32_to_cpu(*(u32 *) p);
  174. v -= off;
  175. *(u32 *) p = cpu_to_be32(v); /* move down */
  176. p += 4;
  177. p = (u8 *) _ALIGN((unsigned long)p + sz, 4);
  178. }
  179. /* fix sizes */
  180. p = (char *)cxt->bph;
  181. sz = (cxt->pstr_begin + cxt->strings_size) - p;
  182. sz1 = _ALIGN(sz, 16); /* align at 16 bytes */
  183. if (sz != sz1)
  184. memset(p + sz, 0, sz1 - sz);
  185. bph->totalsize = cpu_to_be32(sz1);
  186. bph->off_dt_struct = cpu_to_be32(cxt->p_begin - p);
  187. bph->off_dt_strings = cpu_to_be32(cxt->pstr_begin - p);
  188. /* the new strings start */
  189. cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
  190. cxt->pstr = cxt->pstr_begin + cxt->strings_size;
  191. return 0;
  192. }
  193. /**********************************************************************/
  194. static inline int isprint(int c)
  195. {
  196. return c >= 0x20 && c <= 0x7e;
  197. }
  198. static int is_printable_string(const void *data, int len)
  199. {
  200. const char *s = data;
  201. const char *ss;
  202. /* zero length is not */
  203. if (len == 0)
  204. return 0;
  205. /* must terminate with zero */
  206. if (s[len - 1] != '\0')
  207. return 0;
  208. ss = s;
  209. while (*s && isprint(*s))
  210. s++;
  211. /* not zero, or not done yet */
  212. if (*s != '\0' || (s + 1 - ss) < len)
  213. return 0;
  214. return 1;
  215. }
  216. static void print_data(const void *data, int len)
  217. {
  218. int i;
  219. const u8 *s;
  220. /* no data, don't print */
  221. if (len == 0)
  222. return;
  223. if (is_printable_string(data, len)) {
  224. printf(" = \"%s\"", (char *)data);
  225. return;
  226. }
  227. switch (len) {
  228. case 1: /* byte */
  229. printf(" = <0x%02x>", (*(u8 *) data) & 0xff);
  230. break;
  231. case 2: /* half-word */
  232. printf(" = <0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
  233. break;
  234. case 4: /* word */
  235. printf(" = <0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
  236. break;
  237. case 8: /* double-word */
  238. printf(" = <0x%16llx>", be64_to_cpu(*(uint64_t *) data));
  239. break;
  240. default: /* anything else... hexdump */
  241. printf(" = [");
  242. for (i = 0, s = data; i < len; i++)
  243. printf("%02x%s", s[i], i < len - 1 ? " " : "");
  244. printf("]");
  245. break;
  246. }
  247. }
  248. void ft_dump_blob(const void *bphp)
  249. {
  250. const struct boot_param_header *bph = bphp;
  251. const uint64_t *p_rsvmap = (const uint64_t *)
  252. ((const char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
  253. const u32 *p_struct = (const u32 *)
  254. ((const char *)bph + be32_to_cpu(bph->off_dt_struct));
  255. const u32 *p_strings = (const u32 *)
  256. ((const char *)bph + be32_to_cpu(bph->off_dt_strings));
  257. u32 tag;
  258. const u32 *p;
  259. const char *s, *t;
  260. int depth, sz, shift;
  261. int i;
  262. uint64_t addr, size;
  263. if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
  264. /* not valid tree */
  265. return;
  266. }
  267. depth = 0;
  268. shift = 4;
  269. for (i = 0;; i++) {
  270. addr = be64_to_cpu(p_rsvmap[i * 2]);
  271. size = be64_to_cpu(p_rsvmap[i * 2 + 1]);
  272. if (addr == 0 && size == 0)
  273. break;
  274. printf("/memreserve/ 0x%llx 0x%llx;\n", addr, size);
  275. }
  276. p = p_struct;
  277. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  278. /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */
  279. if (tag == OF_DT_BEGIN_NODE) {
  280. s = (const char *)p;
  281. p = (u32 *) _ALIGN((unsigned long)p + strlen(s) + 1, 4);
  282. printf("%*s%s {\n", depth * shift, "", s);
  283. depth++;
  284. continue;
  285. }
  286. if (tag == OF_DT_END_NODE) {
  287. depth--;
  288. printf("%*s};\n", depth * shift, "");
  289. continue;
  290. }
  291. if (tag == OF_DT_NOP) {
  292. printf("%*s[NOP]\n", depth * shift, "");
  293. continue;
  294. }
  295. if (tag != OF_DT_PROP) {
  296. fprintf(stderr, "%*s ** Unknown tag 0x%08x\n",
  297. depth * shift, "", tag);
  298. break;
  299. }
  300. sz = be32_to_cpu(*p++);
  301. s = (const char *)p_strings + be32_to_cpu(*p++);
  302. t = (const char *)p;
  303. p = (const u32 *)_ALIGN((unsigned long)p + sz, 4);
  304. printf("%*s%s", depth * shift, "", s);
  305. print_data(t, sz);
  306. printf(";\n");
  307. }
  308. }
  309. void ft_backtrack_node(struct ft_cxt *cxt)
  310. {
  311. if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
  312. return; /* XXX only for node */
  313. cxt->p -= 4;
  314. }
  315. /* note that the root node of the blob is "peeled" off */
  316. void ft_merge_blob(struct ft_cxt *cxt, void *blob)
  317. {
  318. struct boot_param_header *bph = (struct boot_param_header *)blob;
  319. u32 *p_struct = (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_struct));
  320. u32 *p_strings =
  321. (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_strings));
  322. u32 tag, *p;
  323. char *s, *t;
  324. int depth, sz;
  325. if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
  326. return; /* XXX only for node */
  327. cxt->p -= 4;
  328. depth = 0;
  329. p = p_struct;
  330. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  331. /* printf("tag: 0x%08x (%d) - %d\n", tag, p - p_struct, depth); */
  332. if (tag == OF_DT_BEGIN_NODE) {
  333. s = (char *)p;
  334. p = (u32 *) _ALIGN((unsigned long)p + strlen(s) + 1, 4);
  335. if (depth++ > 0)
  336. ft_begin_node(cxt, s);
  337. continue;
  338. }
  339. if (tag == OF_DT_END_NODE) {
  340. ft_end_node(cxt);
  341. if (--depth == 0)
  342. break;
  343. continue;
  344. }
  345. if (tag == OF_DT_NOP)
  346. continue;
  347. if (tag != OF_DT_PROP)
  348. break;
  349. sz = be32_to_cpu(*p++);
  350. s = (char *)p_strings + be32_to_cpu(*p++);
  351. t = (char *)p;
  352. p = (u32 *) _ALIGN((unsigned long)p + sz, 4);
  353. ft_prop(cxt, s, t, sz);
  354. }
  355. }
  356. void *ft_get_prop(void *bphp, const char *propname, int *szp)
  357. {
  358. struct boot_param_header *bph = bphp;
  359. uint32_t *p_struct =
  360. (uint32_t *) ((char *)bph + be32_to_cpu(bph->off_dt_struct));
  361. uint32_t *p_strings =
  362. (uint32_t *) ((char *)bph + be32_to_cpu(bph->off_dt_strings));
  363. uint32_t version = be32_to_cpu(bph->version);
  364. uint32_t tag;
  365. uint32_t *p;
  366. char *s, *t;
  367. char *ss;
  368. int sz;
  369. static char path[256], prop[256];
  370. path[0] = '\0';
  371. p = p_struct;
  372. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  373. if (tag == OF_DT_BEGIN_NODE) {
  374. s = (char *)p;
  375. p = (uint32_t *) _ALIGN((unsigned long)p + strlen(s) +
  376. 1, 4);
  377. strcat(path, s);
  378. strcat(path, "/");
  379. continue;
  380. }
  381. if (tag == OF_DT_END_NODE) {
  382. path[strlen(path) - 1] = '\0';
  383. ss = strrchr(path, '/');
  384. if (ss != NULL)
  385. ss[1] = '\0';
  386. continue;
  387. }
  388. if (tag == OF_DT_NOP)
  389. continue;
  390. if (tag != OF_DT_PROP)
  391. break;
  392. sz = be32_to_cpu(*p++);
  393. s = (char *)p_strings + be32_to_cpu(*p++);
  394. if (version < 0x10 && sz >= 8)
  395. p = (uint32_t *) _ALIGN((unsigned long)p, 8);
  396. t = (char *)p;
  397. p = (uint32_t *) _ALIGN((unsigned long)p + sz, 4);
  398. strcpy(prop, path);
  399. strcat(prop, s);
  400. if (strcmp(prop, propname) == 0) {
  401. *szp = sz;
  402. return t;
  403. }
  404. }
  405. return NULL;
  406. }
  407. /********************************************************************/
  408. extern unsigned char oftree_dtb[];
  409. extern unsigned int oftree_dtb_len;
  410. /* Function that returns a character from the environment */
  411. extern uchar(*env_get_char) (int);
  412. #define BDM(x) { .name = #x, .offset = offsetof(bd_t, bi_ ##x ) }
  413. #ifdef CONFIG_OF_HAS_BD_T
  414. static const struct {
  415. const char *name;
  416. int offset;
  417. } bd_map[] = {
  418. BDM(memstart),
  419. BDM(memsize),
  420. BDM(flashstart),
  421. BDM(flashsize),
  422. BDM(flashoffset),
  423. BDM(sramstart),
  424. BDM(sramsize),
  425. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \
  426. || defined(CONFIG_E500)
  427. BDM(immr_base),
  428. #endif
  429. #if defined(CONFIG_MPC5xxx)
  430. BDM(mbar_base),
  431. #endif
  432. #if defined(CONFIG_MPC83XX)
  433. BDM(immrbar),
  434. #endif
  435. #if defined(CONFIG_MPC8220)
  436. BDM(mbar_base),
  437. BDM(inpfreq),
  438. BDM(pcifreq),
  439. BDM(pevfreq),
  440. BDM(flbfreq),
  441. BDM(vcofreq),
  442. #endif
  443. BDM(bootflags),
  444. BDM(ip_addr),
  445. BDM(intfreq),
  446. BDM(busfreq),
  447. #ifdef CONFIG_CPM2
  448. BDM(cpmfreq),
  449. BDM(brgfreq),
  450. BDM(sccfreq),
  451. BDM(vco),
  452. #endif
  453. #if defined(CONFIG_MPC5xxx)
  454. BDM(ipbfreq),
  455. BDM(pcifreq),
  456. #endif
  457. BDM(baudrate),
  458. };
  459. #endif
  460. void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_end)
  461. {
  462. u32 *p;
  463. int len;
  464. struct ft_cxt cxt;
  465. ulong clock;
  466. #if defined(CONFIG_OF_HAS_UBOOT_ENV)
  467. int k, nxt;
  468. #endif
  469. #if defined(CONFIG_OF_HAS_BD_T)
  470. u8 *end;
  471. #endif
  472. #if defined(CONFIG_OF_HAS_UBOOT_ENV) || defined(CONFIG_OF_HAS_BD_T)
  473. int i;
  474. static char tmpenv[256];
  475. #endif
  476. /* disable OF tree; booting old kernel */
  477. if (getenv("disable_of") != NULL) {
  478. memcpy(blob, bd, sizeof(*bd));
  479. return;
  480. }
  481. ft_begin(&cxt, blob, size);
  482. if (initrd_start && initrd_end)
  483. ft_add_rsvmap(&cxt, initrd_start, initrd_end - initrd_start + 1);
  484. ft_begin_tree(&cxt);
  485. ft_begin_node(&cxt, "");
  486. ft_end_node(&cxt);
  487. /* copy RO tree */
  488. ft_merge_blob(&cxt, oftree_dtb);
  489. /* back into root */
  490. ft_backtrack_node(&cxt);
  491. #ifdef CONFIG_OF_HAS_UBOOT_ENV
  492. ft_begin_node(&cxt, "u-boot-env");
  493. for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
  494. char *s, *lval, *rval;
  495. for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) ;
  496. s = tmpenv;
  497. for (k = i; k < nxt && s < &tmpenv[sizeof(tmpenv) - 1]; ++k)
  498. *s++ = env_get_char(k);
  499. *s++ = '\0';
  500. lval = tmpenv;
  501. s = strchr(tmpenv, '=');
  502. if (s != NULL) {
  503. *s++ = '\0';
  504. rval = s;
  505. } else
  506. continue;
  507. ft_prop_str(&cxt, lval, rval);
  508. }
  509. ft_end_node(&cxt);
  510. #endif
  511. ft_begin_node(&cxt, "chosen");
  512. ft_prop_str(&cxt, "name", "chosen");
  513. ft_prop_str(&cxt, "bootargs", getenv("bootargs"));
  514. ft_prop_int(&cxt, "linux,platform", 0x600); /* what is this? */
  515. if (initrd_start && initrd_end) {
  516. ft_prop_int(&cxt, "linux,initrd-start", initrd_start);
  517. ft_prop_int(&cxt, "linux,initrd-end", initrd_end);
  518. }
  519. #ifdef OF_STDOUT_PATH
  520. ft_prop_str(&cxt, "linux,stdout-path", OF_STDOUT_PATH);
  521. #endif
  522. ft_end_node(&cxt);
  523. ft_end_node(&cxt); /* end root */
  524. ft_end_tree(&cxt);
  525. /*
  526. printf("merged OF-tree\n");
  527. ft_dump_blob(blob);
  528. */
  529. #ifdef CONFIG_OF_HAS_BD_T
  530. /* paste the bd_t at the end of the flat tree */
  531. end = (char *)blob +
  532. be32_to_cpu(((struct boot_param_header *)blob)->totalsize);
  533. memcpy(end, bd, sizeof(*bd));
  534. #endif
  535. #ifdef CONFIG_PPC
  536. #ifdef CONFIG_OF_HAS_BD_T
  537. for (i = 0; i < sizeof(bd_map)/sizeof(bd_map[0]); i++) {
  538. uint32_t v;
  539. sprintf(tmpenv, "/bd_t/%s", bd_map[i].name);
  540. v = *(uint32_t *)((char *)bd + bd_map[i].offset);
  541. p = ft_get_prop(blob, tmpenv, &len);
  542. if (p != NULL)
  543. *p = cpu_to_be32(v);
  544. }
  545. p = ft_get_prop(blob, "/bd_t/enetaddr", &len);
  546. if (p != NULL)
  547. memcpy(p, bd->bi_enetaddr, 6);
  548. p = ft_get_prop(blob, "/bd_t/ethspeed", &len);
  549. if (p != NULL)
  550. *p = cpu_to_be32((uint32_t) bd->bi_ethspeed);
  551. #endif
  552. clock = bd->bi_intfreq;
  553. p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
  554. if (p != NULL)
  555. *p = cpu_to_be32(clock);
  556. #ifdef OF_TBCLK
  557. clock = OF_TBCLK;
  558. p = ft_get_prop(blob, "/cpus/" OF_CPU "/timebase-frequency", &len);
  559. if (p != NULL)
  560. *p = cpu_to_be32(clock);
  561. #endif
  562. #endif /* __powerpc__ */
  563. #ifdef CONFIG_OF_BOARD_SETUP
  564. ft_board_setup(blob, bd);
  565. #endif
  566. /*
  567. printf("final OF-tree\n");
  568. ft_dump_blob(blob);
  569. */
  570. }
  571. #endif