1 | /* |
---|
2 | * file : boot.S |
---|
3 | * date : 01/17/2014 |
---|
4 | * author : Cesar Fuguet & Alain Greiner |
---|
5 | * |
---|
6 | * This file contains the boot_entry() function that is the entry |
---|
7 | * point for the GIET_VM bootloader. |
---|
8 | * It supports a generic multi-clusters / multi-processors architecture, |
---|
9 | * containing at most 1024 processors. |
---|
10 | * - The number of clusters is defined by the (X_SIZE,Y_SIZE) parameters |
---|
11 | * in the hard_config.h file (up to 256 clusters). |
---|
12 | * - The number of processors per cluster is defined by the NB_PROCS_MAX |
---|
13 | * parameter in the hard_config.h file (up to 4 processors per cluster). |
---|
14 | * |
---|
15 | * This assembly code is executed by all processors. |
---|
16 | * It initializes the stack pointer depending on the proc_id, |
---|
17 | * and using the SEG_BOOT_STACK_BASE and SEG_BOOT_STACK_SIZE |
---|
18 | * parameters defined in the hard_config.h file, and jumps |
---|
19 | * to the boot_init() fuction defined in the boot.c file. |
---|
20 | * |
---|
21 | * - Processor 0 uses a larger stack: 64 Kbytes. |
---|
22 | * - Other processors use a smaller stack: 256 bytes. |
---|
23 | * => the SEG_BOOT_STACK_SIZE cannot be smaller 320 Kytes. |
---|
24 | * (64K + 1024 * 256 = 320 Kbytes = 0x50000) |
---|
25 | */ |
---|
26 | |
---|
27 | #include "mips32_registers.h" |
---|
28 | #include "hard_config.h" |
---|
29 | |
---|
30 | .section .text,"ax",@progbits |
---|
31 | |
---|
32 | .globl boot_entry |
---|
33 | .ent boot_entry |
---|
34 | |
---|
35 | .align 2 |
---|
36 | .set noreorder |
---|
37 | |
---|
38 | boot_entry: |
---|
39 | |
---|
40 | |
---|
41 | /* All processors compute proc_id = (cluster_id * NBPROCS) + lpid */ |
---|
42 | /* where cluster_id = (x * Y_SIZE) + y */ |
---|
43 | /* The (x,y,lpid) values are obtained from the processor CP0 register, */ |
---|
44 | /* where proc_xyl == (((x<<4) + y) * NB_PROCS_MAX) + lpid */ |
---|
45 | /* (proc_id is a "continuous" index, while proc_xyl is a "fixed format" index */ |
---|
46 | |
---|
47 | mfc0 k0, CP0_PROCID |
---|
48 | andi k0, k0, 0x3FF /* k0 <= proc_xyl */ |
---|
49 | la t7, NB_PROCS_MAX /* t7 <= NBPROCS */ |
---|
50 | divu k0, t7 |
---|
51 | mfhi t1 /* t1 <= lpid */ |
---|
52 | mflo t2 /* t2 <= cluster_xy */ |
---|
53 | srl t3, t2, 4 /* t3 <= x coordinate */ |
---|
54 | andi t4, t2, 0xF /* t4 <= y coordinate */ |
---|
55 | la t6, Y_SIZE /* t6 <= Y_SIZE */ |
---|
56 | multu t3, t6 |
---|
57 | mflo t5 |
---|
58 | addu t5, t5, t4 /* t5 <= cluster_id */ |
---|
59 | multu t5, t7 |
---|
60 | mflo t0 |
---|
61 | addu t0, t0, t1 /* t0 <= proc_id */ |
---|
62 | |
---|
63 | |
---|
64 | /* All processors initializes stack pointer, depending on proc_id */ |
---|
65 | |
---|
66 | la k0, SEG_BOOT_STACK_BASE |
---|
67 | li k1, 0x10000 /* k1 <= P0 stack size == 64 Kbytes */ |
---|
68 | addu sp, k0, k1 /* P0 stack from base to (base + 64K) */ |
---|
69 | |
---|
70 | li k1, 0x100 /* k1 <= Pi stack size == 256 bytes */ |
---|
71 | multu k1, t0 |
---|
72 | mflo k0 /* k0 <= 256 * proc_id */ |
---|
73 | addu sp, sp, k1 |
---|
74 | addu sp, sp, k0 /* Pi stacks from base + 64K + proc_id*256 */ |
---|
75 | |
---|
76 | |
---|
77 | /* All processors jump to the boot_init function */ |
---|
78 | |
---|
79 | la k0, boot_init |
---|
80 | jr k0 |
---|
81 | nop |
---|
82 | |
---|
83 | .end boot_entry |
---|
84 | |
---|
85 | .set reorder |
---|
86 | |
---|
87 | /* |
---|
88 | * vim: tabstop=4 : shiftwidth=4 : expandtab |
---|
89 | */ |
---|