source: svn/trunk/newcon3bcm2_21bu/dta/src/bootloader/s1_main.c @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2010, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: $
11 * $brcm_Revision: $
12 * $brcm_Date: $
13 *
14 * Module Description: Stage 1 C entry point.
15 *
16 * Revision History:
17 *
18 * $brcm_Log: $
19 *
20 *
21 ***************************************************************************/
22
23/* copy memory block from word aligned src to word aligned destination
24   with word aligned size. All pointer and size must be 4 bytes aligned */
25extern void aligned_copy(void * src, void * dst, unsigned int n);
26
27extern unsigned int _stage2_start;
28extern unsigned int _stage2_size;
29extern unsigned int __start_s2;
30extern unsigned int key1[];
31
32#define KSEG0_KSEG1(x) ((0x20000000) | (unsigned long)(x))
33#if defined(RSA_BITS)
34#define SIGNATURE_SIZE (RSA_BITS/8)
35#else
36#define SIGNATURE_SIZE 0x80
37#endif
38unsigned int stage2_signature[SIGNATURE_SIZE/4];
39unsigned int key1_copy[SIGNATURE_SIZE/4];
40
41#define XPT_OTP_MC1_BASE 0xb053802c
42
43void print_string(void)
44{
45        /* New B0 scramble function needs print_string to compile */
46}
47/* write character on serial port */
48extern void _writeasm(int c);
49
50int signature_check(unsigned long in, unsigned long size, unsigned long signature, unsigned long public_key);
51
52void stage1_main(void)
53{
54    void * stage2_signature_address;
55    int rc;
56    stage2_signature_address = (void*)((unsigned int)&_stage2_start + (unsigned int)&_stage2_size);
57    /*
58       we must validate key1 somehow.
59     */
60    aligned_copy(stage2_signature_address, stage2_signature, SIGNATURE_SIZE);
61    aligned_copy(key1, key1_copy, SIGNATURE_SIZE);
62    rc = signature_check(KSEG0_KSEG1(&__start_s2), (unsigned long)&_stage2_size, (unsigned long)stage2_signature, (unsigned long)key1_copy);
63    if(0 != rc){
64        /* signature is invalid */
65        _writeasm('-');
66        /* halt if bootloader verification is enabled */
67        if((*(unsigned int*)XPT_OTP_MC1_BASE) & 4)
68            __asm__("wait");
69    }
70    /* exit back to assembly and start stage two execution */
71}
72
73#include "signature.c"
74
75/* Please do not remove! */
76/* Local Variables: */
77/* mode: C */
78/* indent-tabs-mode: nil */
79/* End: */
Note: See TracBrowser for help on using the repository browser.