wdenk | 1f4bb37 | 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> |
| 19 | |
| 20 | #if defined(CONFIG_LYNXKDI) |
| 21 | #include <lynxkdi.h> |
| 22 | |
Stefan Roese | 846b0dd | 2005-08-08 12:42:22 +0200 | [diff] [blame] | 23 | #if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR) |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 24 | void lynxkdi_boot ( image_header_t *hdr ) |
| 25 | { |
Wolfgang Denk | dc013d4 | 2006-03-12 01:59:35 +0100 | [diff] [blame^] | 26 | void (*lynxkdi)(void) = (void(*)(void)) ntohl(hdr->ih_ep); |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 27 | lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020; |
| 28 | bd_t *kbd; |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
Wolfgang Denk | dc013d4 | 2006-03-12 01:59:35 +0100 | [diff] [blame^] | 30 | u32 *psz = (u32 *)(ntohl(hdr->ih_load) + 0x0204); |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 31 | |
| 32 | memset( parms, 0, sizeof(*parms)); |
| 33 | kbd = gd->bd; |
| 34 | parms->clock_ref = kbd->bi_busfreq; |
| 35 | parms->dramsz = kbd->bi_memsize; |
| 36 | memcpy(parms->ethaddr, kbd->bi_enetaddr, 6); |
| 37 | mtspr(SPRN_SPRG2, 0x0020); |
| 38 | |
| 39 | /* Do a simple check for Bluecat so we can pass the |
| 40 | * kernel command line parameters. |
| 41 | */ |
Wolfgang Denk | dc013d4 | 2006-03-12 01:59:35 +0100 | [diff] [blame^] | 42 | if( le32_to_cpu(*psz) == ntohl(hdr->ih_size) ){ /* FIXME: NOT SURE HERE ! */ |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 43 | char *args; |
Wolfgang Denk | dc013d4 | 2006-03-12 01:59:35 +0100 | [diff] [blame^] | 44 | char *cmdline = (char *)(ntohl(hdr->ih_load) + 0x020c); |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 45 | int len; |
| 46 | |
| 47 | printf("Booting Bluecat KDI ...\n"); |
| 48 | udelay(200*1000); /* Allow serial port to flush */ |
| 49 | if ((args = getenv("bootargs")) == NULL) |
| 50 | args = ""; |
| 51 | /* Prepend the cmdline */ |
| 52 | len = strlen(args); |
| 53 | if( len && (len + strlen(cmdline) + 2 < (0x0400 - 0x020c))) { |
| 54 | memmove( cmdline + strlen(args) + 1, cmdline, strlen(cmdline) ); |
| 55 | strcpy( cmdline, args ); |
| 56 | cmdline[len] = ' '; |
| 57 | } |
| 58 | } |
| 59 | else { |
| 60 | printf("Booting LynxOS KDI ...\n"); |
| 61 | } |
| 62 | |
| 63 | lynxkdi(); |
| 64 | } |
| 65 | #else |
| 66 | #error "Lynx KDI support not implemented for configured CPU" |
| 67 | #endif |
| 68 | |
| 69 | #endif /* CONFIG_LYNXKDI */ |