[359] | 1 | /* |
---|
[493] | 2 | * file : boot_entry.S |
---|
[359] | 3 | * date : 01/17/2014 |
---|
[490] | 4 | * author : Cesar Fuguet & Alain Greiner & Hao Liu |
---|
[359] | 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 | * |
---|
[493] | 21 | * - each processor P[x,y,0] uses a larger stack: 1,25 Kbytes. |
---|
| 22 | * - Other processors use a smaller stack: 0,25 Kbytes. |
---|
| 23 | * => the SEG_BOOT_STACK_SIZE cannot be smaller than |
---|
| 24 | * 256 * (1024 + 256) + (1024 - 256) * 256 = 512 Kbytes |
---|
[359] | 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 | /* The (x,y,lpid) values are obtained from the processor CP0 register, */ |
---|
[493] | 41 | /* where proc_id == (((x<<Y_WIDTH) + y)<<P_WIDTH) + lpid (fixed format) */ |
---|
| 42 | /* The continuous cluster index is computed as cluster_id = (x * Y_SIZE) + y */ |
---|
[359] | 43 | |
---|
[366] | 44 | mfc0 k0, CP0_PROCID |
---|
[493] | 45 | andi k0, k0, 0xFFF /* k0 <= proc_id */ |
---|
[427] | 46 | andi t1, k0, ((1<<P_WIDTH)-1) /* t1 <= lpid */ |
---|
| 47 | srl t2, k0, P_WIDTH /* t2 <= cluster_xy */ |
---|
| 48 | srl t3, t2, Y_WIDTH /* t3 <= x coordinate */ |
---|
| 49 | andi t4, t2, ((1<<Y_WIDTH)-1) /* t4 <= y coordinate */ |
---|
| 50 | la t6, Y_SIZE /* t6 <= Y_SIZE */ |
---|
[359] | 51 | multu t3, t6 |
---|
[493] | 52 | mflo t5 /* t5 <= x * Y_SIZE */ |
---|
[427] | 53 | addu t5, t5, t4 /* t5 <= cluster_id */ |
---|
[359] | 54 | |
---|
[493] | 55 | /* All processors initializes stack pointer, depending on x,y,lpid */ |
---|
| 56 | /* Processors P[x,y,0] : stack size = 1,25 Kbytes */ |
---|
[499] | 57 | /* Other processors : stack size = 0,25 Kbytes */ |
---|
[493] | 58 | /* In each cluster, the total stack size is NB_PROCS_MAX-1)*0x100 + 0x500 */ |
---|
[359] | 59 | |
---|
[493] | 60 | li t6, (NB_PROCS_MAX-1) * 0x100 + 0x500 /* t6 <= cluster_size */ |
---|
| 61 | multu t6, t5 |
---|
| 62 | mflo t7 /* t7 <= cluster_size * cluster_id */ |
---|
| 63 | la k0, SEG_BOOT_STACK_BASE |
---|
| 64 | addu k0, k0, t7 /* k0 <= stack base in cluster */ |
---|
| 65 | li k1, 0x500 /* k1 <= 1,25 Kbytes */ |
---|
| 66 | addu sp, k0, k1 /* P[x,y,0] stack top */ |
---|
| 67 | li k1, 0x100 /* k1 <= 0,25 bytes */ |
---|
| 68 | multu k1, t1 |
---|
| 69 | mflo k0 /* k0 <= 256 * lpid */ |
---|
| 70 | addu sp, sp, k0 /* P[x,y,lpid] stack top */ |
---|
[359] | 71 | |
---|
| 72 | /* All processors jump to the boot_init function */ |
---|
| 73 | |
---|
[490] | 74 | la k0, boot_init |
---|
| 75 | jr k0 |
---|
[359] | 76 | nop |
---|
| 77 | |
---|
| 78 | .end boot_entry |
---|
| 79 | |
---|
| 80 | .set reorder |
---|
| 81 | |
---|
| 82 | /* |
---|
| 83 | * vim: tabstop=4 : shiftwidth=4 : expandtab |
---|
| 84 | */ |
---|