Changeset 96e0748d in mainline


Ignore:
Timestamp:
2009-02-17T22:47:27Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f89979b
Parents:
e662a5f
Message:

make arch_pre_main optional, don't force any specific prototype
simplify boot process
mips32: detect number of configured CPUs in msim

Files:
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/loader/asm.h

    re662a5f r96e0748d  
    3333/** @file
    3434 *  @brief Functions implemented in assembly.
    35  */ 
     35 */
    3636
    3737
     
    4141
    4242/** Copies cnt bytes from dst to src.
    43  * 
     43 *
    4444 * @param dst Destination address.
    4545 * @param src Source address.
    46  * @param cnt Count of bytes to be copied. 
     46 * @param cnt Count of bytes to be copied.
    4747 */
    4848#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
     
    5959/** Jumps to the kernel entry point.
    6060 *
    61  * @param entry          Kernel entry point address.
    62  * @param bootinfo       Structure holding information about loaded tasks.
    63  * @param bootinfo_size  Size of the bootinfo structure.
     61 * @param entry    Kernel entry point address.
     62 * @param bootinfo Structure holding information about loaded tasks.
     63 *
    6464 */
    65 extern void jump_to_kernel(void *entry, void *bootinfo,
    66     unsigned int bootinfo_size) __attribute__((noreturn));
     65extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
    6766
    6867
  • boot/arch/arm32/loader/boot.S

    re662a5f r96e0748d  
    5454page_table:
    5555        .skip PTL0_ENTRIES * PTL0_ENTRY_SIZE
    56 
    57 
  • boot/arch/arm32/loader/main.c

    re662a5f r96e0748d  
    3333/** @file
    3434 *  @brief Bootstrap.
    35  */ 
     35 */
    3636
    3737
     
    4040#include "_components.h"
    4141#include <printf.h>
     42#include <align.h>
    4243#include <macros.h>
    4344
     
    110111       
    111112        printf("\nBooting the kernel...\n");
    112         jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
     113        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
    113114}
    114115
  • boot/arch/arm32/loader/main.h

    re662a5f r96e0748d  
    3333/** @file
    3434 *  @brief Boot related declarations.
    35  */ 
     35 */
    3636
    3737
     
    3939#define BOOT_arm32_MAIN_H
    4040
    41 
    42 /** Aligns to the nearest higher address.
    43  *
    44  * @param addr  Address or number to be aligned.
    45  * @param align Size of alignment, must be power of 2.
    46  */
    47 #define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
    4841
    4942/** Maximum number of tasks in the #bootinfo_t struct. */
     
    7568/** @}
    7669 */
    77 
  • boot/arch/mips32/loader/asm.h

    re662a5f r96e0748d  
    3030#define BOOT_mips32_ASM_H_
    3131
    32 #define PAGE_SIZE 16384
    33 #define PAGE_WIDTH 14
     32#define PAGE_SIZE   16384
     33#define PAGE_WIDTH  14
    3434
    35 #define memcpy(dst, src, cnt)   __builtin_memcpy((dst), (src), (cnt))
     35#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
    3636
    37 void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
     37void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
    3838
    3939#endif
  • boot/arch/mips32/loader/boot.S

    re662a5f r96e0748d  
    2828
    2929#include "regname.h"
    30 
    31 #define INITIAL_STACK        0x80040000
    32 #define MSIM_DORDER_ADDRESS  0x90000004
     30#include "main.h"
    3331
    3432.set noat
     
    4139start:
    4240       
     41        /* Setup CPU map (on msim this code
     42           is executed in parallel on all CPUs,
     43           but it not an issue) */
     44        la $a0, CPUMAP
     45       
     46        sw $zero, 0($a0)
     47        sw $zero, 4($a0)
     48        sw $zero, 8($a0)
     49        sw $zero, 12($a0)
     50       
     51        sw $zero, 16($a0)
     52        sw $zero, 20($a0)
     53        sw $zero, 24($a0)
     54        sw $zero, 28($a0)
     55       
     56        sw $zero, 32($a0)
     57        sw $zero, 36($a0)
     58        sw $zero, 40($a0)
     59        sw $zero, 44($a0)
     60       
     61        sw $zero, 48($a0)
     62        sw $zero, 52($a0)
     63        sw $zero, 56($a0)
     64        sw $zero, 60($a0)
     65       
     66        sw $zero, 64($a0)
     67        sw $zero, 68($a0)
     68        sw $zero, 72($a0)
     69        sw $zero, 76($a0)
     70       
     71        sw $zero, 80($a0)
     72        sw $zero, 84($a0)
     73        sw $zero, 88($a0)
     74        sw $zero, 92($a0)
     75       
     76        sw $zero, 96($a0)
     77        sw $zero, 100($a0)
     78        sw $zero, 104($a0)
     79        sw $zero, 108($a0)
     80       
     81        sw $zero, 112($a0)
     82        sw $zero, 116($a0)
     83        sw $zero, 120($a0)
     84        sw $zero, 124($a0)
     85       
     86        lui $a1, 1
     87       
    4388#ifdef MACHINE_msim
     89       
    4490        /* Read dorder value */
    4591        la $k0, MSIM_DORDER_ADDRESS
    46         lw $k0, ($k0)
     92        lw $k1, ($k0)
    4793       
    4894        /* If we are not running on BSP
    49            end in an infinite loop  */
    50         beq $k0, $zero, bsp
     95           then end in an infinite loop  */
     96        beq $k1, $zero, bsp
    5197        nop
     98       
     99        /* Record CPU presence */
     100        sll $a2, $k1, 2
     101        addu $a2, $a2, $a0
     102        sw $a1, ($a2)
    52103       
    53104        loop:
     
    58109       
    59110        bsp:
     111                /* Record CPU presence */
     112                sw $a1, ($a0)
     113               
    60114                /* Setup initial stack */
    61                 lui $sp, INITIAL_STACK >> 16
    62                 ori $sp, $sp, INITIAL_STACK & 0xffff
     115                la $sp, INITIAL_STACK
    63116               
    64117                j bootstrap
  • boot/arch/mips32/loader/main.c

    re662a5f r96e0748d  
    2929#include "main.h"
    3030#include <printf.h>
     31#include <align.h>
    3132#include <macros.h>
    3233#include "msim.h"
     
    7475       
    7576        printf("\nCopying components\n");
     77       
    7678        unsigned int top = 0;
    7779        bootinfo.cnt = 0;
    78         for (i = 0; i < COMPONENTS; i++) {
     80        for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
    7981                printf(" %s...", components[i].name);
    8082                top = ALIGN_UP(top, PAGE_SIZE);
     
    8991        }
    9092       
     93        unsigned int *cpumap = (unsigned int *) CPUMAP;
     94        bootinfo.cpumap = 0;
     95        for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
     96                if (cpumap[i] != 0)
     97                        bootinfo.cpumap |= (1 << i);
     98        }
     99       
    91100        printf("\nBooting the kernel...\n");
    92         jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
     101        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
    93102}
  • boot/arch/mips32/loader/main.h

    re662a5f r96e0748d  
    3030#define BOOT_mips32_MAIN_H_
    3131
    32 /** Align to the nearest higher address.
    33  *
    34  * @param addr  Address or size to be aligned.
    35  * @param align Size of alignment, must be power of 2.
    36  */
    37 #define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
     32#define CPUMAP               0x80001000
     33#define INITIAL_STACK        0x80002000
     34#define MSIM_DORDER_ADDRESS  0xb0000004
    3835
    39 #define TASKMAP_MAX_RECORDS 32
     36#define TASKMAP_MAX_RECORDS  32
     37#define CPUMAP_MAX_RECORDS   32
     38
     39#ifndef __ASM__
    4040
    4141typedef struct {
     
    4545
    4646typedef struct {
     47        unsigned int cpumap;
    4748        unsigned int cnt;
    4849        task_t tasks[TASKMAP_MAX_RECORDS];
     
    5354
    5455#endif
     56
     57#endif
  • kernel/arch/arm32/include/arch.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup arm32   
     29/** @addtogroup arm32
    3030 * @{
    3131 */
     
    3737#define KERN_arm32_ARCH_H_
    3838
     39#define TASKMAP_MAX_RECORDS  32
     40#define CPUMAP_MAX_RECORDS   32
     41
     42#include <typedefs.h>
     43
     44typedef struct {
     45        uintptr_t addr;
     46        uint32_t size;
     47} utask_t;
     48
     49typedef struct {
     50        uint32_t cnt;
     51        utask_t tasks[TASKMAP_MAX_RECORDS];
     52} bootinfo_t;
     53
     54extern void arch_pre_main(void *entry, bootinfo_t *bootinfo);
     55
    3956#endif
    4057
  • kernel/arch/arm32/include/asm/boot.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup arm32   
     29/** @addtogroup arm32
    3030 * @{
    3131 */
     
    4040#define TEMP_STACK_SIZE 0x100
    4141
    42 #ifndef __ASM__
    43 
    44 /** Kernel entry point.
    45  *
    46  * Implemented in assembly. Copies boot_bootinfo (declared as bootinfo in
    47  * boot/arch/arm32/loader/main.c) to #bootinfo struct. Then jumps to
    48  * #arch_pre_main and #main_bsp.
    49  *
    50  * @param entry          Entry point address (not used).
    51  * @param boot_bootinfo  Struct holding information about loaded tasks.
    52  * @param bootinfo_size  Size of the bootinfo structure.
    53  */
    54 extern void kernel_image_start(void *entry, void *boot_bootinfo,
    55     unsigned int bootinfo_size);
    56 
    57 #endif
    58 
    5942#endif
    6043
  • kernel/arch/arm32/src/arm32.c

    re662a5f r96e0748d  
    3535
    3636#include <arch.h>
    37 #include <arch/boot.h>
    3837#include <config.h>
    3938#include <arch/console.h>
     
    4948#include <arch/machine.h>
    5049#include <userspace.h>
    51 
    52 /** Information about loaded tasks. */
    53 bootinfo_t bootinfo;
     50#include <macros.h>
    5451
    5552/** Performs arm32 specific initialization before main_bsp() is called. */
    56 void arch_pre_main(void)
     53void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
    5754{
    5855        unsigned int i;
    59 
    60         init.cnt = bootinfo.cnt;
    61 
    62         for (i = 0; i < bootinfo.cnt; ++i) {
    63                 init.tasks[i].addr = bootinfo.tasks[i].addr;
    64                 init.tasks[i].size = bootinfo.tasks[i].size;
     56       
     57        init.cnt = bootinfo->cnt;
     58       
     59        for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); ++i) {
     60                init.tasks[i].addr = bootinfo->tasks[i].addr;
     61                init.tasks[i].size = bootinfo->tasks[i].size;
    6562        }
    66        
    6763}
    6864
  • kernel/arch/arm32/src/start.S

    re662a5f r96e0748d  
    4141        bic r3, r3, #0x1f
    4242        orr r3, r3, #0x13
    43         msr cpsr_c, r3 
     43        msr cpsr_c, r3
    4444       
    4545        ldr sp, =temp_stack
    46 
    47         cmp r2, #0
    48         beq bootinfo_end
    49 
    50         ldr r3, =bootinfo
    51 
    52         bootinfo_loop:
    53                 ldr r4, [r1]
    54                 str r4, [r3]
    55 
    56                 add r1, r1, #4
    57                 add r3, r3, #4
    58                 add r2, r2, #-4
    59 
    60                 cmp r2, #0
    61                 bne bootinfo_loop
    6246       
    63         bootinfo_end:
    64 
    6547        bl arch_pre_main
    66 
     48       
    6749        bl main_bsp
    6850
     
    7557supervisor_sp:
    7658        .space 4
    77 
  • kernel/arch/ia64/include/arch.h

    re662a5f r96e0748d  
    4040#include <arch/ski/ski.h>
    4141
     42extern void arch_pre_main(void);
     43
    4244#endif
    4345
  • kernel/arch/mips32/include/arch.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    3636#define KERN_mips32_ARCH_H_
    3737
     38#define TASKMAP_MAX_RECORDS  32
     39#define CPUMAP_MAX_RECORDS   32
     40
     41#include <typedefs.h>
     42
     43extern count_t cpu_count;
     44
     45typedef struct {
     46        uintptr_t addr;
     47        uint32_t size;
     48} utask_t;
     49
     50typedef struct {
     51        uint32_t cpumap;
     52        uint32_t cnt;
     53        utask_t tasks[TASKMAP_MAX_RECORDS];
     54} bootinfo_t;
     55
     56extern void arch_pre_main(void *entry, bootinfo_t *bootinfo);
     57
    3858#endif
    3959
  • kernel/arch/mips32/include/asm/boot.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
  • kernel/arch/mips32/src/mips32.c

    re662a5f r96e0748d  
    3434
    3535#include <arch.h>
    36 #include <arch/boot.h>
    3736#include <arch/cp0.h>
    3837#include <arch/exception.h>
     
    5958#include <arch/asm/regname.h>
    6059
    61 /* Size of the code jumping to the exception handler code 
    62  * - J+NOP 
    63  */
    64 #define EXCEPTION_JUMP_SIZE    8
    65 
    66 #define TLB_EXC ((char *) 0x80000000)
    67 #define NORM_EXC ((char *) 0x80000180)
    68 #define CACHE_EXC ((char *) 0x80000100)
     60/* Size of the code jumping to the exception handler code
     61 * - J+NOP
     62 */
     63#define EXCEPTION_JUMP_SIZE  8
     64
     65#define TLB_EXC    ((char *) 0x80000000)
     66#define NORM_EXC   ((char *) 0x80000180)
     67#define CACHE_EXC  ((char *) 0x80000100)
    6968
    7069
    7170/* Why the linker moves the variable 64K away in assembler
    72  * when not in .text section ????????
    73  */
     71 * when not in .text section?
     72 */
     73
     74/* Stack pointer saved when entering user mode */
    7475uintptr_t supervisor_sp __attribute__ ((section (".text")));
    75 /* Stack pointer saved when entering user mode */
    76 /* TODO: How do we do it on SMP system???? */
    77 bootinfo_t bootinfo __attribute__ ((section (".text")));
    78 
    79 void arch_pre_main(void)
     76
     77count_t cpu_count = 0;
     78
     79void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
    8080{
    8181        /* Setup usermode */
    82         init.cnt = bootinfo.cnt;
    83        
    84         uint32_t i;
    85        
    86         for (i = 0; i < bootinfo.cnt; i++) {
    87                 init.tasks[i].addr = bootinfo.tasks[i].addr;
    88                 init.tasks[i].size = bootinfo.tasks[i].size;
     82        init.cnt = bootinfo->cnt;
     83       
     84        count_t i;
     85        for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) {
     86                init.tasks[i].addr = bootinfo->tasks[i].addr;
     87                init.tasks[i].size = bootinfo->tasks[i].size;
     88        }
     89       
     90        for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
     91                if ((bootinfo->cpumap & (1 << i)) != 0)
     92                        cpu_count++;
    8993        }
    9094}
  • kernel/arch/mips32/src/smp/smp.c

    re662a5f r96e0748d  
    3333 */
    3434
     35#include <config.h>
    3536#include <smp/smp.h>
     37#include <arch/arch.h>
    3638
    3739#ifdef CONFIG_SMP
     
    3941void smp_init(void)
    4042{
     43        config.cpu_count = cpu_count;
    4144}
    4245
  • kernel/arch/mips32/src/start.S

    re662a5f r96e0748d  
    3232#include <arch/context_offset.h>
    3333#include <arch/stack.h>
    34        
     34
    3535.text
    3636
     
    153153        # Move $k0 (superveisor_sp)
    154154        lw $k0, 0($k0)
    155 1:             
     1551:
    156156.endm
    157                
     157
    158158.org 0x0
    159159kernel_image_start:
     
    162162        ori $sp, $sp, %lo(end_stack)
    163163       
     164        /* Not sure about this, but might
     165           be needed for PIC code */
     166        lui $gp, 0x8000
     167       
    164168        /* $a1 contains physical address of bootinfo_t */
    165         /* $a2 contains size of bootinfo_t */
    166        
    167         beq $a2, $0, bootinfo_end
    168        
    169         /* Not sure about this, but might be needed for PIC code???? */
    170         lui $gp, 0x8000
    171        
    172         lui $a3, %hi(bootinfo)
    173         ori $a3, $a3, %lo(bootinfo)
    174        
    175         bootinfo_loop:
    176                
    177                 lw $v0, 0($a1)
    178                 sw $v0, 0($a3)
    179                
    180                 addi $a1, $a1, 4
    181                 addi $a3, $a3, 4
    182                 addi $a2, $a2, -4
    183                
    184                 bgtz $a2, bootinfo_loop
    185                 nop
    186                
    187         bootinfo_end:
    188169       
    189170        jal arch_pre_main
     
    206187exception_entry:
    207188        j exception_handler
    208         nop     
    209        
     189        nop
     190
    210191exception_handler:
    211192        KERNEL_STACK_TO_K0
     
    216197        mfc0 $k0, $cause
    217198       
    218         sra $k0, $k0, 0x2               # cp0_exc_cause() part 1
    219         andi $k0, $k0, 0x1f             # cp0_exc_cause() part 2
    220         sub $k0, 8                      # 8 = SYSCALL
     199        sra $k0, $k0, 0x2    # cp0_exc_cause() part 1
     200        andi $k0, $k0, 0x1f  # cp0_exc_cause() part 2
     201        sub $k0, 8           # 8 = SYSCALL
    221202       
    222203        beqz $k0, syscall_shortcut
    223         add $k0, 8                      # Revert $k0 back to correct exc number
     204        add $k0, 8           # Revert $k0 back to correct exc number
    224205       
    225206        REGISTERS_STORE_AND_EXC_RESET $sp
    226207       
    227208        move $a1, $sp
    228         jal exc_dispatch                # exc_dispatch(excno, register_space)
     209        jal exc_dispatch     # exc_dispatch(excno, register_space)
    229210        move $a0, $k0
    230211
  • kernel/arch/ppc32/include/arch.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup ppc32   
     29/** @addtogroup ppc32
    3030 * @{
    3131 */
     
    3636#define KERN_ppc32_ARCH_H_
    3737
    38 #include <arch/drivers/cuda.h>
     38extern void arch_pre_main(void);
    3939
    4040#endif
  • kernel/arch/ppc32/include/boot/boot.h

    re662a5f r96e0748d  
    2727 */
    2828
    29 /** @addtogroup ppc32   
     29/** @addtogroup ppc32
    3030 * @{
    3131 */
     
    3636#define KERN_ppc32_BOOT_H_
    3737
    38 #define BOOT_OFFSET             0x8000
     38#define BOOT_OFFSET  0x8000
    3939
    4040/* Temporary stack size for boot process */
    41 #define TEMP_STACK_SIZE 0x1000
     41#define TEMP_STACK_SIZE  0x1000
    4242
    43 #define TASKMAP_MAX_RECORDS 32
    44 #define MEMMAP_MAX_RECORDS 32
     43#define TASKMAP_MAX_RECORDS  32
     44#define MEMMAP_MAX_RECORDS   32
    4545
    4646#ifndef __ASM__
  • kernel/arch/ppc32/src/boot/boot.S

    re662a5f r96e0748d  
    3434.global kernel_image_start
    3535kernel_image_start:
    36 
     36       
    3737        # load temporal kernel stack
    3838       
     
    5353       
    5454        addis r3, r3, 0x8000
    55 
     55       
    5656        lis r31, bootinfo@ha
    5757        addi r31, r31, bootinfo@l  # r31 = bootinfo
  • kernel/arch/ppc32/src/ppc32.c

    re662a5f r96e0748d  
    4646#include <ddi/irq.h>
    4747#include <arch/drivers/pic.h>
     48#include <macros.h>
    4849
    49 #define IRQ_COUNT       64
     50#define IRQ_COUNT  64
    5051
    5152bootinfo_t bootinfo;
     
    5354void arch_pre_main(void)
    5455{
    55         /* Setup usermode */
    5656        init.cnt = bootinfo.taskmap.count;
    5757       
    5858        uint32_t i;
    5959       
    60         for (i = 0; i < bootinfo.taskmap.count; i++) {
     60        for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) {
    6161                init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
    6262                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
  • kernel/arch/sparc64/include/arch.h

    re662a5f r96e0748d  
    4646#define NWINDOWS                8       /** Number of register window sets. */
    4747
     48#ifndef __ASM__
     49
     50extern void arch_pre_main(void);
     51
     52#endif /* __ASM__ */
     53
    4854#endif
    4955
  • kernel/generic/include/arch.h

    re662a5f r96e0748d  
    6464} the_t;
    6565
    66 #define THE             ((the_t *)(get_stack_base()))
     66#define THE  ((the_t * )(get_stack_base()))
    6767
    6868extern void the_initialize(the_t *the);
    6969extern void the_copy(the_t *src, the_t *dst);
    7070
    71 extern void arch_pre_main(void);
    7271extern void arch_pre_mm_init(void);
    7372extern void arch_post_mm_init(void);
Note: See TracChangeset for help on using the changeset viewer.