source: trunk/tools/bootloader_tsar/boot_entry.S @ 1

Last change on this file since 1 was 1, checked in by alain, 7 years ago

First import

File size: 7.8 KB
Line 
1/*************************************************************************************************
2 * This file contains the entry point of the ALMOS-MK boot-loader for TSAR architecture.         *
3 * It supports a generic multi-clusters / multi-processors architecture                          *
4 *                                                                                               *
5 * - The number of clusters is defined by the (X_SIZE, Y_SIZE) parameters in the                 *
6 *   hard_config.h file (up to 256 clusters).                                                    *
7 * - The number of processors per cluster is defined by the NB_PROCS_MAX parameter in the        *
8 *   hard_config.h file (up to 4 processors per cluster).                                        *
9 *                                                                                               *
10 * This assembly code is executed by all cores. It has 2 versions (in order to see if the        *
11 * contention created by the ARCHINFO core descriptor table scanning loops is acceptable):       *
12 * with or without the assumption that the core hardware identifier gid has a fixed format:      *
13 *                                                                                               *
14 * - Version with fixed format: gid == (((x << Y_WIDTH) + y) << PADDR_WIDTH) + lid               *
15 *   It does 3 things:                                                                           *
16 *      + It initializes the stack pointer depending on the lid extracted from the gid,          *
17 *        using the BOOT_STACK_BASE and BOOT_STACK_SIZE parameters defined in the                *
18 *        'boot_config.h' file,                                                                  *
19 *      + It changes the value of the address extension registers using the cxy extracted        *
20 *        from the gid,                                                                          *
21 *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2       *
22 *        arguments which are the cxy and lid of each core to this function.                     *
23 *                                                                                               *
24 * - Version without fixed format                                                                *
25 *   It has to perform an additional step in order to extract the (cxy,lid) values from the      *
26 *   arch_info.bin structure that has been loaded in the cluster (0,0) memory by the bscpu.      *
27 *      + Each core other than the bscpu scans the core descriptor table in the arch_info.bin    *
28 *        structure to make an associative search on the (gid), and get the (cxy,lid).           *
29 *      + It initializes the stack pointer depending on the lid, using the BOOT_STACK_BASE       *
30 *        and BOOT_STACK_SIZE parameters defined in the 'boot_config.h' file,                    *
31 *      + It changes the value of the address extension registers using cxy obtained             *
32 *        previously,                                                                            *
33 *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2       *
34 *        arguments which are the cxy and lid of each core to this function.                     *
35 *************************************************************************************************/
36
37#include "mips32_registers.h"
38#include "hard_config.h"
39#include "boot_config.h"
40
41    .section    .text, "ax", @progbits
42
43    .globl      boot_entry
44    .ent        boot_entry
45
46    .align      2
47    .set        noreorder
48
49boot_entry:
50
51#if USE_FIXED_FORMAT
52
53/*************
54 * VERSION 1 *
55 *************/
56
57    /*
58     * Get (cxy, lid) values from gid contained in coprocessor0 register.
59     */
60
61    mfc0    k0,     CP0_PROCID         
62    andi    k0,     k0,     0xFFF                       /* k0 <= gid                        */
63    andi    t1,     k0,     ((1 << PADDR_WIDTH) - 1)    /* t1 <= lid                        */
64    srl     t2,     k0,     PADDR_WIDTH                 /* t2 <= cxy                        */
65   
66    /*
67     * Initializing stack pointer from previously retrieved lid value.
68     */
69   
70    la      t0,     BOOT_STACK_BASE                     /* t0 <= BOOT_STACK_BASE            */
71    li      k1,     BOOT_STACK_SIZE                     /* k1 <= BOOT_STACK_SIZE            */
72    multu   k1,     t1
73    mflo    k0,                                         /* k0 <= BOOT_STACK_SIZE * lid      */
74    subu    sp,     t0,     k0                          /* P[cxy,lid] stack top initialized */
75
76    /*
77     * Switching to local DSPACE by changing the value of the address extension registers.
78     */
79
80    mtc2    t2,     CP2_DATA_PADDR_EXT
81
82    /*
83     * Jumping to boot_loader() function after passing 2 arguments in the registers.
84     */
85
86    or      a0,     zero,   t1                          /* a0 <= lid                        */     
87    or      a1,     zero,   t2                          /* a1 <= cxy                        */
88    la      ra,     boot_loader
89    jr      ra
90    nop
91
92#else
93
94/*************
95 * VERSION 2 *
96 *************/
97
98    /*
99     * Testing if this is bscpu.
100     */
101
102    mfc0    k0,     CP0_PROCID         
103    andi    k0,     k0,     0xFFF                       /* k0 <= gid                        */
104
105    li      t1,     BOOT_CORE_GID                       /* t1 <= bscpu gid                  */
106    or      t3,     zero,   zero                        /* t3 <= bscpu lid = 0              */
107    beq     k0,     t1,     bscpu_exit                  /* if bscpu, skip scanning core tbl */
108    li      t4,     BOOT_CORE_CXY                       /* t4 <= bscpu cxy                  */
109
110    /*
111     * Getting base address of the core descriptor table in 'arch_info.bin' file.
112     */
113
114    la      t0,     ARCHINFO_BASE                       /* t0 <= ARCHINFO_BASE              */
115    li      t1,     0x80                                /* t1 <= ARCHINFO_HEADER_SIZE       */
116    addu    t2,     t0,     t1                          /* t2 <= ARCHINFO_CORE_BASE         */
117
118    /*
119     * Scanning the core descriptor table if this is not bscpu. TODO If not found?
120     */
121
122    li      t3,     0x8                                 /* t3 <= ARCHINFO_CORE_SIZE         */
123   
124scanning_core_table:
125    lw      t1,     0(t2)                               /* t1 <= archinfo_core.gid          */
126    bne     t1,     k0,     scanning_core_table         /* if (t1 != k0) => loop            */
127    addu    t2,     t2,     t3                          /* t2 <= @ next archinfo_core       */
128
129    /*
130     * Getting (cxy, lid) values from the found core descriptor.
131     */
132   
133    lw      t3,     -8(t2)                              /* t3 <= lid                        */
134    lw      t4,     -4(t2)                              /* t4 <= cxy                        */
135
136    /*
137     * Initializing stack pointer from previously retrieved lid value.
138     */
139
140bscpu_exit:   
141    la      t0,     BOOT_STACK_BASE                     /* t0 <= BOOT_STACK_BASE            */
142    li      k1,     BOOT_STACK_SIZE                     /* k1 <= BOOT_STACK_SIZE            */
143    multu   k1,     t3
144    mflo    k0                                          /* k0 <= BOOT_STACK_SIZE * lid      */
145    subu    sp,     t0,     k0                          /* P[cxy,lid] stack top initialized */
146
147    /*
148     * Switching to local DSPACE by changing the value of the address extension registers.
149     */
150
151    mtc2    t4,     CP2_DATA_PADDR_EXT
152
153    /*
154     * Jumping to boot_loader() function after passing 2 arguments in the registers.
155     */
156
157    or      a0,     zero,   t3                          /* a0 <= lid                        */     
158    or      a1,     zero,   t4                          /* a1 <= cxy                        */
159    la      ra,     boot_loader
160    jr      ra
161    nop
162
163#endif
164
165    .end boot_entry
166
167    .set reorder
Note: See TracBrowser for help on using the repository browser.