lynxkdi.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) Orbacom Systems, Inc <www.orbacom.com>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms are freely
  6. * permitted provided that the above copyright notice and this
  7. * paragraph and the following disclaimer are duplicated in all
  8. * such forms.
  9. *
  10. * This software is provided "AS IS" and without any express or
  11. * implied warranties, including, without limitation, the implied
  12. * warranties of merchantability and fitness for a particular
  13. * purpose.
  14. */
  15. #include <common.h>
  16. #include <asm/processor.h>
  17. #include <image.h>
  18. #include <net.h>
  19. #include <lynxkdi.h>
  20. DECLARE_GLOBAL_DATA_PTR;
  21. #if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
  22. void lynxkdi_boot(image_header_t *hdr)
  23. {
  24. void (*lynxkdi)(void) = (void(*)(void))image_get_ep(hdr);
  25. lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
  26. bd_t *kbd;
  27. u32 *psz = (u32 *)(image_get_load(hdr) + 0x0204);
  28. memset(parms, 0, sizeof(*parms));
  29. kbd = gd->bd;
  30. parms->clock_ref = kbd->bi_busfreq;
  31. parms->dramsz = kbd->bi_memsize;
  32. eth_getenv_enetaddr("ethaddr", parms->ethaddr);
  33. mtspr(SPRN_SPRG2, 0x0020);
  34. /* Do a simple check for Bluecat so we can pass the
  35. * kernel command line parameters.
  36. */
  37. /* FIXME: NOT SURE HERE ! */
  38. if (le32_to_cpu(*psz) == image_get_data_size(hdr)) {
  39. char *args;
  40. char *cmdline = (char *)(image_get_load(hdr) + 0x020c);
  41. int len;
  42. printf("Booting Bluecat KDI ...\n");
  43. udelay(200*1000); /* Allow serial port to flush */
  44. if ((args = getenv("bootargs")) == NULL)
  45. args = "";
  46. /* Prepend the cmdline */
  47. len = strlen(args);
  48. if (len && (len + strlen(cmdline) + 2 < (0x0400 - 0x020c))) {
  49. memmove(cmdline + strlen(args) + 1, cmdline,
  50. strlen(cmdline));
  51. strcpy(cmdline, args);
  52. cmdline[len] = ' ';
  53. }
  54. }
  55. else {
  56. printf("Booting LynxOS KDI ...\n");
  57. }
  58. lynxkdi();
  59. }
  60. #else
  61. #error "Lynx KDI support not implemented for configured CPU"
  62. #endif