source: soft/giet_vm/boot/reset.S @ 169

Last change on this file since 169 was 165, checked in by alain, 12 years ago

Introducing various modifications in kernel initialisation

File size: 4.8 KB
Line 
1/********************************************************************************/
2/*      File : reset.S                                                              */
3/*      Author : Alain Greiner  & Mohamed karaoui                                   */
4/*      Date : 03/06/2012                                                                                       */
5/********************************************************************************/
6/* This boot code is for a multi-cluster, multi-processor architecture,             */
7/* running one or several multi-tasks software application(s) defined in        */
8/* the mapping_info data-structure.                                                                     */
9/* Procesor 0 uses the mapping_info data structure to build all page tables     */
10/* before jumping to the kernel_init code.                                                                              */
11/* Other processors are waiting until the mapping_info signature has been       */
12/* modified by processor 0 (done while executing kernel_init code).             */
13/* Implementation note:                                                                                                                 */
14/* The entry point is 0xbfc00000, but the actual boot code starts at address    */
15/* 0xbfc00500, and a minimal boot exception handler is implemented at address   */
16/* 0xbfc0380.                                                                                                   */
17/********************************************************************************/
18               
19#include <giet_config.h>
20#include "../sys/mips32_registers.h"
21
22#define EXCEP_ORG               0x380
23#define START_ORG               0x500
24
25#define OUT_MAPPING_SIGNATURE   0xBABEF00D
26
27        .section .boot,"ax",@progbits
28        .align  2
29        .set noreorder
30
31/********************************************************/
32/* reset entry point                                    */
33/* (address 0xBFC00000 imposed by the hardware)         */
34/********************************************************/
35boot_reset:
36    j   boot_start
37        nop
38
39/*******************************************************/
40/* handling exceptions in the boot phase               */
41/* (address 0xBFC00380 imposed by the hardware         */
42/*******************************************************/
43        .align  2
44    .org        EXCEP_ORG
45boot_excep:
46    la  a0,     boot_error_string
47    jal boot_puts
48    nop
49    mfc0        a0,     CP0_TIME
50        jal     boot_putw
51        nop
52    la  a0,     boot_lf_string
53    jal boot_puts
54    nop
55
56        la      a0,     boot_pid_string
57    jal boot_puts
58    nop
59    mfc0        k0,     CP0_PROCID
60    andi        a0,     k0,     0xFFF
61        jal     boot_putw
62    nop
63    la  a0,     boot_lf_string
64    jal boot_puts
65    nop
66
67        la      a0,     boot_epc_string
68    jal boot_puts
69    nop
70    mfc0        a0,     CP0_EPC
71        jal     boot_putw
72    nop
73    la  a0,     boot_lf_string
74    jal boot_puts
75    nop
76
77        la      a0,     boot_cr_string
78    jal boot_puts
79    nop
80    mfc0        a0,     CP0_CR
81        jal     boot_putw
82    nop
83    la  a0,     boot_lf_string
84    jal boot_puts
85    nop
86
87        la      a0,     boot_sr_string
88    jal boot_puts
89    nop
90    mfc0        a0,     CP0_SR
91        jal     boot_putw
92    nop
93    la  a0,     boot_lf_string
94    jal boot_puts
95    nop
96
97        la      a0,     boot_bar_string
98    jal boot_puts
99    nop
100    mfc0        a0,     CP0_BAR
101        jal     boot_putw
102    nop
103    la  a0,     boot_lf_string
104    jal boot_puts
105    nop
106
107        j       boot_exit
108        nop
109
110/*******************************************/
111/* actual starting point for the boot code */
112/*******************************************/
113    .align      2
114    .org        START_ORG
115
116boot_start:
117    /* get the procid */
118    mfc0        k0,     CP0_PROCID
119    andi        k0,     k0,     0xFFF   /* no more than 4096 processors... */
120
121    /* Only processor 0 does init */
122    bne k0,     zero,   boot_wait_signature
123    nop
124
125    /* Processor 0 get a temporary stack */
126    la      sp, seg_boot_stack_base
127    addiu       sp,     sp,     0x3000                          /* SP <= seg_boot_stack + 12K */
128
129    /* Processor 0 initialises all Page Tables */
130    jal boot_pt_init
131    nop
132 
133    /* jump to kernel_init */
134    j           boot_to_kernel_init
135    nop
136
137boot_wait_signature:
138
139    /* all other processors are waiting signature change */
140    la  k0, seg_mapping_base
141    cache   0x11,   0(k0)                               /* invalidate local cache copy */
142    lw  k0, 0(k0)                                               /* k0 <= mapping_info[0]       */
143    li  k1,     OUT_MAPPING_SIGNATURE
144    bne k1, k0, boot_wait_signature
145    nop
146       
147    /* all other processors get a temporary stack of 256 bytes */
148    la      sp, seg_boot_stack_base
149    addiu   sp, sp, 0x3100                             
150    mfc0        k0, CP0_PROCID
151    andi    k0, k0, 0xFFF
152    sll     k0, k0, 8                                   
153    addu    sp, sp, k0          /* SP <= seg_boot_stack_base + 12K + (pid+1)*256 */
154
155boot_to_kernel_init:
156
157    /* all processors initialize PTPR with PTAB[0] */
158    la      k1, _ptabs
159    lw      k1, 0(k1)   
160    srl     k1, k1, 13
161    mtc2        k1,     CP2_PTPR                /* PTPR <= _ptabs[0]  */
162
163        /* all processors activate MMU */
164    li      k1, 0xF
165    mtc2    k1, CP2_MODE        /* MODE register */
166
167    /* jump to kernel_init */
168    la      k0, seg_kernel_init_base
169    j       k0
170    nop
171
172boot_error_string:      .asciiz "\n[BOOT] Fatal Error in reset.S at cycle "
173boot_pid_string:        .asciiz "    PID  = "
174boot_sr_string:         .asciiz "    SR   = "
175boot_cr_string:         .asciiz "    CR   = "
176boot_epc_string:        .asciiz "    EPC  = "
177boot_bar_string:        .asciiz "    BAR  = "
178boot_lf_string:         .asciiz "\n"
179
180        .set    reorder
181
182
Note: See TracBrowser for help on using the repository browser.