wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 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 | |
| 16 | #include <common.h> |
| 17 | #include <asm/processor.h> |
| 18 | #include <image.h> |
Wolfgang Denk | ffcf599 | 2009-03-28 20:16:16 +0100 | [diff] [blame] | 19 | #include <net.h> |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 20 | |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 21 | #include <lynxkdi.h> |
| 22 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Stefan Roese | b30f2a1 | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 25 | #if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR) |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 26 | void lynxkdi_boot(image_header_t *hdr) |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 27 | { |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 28 | void (*lynxkdi)(void) = (void(*)(void))image_get_ep(hdr); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 29 | lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020; |
| 30 | bd_t *kbd; |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 31 | u32 *psz = (u32 *)(image_get_load(hdr) + 0x0204); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 32 | |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 33 | memset(parms, 0, sizeof(*parms)); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 34 | kbd = gd->bd; |
| 35 | parms->clock_ref = kbd->bi_busfreq; |
| 36 | parms->dramsz = kbd->bi_memsize; |
Mike Frysinger | 84d03e5 | 2009-02-11 18:54:07 -0500 | [diff] [blame] | 37 | eth_getenv_enetaddr("ethaddr", parms->ethaddr); |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 38 | mtspr(SPRN_SPRG2, 0x0020); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 39 | |
| 40 | /* Do a simple check for Bluecat so we can pass the |
| 41 | * kernel command line parameters. |
| 42 | */ |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 43 | /* FIXME: NOT SURE HERE ! */ |
| 44 | if (le32_to_cpu(*psz) == image_get_data_size(hdr)) { |
Marian Balakowicz | 2df645e | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 45 | char *args; |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 46 | char *cmdline = (char *)(image_get_load(hdr) + 0x020c); |
Marian Balakowicz | 2df645e | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 47 | int len; |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 48 | |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 49 | printf("Booting Bluecat KDI ...\n"); |
| 50 | udelay(200*1000); /* Allow serial port to flush */ |
| 51 | if ((args = getenv("bootargs")) == NULL) |
Marian Balakowicz | 2df645e | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 52 | args = ""; |
| 53 | /* Prepend the cmdline */ |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 54 | len = strlen(args); |
| 55 | if (len && (len + strlen(cmdline) + 2 < (0x0400 - 0x020c))) { |
| 56 | memmove(cmdline + strlen(args) + 1, cmdline, |
| 57 | strlen(cmdline)); |
| 58 | strcpy(cmdline, args); |
Marian Balakowicz | 2df645e | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 59 | cmdline[len] = ' '; |
| 60 | } |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 61 | } |
| 62 | else { |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 63 | printf("Booting LynxOS KDI ...\n"); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Stephen Warren | 6904b6e | 2011-10-18 11:11:49 +0000 | [diff] [blame] | 66 | lynxkdi(); |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 67 | } |
| 68 | #else |
| 69 | #error "Lynx KDI support not implemented for configured CPU" |
| 70 | #endif |