aboutsummaryrefslogtreecommitdiff
path: root/arch/csky/lib/bootm.c
blob: 9f8cf4a0fa3d397d4856f3f7a313c8c3410715d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * Copyright (C) 2017-2020 Alibaba Group Holding Limited
 *
 * SPDX-License-Identifier: GPL-2.0+
 */

#include <common.h>
#include <command.h>
#include <image.h>
#include <u-boot/zlib.h>
#include <asm/byteorder.h>
#include <linux/libfdt.h>
#include <mapmem.h>
#include <fdt_support.h>
#include <linux/compiler.h>
#include <bootm.h>
#include <vxworks.h>
#include <asm/arch/interrupt.h>
#include <irq_func.h>
#include <cpu_func.h>
DECLARE_GLOBAL_DATA_PTR;


__weak int board_prep_linux(bootm_headers_t *images) { return 0; }


/* Main Entry point for csky bootm implementation
*
* Modeled after the powerpc implementation
* DIFFERENCE: Instead of calling prep and go at the end
* they are called if subcommand is equal 0.
*/
int do_bootm_linux(int flag, int argc, char * const argv[],
                bootm_headers_t *images)
{
    void (*theKernel)(int magic, void * params);
    char *tmp;
    unsigned int dtb_load_addr = 0;

    if ((tmp = env_get("dtb_load_addr_virt")) != NULL) {
        dtb_load_addr = simple_strtoul(tmp, NULL, 16);
        printf("dtb_load_addr: 0x%X\n", dtb_load_addr);
    } else {
        printf("\nError! No dtb address found! Stop here...\n");
        while (1);
    }

    theKernel = (void (*)(int, void *))images->ep;
    printf("\nStarting kernel ... \n\n");

    disable_interrupts();
    flush_cache(0, 0);
#ifdef CONFIG_ERAGON3
    /* Open the D cache */
    asm volatile(
        "mfcr   r4, cr18\n"
        "bseti  r4, 3   \n"
        "mtcr   r4, cr18\n"
        :
        :
        : "r4"
    );
#endif
    board_prep_linux(images);
    theKernel(0x20150401, (void *)dtb_load_addr);
    return 1;
}