cmd_bdinfo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * Boot support
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. DECLARE_GLOBAL_DATA_PTR;
  29. static void print_num(const char *, ulong);
  30. #if !(defined(CONFIG_ARM) || defined(CONFIG_M68K) || defined(CONFIG_SANDBOX)) \
  31. || defined(CONFIG_CMD_NET)
  32. #define HAVE_PRINT_ETH
  33. static void print_eth(int idx);
  34. #endif
  35. #if (!defined(CONFIG_ARM) && !defined(CONFIG_X86) && !defined(CONFIG_SANDBOX))
  36. #define HAVE_PRINT_LNUM
  37. static void print_lnum(const char *, u64);
  38. #endif
  39. #if defined(CONFIG_PPC)
  40. static void print_str(const char *, const char *);
  41. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  42. {
  43. bd_t *bd = gd->bd;
  44. char buf[32];
  45. #ifdef DEBUG
  46. print_num("bd address", (ulong)bd);
  47. #endif
  48. print_num("memstart", bd->bi_memstart);
  49. print_lnum("memsize", bd->bi_memsize);
  50. print_num("flashstart", bd->bi_flashstart);
  51. print_num("flashsize", bd->bi_flashsize);
  52. print_num("flashoffset", bd->bi_flashoffset);
  53. print_num("sramstart", bd->bi_sramstart);
  54. print_num("sramsize", bd->bi_sramsize);
  55. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  56. defined(CONFIG_8260) || defined(CONFIG_E500)
  57. print_num("immr_base", bd->bi_immr_base);
  58. #endif
  59. print_num("bootflags", bd->bi_bootflags);
  60. #if defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
  61. defined(CONFIG_405GP) || \
  62. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  63. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  64. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  65. defined(CONFIG_XILINX_405)
  66. print_str("procfreq", strmhz(buf, bd->bi_procfreq));
  67. print_str("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  68. #if defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
  69. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  70. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  71. defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
  72. print_str("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  73. #endif
  74. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  75. #if defined(CONFIG_CPM2)
  76. print_str("vco", strmhz(buf, bd->bi_vco));
  77. print_str("sccfreq", strmhz(buf, bd->bi_sccfreq));
  78. print_str("brgfreq", strmhz(buf, bd->bi_brgfreq));
  79. #endif
  80. print_str("intfreq", strmhz(buf, bd->bi_intfreq));
  81. #if defined(CONFIG_CPM2)
  82. print_str("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  83. #endif
  84. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  85. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  86. #if defined(CONFIG_MPC8220)
  87. print_str("inpfreq", strmhz(buf, bd->bi_inpfreq));
  88. print_str("flbfreq", strmhz(buf, bd->bi_flbfreq));
  89. print_str("pcifreq", strmhz(buf, bd->bi_pcifreq));
  90. print_str("vcofreq", strmhz(buf, bd->bi_vcofreq));
  91. print_str("pevfreq", strmhz(buf, bd->bi_pevfreq));
  92. #endif
  93. print_eth(0);
  94. #if defined(CONFIG_HAS_ETH1)
  95. print_eth(1);
  96. #endif
  97. #if defined(CONFIG_HAS_ETH2)
  98. print_eth(2);
  99. #endif
  100. #if defined(CONFIG_HAS_ETH3)
  101. print_eth(3);
  102. #endif
  103. #if defined(CONFIG_HAS_ETH4)
  104. print_eth(4);
  105. #endif
  106. #if defined(CONFIG_HAS_ETH5)
  107. print_eth(5);
  108. #endif
  109. #ifdef CONFIG_HERMES
  110. print_str("ethspeed", strmhz(buf, bd->bi_ethspeed));
  111. #endif
  112. printf("IP addr = %pI4\n", &bd->bi_ip_addr);
  113. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  114. print_num("relocaddr", gd->relocaddr);
  115. return 0;
  116. }
  117. #elif defined(CONFIG_NIOS2)
  118. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  119. {
  120. bd_t *bd = gd->bd;
  121. print_num("mem start", (ulong)bd->bi_memstart);
  122. print_lnum("mem size", (u64)bd->bi_memsize);
  123. print_num("flash start", (ulong)bd->bi_flashstart);
  124. print_num("flash size", (ulong)bd->bi_flashsize);
  125. print_num("flash offset", (ulong)bd->bi_flashoffset);
  126. #if defined(CONFIG_SYS_SRAM_BASE)
  127. print_num ("sram start", (ulong)bd->bi_sramstart);
  128. print_num ("sram size", (ulong)bd->bi_sramsize);
  129. #endif
  130. #if defined(CONFIG_CMD_NET)
  131. print_eth(0);
  132. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  133. #endif
  134. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  135. return 0;
  136. }
  137. #elif defined(CONFIG_MICROBLAZE)
  138. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  139. {
  140. bd_t *bd = gd->bd;
  141. print_num("mem start ", (ulong)bd->bi_memstart);
  142. print_lnum("mem size ", (u64)bd->bi_memsize);
  143. print_num("flash start ", (ulong)bd->bi_flashstart);
  144. print_num("flash size ", (ulong)bd->bi_flashsize);
  145. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  146. #if defined(CONFIG_SYS_SRAM_BASE)
  147. print_num("sram start ", (ulong)bd->bi_sramstart);
  148. print_num("sram size ", (ulong)bd->bi_sramsize);
  149. #endif
  150. #if defined(CONFIG_CMD_NET)
  151. print_eth(0);
  152. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  153. #endif
  154. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  155. return 0;
  156. }
  157. #elif defined(CONFIG_SPARC)
  158. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  159. {
  160. bd_t *bd = gd->bd;
  161. #ifdef DEBUG
  162. print_num("bd address ", (ulong) bd);
  163. #endif
  164. print_num("memstart ", bd->bi_memstart);
  165. print_lnum("memsize ", bd->bi_memsize);
  166. print_num("flashstart ", bd->bi_flashstart);
  167. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  168. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  169. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  170. CONFIG_SYS_MONITOR_LEN);
  171. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  172. CONFIG_SYS_MALLOC_LEN);
  173. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  174. CONFIG_SYS_STACK_SIZE);
  175. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  176. CONFIG_SYS_PROM_SIZE);
  177. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  178. GENERATED_GBL_DATA_SIZE);
  179. #if defined(CONFIG_CMD_NET)
  180. print_eth(0);
  181. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  182. #endif
  183. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  184. return 0;
  185. }
  186. #elif defined(CONFIG_M68K)
  187. static void print_str(const char *, const char *);
  188. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  189. {
  190. bd_t *bd = gd->bd;
  191. char buf[32];
  192. print_num("memstart", (ulong)bd->bi_memstart);
  193. print_lnum("memsize", (u64)bd->bi_memsize);
  194. print_num("flashstart", (ulong)bd->bi_flashstart);
  195. print_num("flashsize", (ulong)bd->bi_flashsize);
  196. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  197. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  198. print_num("sramstart", (ulong)bd->bi_sramstart);
  199. print_num("sramsize", (ulong)bd->bi_sramsize);
  200. #endif
  201. #if defined(CONFIG_SYS_MBAR)
  202. print_num("mbar", bd->bi_mbar_base);
  203. #endif
  204. print_str("cpufreq", strmhz(buf, bd->bi_intfreq));
  205. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  206. #ifdef CONFIG_PCI
  207. print_str("pcifreq", strmhz(buf, bd->bi_pcifreq));
  208. #endif
  209. #ifdef CONFIG_EXTRA_CLOCK
  210. print_str("flbfreq", strmhz(buf, bd->bi_flbfreq));
  211. print_str("inpfreq", strmhz(buf, bd->bi_inpfreq));
  212. print_str("vcofreq", strmhz(buf, bd->bi_vcofreq));
  213. #endif
  214. #if defined(CONFIG_CMD_NET)
  215. print_eth(0);
  216. #if defined(CONFIG_HAS_ETH1)
  217. print_eth(1);
  218. #endif
  219. #if defined(CONFIG_HAS_ETH2)
  220. print_eth(2);
  221. #endif
  222. #if defined(CONFIG_HAS_ETH3)
  223. print_eth(3);
  224. #endif
  225. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  226. #endif
  227. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  228. return 0;
  229. }
  230. #elif defined(CONFIG_BLACKFIN)
  231. static void print_str(const char *, const char *);
  232. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  233. {
  234. bd_t *bd = gd->bd;
  235. char buf[32];
  236. printf("U-Boot = %s\n", bd->bi_r_version);
  237. printf("CPU = %s\n", bd->bi_cpu);
  238. printf("Board = %s\n", bd->bi_board_name);
  239. print_str("VCO", strmhz(buf, bd->bi_vco));
  240. print_str("CCLK", strmhz(buf, bd->bi_cclk));
  241. print_str("SCLK", strmhz(buf, bd->bi_sclk));
  242. print_num("boot_params", (ulong)bd->bi_boot_params);
  243. print_num("memstart", (ulong)bd->bi_memstart);
  244. print_lnum("memsize", (u64)bd->bi_memsize);
  245. print_num("flashstart", (ulong)bd->bi_flashstart);
  246. print_num("flashsize", (ulong)bd->bi_flashsize);
  247. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  248. print_eth(0);
  249. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  250. printf("baudrate = %d bps\n", bd->bi_baudrate);
  251. return 0;
  252. }
  253. #elif defined(CONFIG_MIPS)
  254. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  255. {
  256. bd_t *bd = gd->bd;
  257. print_num("boot_params", (ulong)bd->bi_boot_params);
  258. print_num("memstart", (ulong)bd->bi_memstart);
  259. print_lnum("memsize", (u64)bd->bi_memsize);
  260. print_num("flashstart", (ulong)bd->bi_flashstart);
  261. print_num("flashsize", (ulong)bd->bi_flashsize);
  262. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  263. print_eth(0);
  264. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  265. printf("baudrate = %d bps\n", bd->bi_baudrate);
  266. return 0;
  267. }
  268. #elif defined(CONFIG_AVR32)
  269. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  270. {
  271. bd_t *bd = gd->bd;
  272. print_num("boot_params", (ulong)bd->bi_boot_params);
  273. print_num("memstart", (ulong)bd->bi_memstart);
  274. print_lnum("memsize", (u64)bd->bi_memsize);
  275. print_num("flashstart", (ulong)bd->bi_flashstart);
  276. print_num("flashsize", (ulong)bd->bi_flashsize);
  277. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  278. print_eth(0);
  279. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  280. printf("baudrate = %lu bps\n", bd->bi_baudrate);
  281. return 0;
  282. }
  283. #elif defined(CONFIG_ARM)
  284. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  285. {
  286. int i;
  287. bd_t *bd = gd->bd;
  288. print_num("arch_number", bd->bi_arch_number);
  289. print_num("boot_params", (ulong)bd->bi_boot_params);
  290. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  291. print_num("DRAM bank", i);
  292. print_num("-> start", bd->bi_dram[i].start);
  293. print_num("-> size", bd->bi_dram[i].size);
  294. }
  295. #if defined(CONFIG_CMD_NET)
  296. print_eth(0);
  297. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  298. #endif
  299. printf("baudrate = %d bps\n", bd->bi_baudrate);
  300. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  301. print_num("TLB addr", gd->tlb_addr);
  302. #endif
  303. print_num("relocaddr", gd->relocaddr);
  304. print_num("reloc off", gd->reloc_off);
  305. print_num("irq_sp", gd->irq_sp); /* irq stack pointer */
  306. print_num("sp start ", gd->start_addr_sp);
  307. print_num("FB base ", gd->fb_base);
  308. return 0;
  309. }
  310. #elif defined(CONFIG_SH)
  311. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  312. {
  313. bd_t *bd = gd->bd;
  314. print_num("mem start ", (ulong)bd->bi_memstart);
  315. print_lnum("mem size ", (u64)bd->bi_memsize);
  316. print_num("flash start ", (ulong)bd->bi_flashstart);
  317. print_num("flash size ", (ulong)bd->bi_flashsize);
  318. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  319. #if defined(CONFIG_CMD_NET)
  320. print_eth(0);
  321. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  322. #endif
  323. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  324. return 0;
  325. }
  326. #elif defined(CONFIG_X86)
  327. static void print_str(const char *, const char *);
  328. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  329. {
  330. int i;
  331. bd_t *bd = gd->bd;
  332. char buf[32];
  333. print_num("boot_params", (ulong)bd->bi_boot_params);
  334. print_num("bi_memstart", bd->bi_memstart);
  335. print_num("bi_memsize", bd->bi_memsize);
  336. print_num("bi_flashstart", bd->bi_flashstart);
  337. print_num("bi_flashsize", bd->bi_flashsize);
  338. print_num("bi_flashoffset", bd->bi_flashoffset);
  339. print_num("bi_sramstart", bd->bi_sramstart);
  340. print_num("bi_sramsize", bd->bi_sramsize);
  341. print_num("bi_bootflags", bd->bi_bootflags);
  342. print_str("cpufreq", strmhz(buf, bd->bi_intfreq));
  343. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  344. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  345. print_num("DRAM bank", i);
  346. print_num("-> start", bd->bi_dram[i].start);
  347. print_num("-> size", bd->bi_dram[i].size);
  348. }
  349. #if defined(CONFIG_CMD_NET)
  350. print_eth(0);
  351. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  352. print_str("ethspeed", strmhz(buf, bd->bi_ethspeed));
  353. #endif
  354. printf("baudrate = %d bps\n", bd->bi_baudrate);
  355. return 0;
  356. }
  357. #elif defined(CONFIG_SANDBOX)
  358. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  359. {
  360. int i;
  361. bd_t *bd = gd->bd;
  362. print_num("boot_params", (ulong)bd->bi_boot_params);
  363. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  364. print_num("DRAM bank", i);
  365. print_num("-> start", bd->bi_dram[i].start);
  366. print_num("-> size", bd->bi_dram[i].size);
  367. }
  368. #if defined(CONFIG_CMD_NET)
  369. print_eth(0);
  370. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  371. #endif
  372. print_num("FB base ", gd->fb_base);
  373. return 0;
  374. }
  375. #else
  376. #error "a case for this architecture does not exist!"
  377. #endif
  378. static void print_num(const char *name, ulong value)
  379. {
  380. printf("%-12s= 0x%08lX\n", name, value);
  381. }
  382. #ifdef HAVE_PRINT_ETH
  383. static void print_eth(int idx)
  384. {
  385. char name[10], *val;
  386. if (idx)
  387. sprintf(name, "eth%iaddr", idx);
  388. else
  389. strcpy(name, "ethaddr");
  390. val = getenv(name);
  391. if (!val)
  392. val = "(not set)";
  393. printf("%-12s= %s\n", name, val);
  394. }
  395. #endif
  396. #ifdef HAVE_PRINT_LNUM
  397. static void print_lnum(const char *name, u64 value)
  398. {
  399. printf("%-12s= 0x%.8llX\n", name, value);
  400. }
  401. #endif
  402. #if defined(CONFIG_PPC) || \
  403. defined(CONFIG_M68K) || \
  404. defined(CONFIG_BLACKFIN) || \
  405. defined(CONFIG_X86)
  406. static void print_str(const char *name, const char *str)
  407. {
  408. printf("%-12s= %6s MHz\n", name, str);
  409. }
  410. #endif /* CONFIG_PPC */
  411. /* -------------------------------------------------------------------- */
  412. U_BOOT_CMD(
  413. bdinfo, 1, 1, do_bdinfo,
  414. "print Board Info structure",
  415. ""
  416. );