lynxkdi.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <lynxkdi.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. #if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
  21. void lynxkdi_boot (image_header_t *hdr)
  22. {
  23. void (*lynxkdi)(void) = (void(*)(void))image_get_ep (hdr);
  24. lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
  25. bd_t *kbd;
  26. u32 *psz = (u32 *)(image_get_load (hdr) + 0x0204);
  27. memset (parms, 0, sizeof(*parms));
  28. kbd = gd->bd;
  29. parms->clock_ref = kbd->bi_busfreq;
  30. parms->dramsz = kbd->bi_memsize;
  31. memcpy (parms->ethaddr, kbd->bi_enetaddr, 6);
  32. mtspr (SPRN_SPRG2, 0x0020);
  33. /* Do a simple check for Bluecat so we can pass the
  34. * kernel command line parameters.
  35. */
  36. if (le32_to_cpu (*psz) == image_get_data_size (hdr)) { /* FIXME: NOT SURE HERE ! */
  37. char *args;
  38. char *cmdline = (char *)(image_get_load (hdr) + 0x020c);
  39. int len;
  40. printf ("Booting Bluecat KDI ...\n");
  41. udelay (200*1000); /* Allow serial port to flush */
  42. if ((args = getenv ("bootargs")) == NULL)
  43. args = "";
  44. /* Prepend the cmdline */
  45. len = strlen (args);
  46. if (len && (len + strlen (cmdline) + 2 < (0x0400 - 0x020c))) {
  47. memmove (cmdline + strlen (args) + 1, cmdline, strlen (cmdline));
  48. strcpy (cmdline, args);
  49. cmdline[len] = ' ';
  50. }
  51. }
  52. else {
  53. printf ("Booting LynxOS KDI ...\n");
  54. }
  55. lynxkdi ();
  56. }
  57. #else
  58. #error "Lynx KDI support not implemented for configured CPU"
  59. #endif