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
RevLine 
[160]1/********************************************************************************/
[165]2/*      File : reset.S                                                              */
3/*      Author : Alain Greiner  & Mohamed karaoui                                   */
4/*      Date : 03/06/2012                                                                                       */
[160]5/********************************************************************************/
6/* This boot code is for a multi-cluster, multi-processor architecture,             */
[165]7/* running one or several multi-tasks software application(s) defined in        */
[160]8/* the mapping_info data-structure.                                                                     */
[165]9/* Procesor 0 uses the mapping_info data structure to build all page tables     */
10/* before jumping to the kernel_init code.                                                                              */
[160]11/* Other processors are waiting until the mapping_info signature has been       */
12/* modified by processor 0 (done while executing kernel_init code).             */
[165]13/* Implementation note:                                                                                                                 */
[160]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>
[165]20#include "../sys/mips32_registers.h"
[160]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
[165]47    jal boot_puts
[160]48    nop
49    mfc0        a0,     CP0_TIME
[165]50        jal     boot_putw
[160]51        nop
52    la  a0,     boot_lf_string
[165]53    jal boot_puts
[160]54    nop
55
[165]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
[160]67        la      a0,     boot_epc_string
[165]68    jal boot_puts
[160]69    nop
70    mfc0        a0,     CP0_EPC
[165]71        jal     boot_putw
[160]72    nop
73    la  a0,     boot_lf_string
[165]74    jal boot_puts
[160]75    nop
76
77        la      a0,     boot_cr_string
[165]78    jal boot_puts
[160]79    nop
80    mfc0        a0,     CP0_CR
[165]81        jal     boot_putw
[160]82    nop
83    la  a0,     boot_lf_string
[165]84    jal boot_puts
[160]85    nop
86
87        la      a0,     boot_sr_string
[165]88    jal boot_puts
[160]89    nop
90    mfc0        a0,     CP0_SR
[165]91        jal     boot_putw
[160]92    nop
93    la  a0,     boot_lf_string
[165]94    jal boot_puts
[160]95    nop
96
97        la      a0,     boot_bar_string
[165]98    jal boot_puts
[160]99    nop
100    mfc0        a0,     CP0_BAR
[165]101        jal     boot_putw
[160]102    nop
103    la  a0,     boot_lf_string
[165]104    jal boot_puts
[160]105    nop
106
107        j       boot_exit
108        nop
109
110/*******************************************/
111/* actual starting point for the boot code */
112/*******************************************/
113    .align      2
[165]114    .org        START_ORG
[160]115
116boot_start:
117    /* get the procid */
118    mfc0        k0,     CP0_PROCID
[165]119    andi        k0,     k0,     0xFFF   /* no more than 4096 processors... */
[160]120
[165]121    /* Only processor 0 does init */
122    bne k0,     zero,   boot_wait_signature
[160]123    nop
124
[165]125    /* Processor 0 get a temporary stack */
126    la      sp, seg_boot_stack_base
127    addiu       sp,     sp,     0x3000                          /* SP <= seg_boot_stack + 12K */
[160]128
[165]129    /* Processor 0 initialises all Page Tables */
130    jal boot_pt_init
[160]131    nop
[165]132 
133    /* jump to kernel_init */
134    j           boot_to_kernel_init
[160]135    nop
136
137boot_wait_signature:
[165]138
139    /* all other processors are waiting signature change */
[160]140    la  k0, seg_mapping_base
[165]141    cache   0x11,   0(k0)                               /* invalidate local cache copy */
142    lw  k0, 0(k0)                                               /* k0 <= mapping_info[0]       */
[160]143    li  k1,     OUT_MAPPING_SIGNATURE
144    bne k1, k0, boot_wait_signature
145    nop
146       
[165]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 */
[160]154
[165]155boot_to_kernel_init:
[160]156
[165]157    /* all processors initialize PTPR with PTAB[0] */
158    la      k1, _ptabs
[160]159    lw      k1, 0(k1)   
160    srl     k1, k1, 13
[165]161    mtc2        k1,     CP2_PTPR                /* PTPR <= _ptabs[0]  */
[160]162
[165]163        /* all processors activate MMU */
164    li      k1, 0xF
165    mtc2    k1, CP2_MODE        /* MODE register */
[160]166
167    /* jump to kernel_init */
[165]168    la      k0, seg_kernel_init_base
[160]169    j       k0
170    nop
171
[165]172boot_error_string:      .asciiz "\n[BOOT] Fatal Error in reset.S at cycle "
173boot_pid_string:        .asciiz "    PID  = "
[160]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.