Changeset 4872160 in mainline for boot/arch/arm32


Ignore:
Timestamp:
2010-05-04T10:44:55Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
568db0f
Parents:
bb252ca
Message:

new boot infrastructure

  • more code and metadata unification
  • import of up-to-date implementations from the kernel
  • the boot loaders should behave more similarly on all platforms
  • support for deflate compressed (LZ77) boot components
    • this again allows feasible boot images to be created on mips32
  • IA64 is still not booting
    • the broken forked GNU EFI library has been removed, a replacement of the functionality is on its way
Location:
boot/arch/arm32
Files:
3 added
8 deleted
1 edited
7 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29BFD_NAME = elf32-littlearm
     30BFD_OUTPUT = $(BFD_NAME)
     31BFD_ARCH = arm
    3032
    31 build: $(BASE)/image.boot
     33BITS = 32
     34ENDIANESS = LE
     35PAGE_SIZE = 4096
    3236
    33 $(BASE)/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    34         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    35         cp arch/$(BARCH)/loader/image.boot $@
     37RD_SRVS += \
     38        $(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd
    3639
    37 clean:
    38         $(MAKE) -C arch/$(BARCH)/loader clean
    39         rm -f $(BASE)/image.boot
     40SOURCES = \
     41        arch/$(BARCH)/src/asm.S \
     42        arch/$(BARCH)/src/main.c \
     43        arch/$(BARCH)/src/mm.c \
     44        arch/$(BARCH)/src/putchar.c \
     45        $(COMPS_C) \
     46        genarch/src/division.c \
     47        generic/src/printf_core.c \
     48        generic/src/vprintf.c \
     49        generic/src/printf.c \
     50        generic/src/str.c \
     51        generic/src/version.c \
     52        generic/src/inflate.c
  • boot/arch/arm32/include/arch.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_ia64_TYPES_H_
    30 #define BOOT_ia64_TYPES_H_
     29#ifndef BOOT_arm32_ARCH_H
     30#define BOOT_arm32_ARCH_H
    3131
    32 #include <gentypes.h>
     32#define PAGE_WIDTH  12
     33#define PAGE_SIZE   (1 << PAGE_WIDTH)
    3334
    34 typedef signed char int8_t;
     35#define PTL0_ENTRIES     4096
     36#define PTL0_ENTRY_SIZE  4
    3537
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long uint64_t;
     38#define BOOT_OFFSET  0x800000
    4039
    41 typedef uint64_t uintptr_t;
    42 typedef uint64_t unative_t;
     40#ifndef __ASM__
     41        #define PA2KA(addr)  (((uintptr_t) (addr)) + 0x80000000)
     42#else
     43        #define PA2KA(addr)  ((addr) + 0x80000000)
     44#endif
    4345
    4446#endif
     47
     48/** @}
     49 */
  • boot/arch/arm32/include/asm.h

    rbb252ca r4872160  
    2727 */
    2828
    29 
    3029/** @addtogroup arm32boot
    3130 * @{
    3231 */
    3332/** @file
    34  *  @brief Functions implemented in assembly.
     33 * @brief Functions implemented in assembly.
    3534 */
    36 
    3735
    3836#ifndef BOOT_arm32_ASM_H
    3937#define BOOT_arm32_ASM_H
    4038
     39#include <arch/arch.h>
     40#include <arch/mm.h>
    4141
    42 /** Called when the CPU is switched on.
     42extern pte_level0_section_t boot_pt[PTL0_ENTRIES];
     43extern void *boot_stack;
     44
     45/** Jump to the kernel entry point.
    4346 *
    44  *  This function is placed to the 0x0 address where ARM CPU starts execution.
    45  *  Jumps to the #bootstrap only.
    46  */
    47 extern void start(void);
    48 
    49 
    50 /** Jumps to the kernel entry point.
    51  *
    52  * @param entry    Kernel entry point address.
     47 * @param entry    Kernel entry point.
    5348 * @param bootinfo Structure holding information about loaded tasks.
    5449 *
    5550 */
    56 extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
    57 
     51extern void jump_to_kernel(void *entry, void *bootinfo)
     52    __attribute__((noreturn));
    5853
    5954#endif
  • boot/arch/arm32/include/main.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2007 Michal Kebrt
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 
    3029/** @addtogroup arm32boot
    3130 * @{
    3231 */
    33 /** @file 
    34  *  @brief Definitions of basic types like #uintptr_t.
    35  */ 
     32/** @file
     33 * @brief Boot related declarations.
     34 */
    3635
     36#ifndef BOOT_arm32_MAIN_H
     37#define BOOT_arm32_MAIN_H
    3738
    38 #ifndef BOOT_arm32_TYPES_H
    39 #define BOOT_arm32_TYPES_H
     39/** Address where characters to be printed are expected. */
     40#ifdef MACHINE_testarm
     41        #define VIDEORAM_ADDRESS  0x10000000
     42#endif
    4043
     44#ifdef MACHINE_integratorcp
     45        #define VIDEORAM_ADDRESS  0x16000000
     46#endif
    4147
    42 #include <gentypes.h>
    43 
    44 typedef signed char int8_t;
    45 
    46 typedef unsigned char uint8_t;
    47 typedef unsigned short uint16_t;
    48 typedef unsigned int uint32_t;
    49 typedef unsigned long long uint64_t;
    50 
    51 typedef uint32_t uintptr_t;
    52 typedef uint32_t unative_t;
    53 
     48extern void bootstrap(void);
    5449
    5550#endif
    5651
    57 
    5852/** @}
    5953 */
  • boot/arch/arm32/include/mm.h

    rbb252ca r4872160  
    11/*
     2 * Copyright (c) 2007 Pavel Jancik
    23 * Copyright (c) 2007 Michal Kebrt
    34 * All rights reserved.
     
    2728 */
    2829
    29 
    3030/** @addtogroup arm32boot
    3131 * @{
    3232 */
    3333/** @file
    34  *  @brief Boot related declarations.
     34 * @brief Memory management used while booting the kernel.
     35 *
     36 * So called "section" paging is used while booting the kernel. The term
     37 * "section" comes from the ARM architecture specification and stands for the
     38 * following: one-level paging, 1MB sized pages, 4096 entries in the page
     39 * table.
    3540 */
    3641
     42#ifndef BOOT_arm32__MM_H
     43#define BOOT_arm32__MM_H
    3744
    38 #ifndef BOOT_arm32_MAIN_H
    39 #define BOOT_arm32_MAIN_H
     45#include <typedefs.h>
    4046
     47/** Describe "section" page table entry (one-level paging with 1 MB sized pages). */
     48#define PTE_DESCRIPTOR_SECTION  0x02
    4149
    42 /** Maximum number of tasks in the #bootinfo_t struct. */
    43 #define TASKMAP_MAX_RECORDS 32
     50/** Page table access rights: user - no access, kernel - read/write. */
     51#define PTE_AP_USER_NO_KERNEL_RW  0x01
    4452
    45 /** Size of buffer for storing task name in task_t. */
    46 #define BOOTINFO_TASK_NAME_BUFLEN 32
     53/* Page table level 0 entry - "section" format is used
     54 * (one-level paging, 1 MB sized pages). Used only while booting the kernel.
     55 */
     56typedef struct {
     57        unsigned int descriptor_type : 2;
     58        unsigned int bufferable : 1;
     59        unsigned int cacheable : 1;
     60        unsigned int impl_specific : 1;
     61        unsigned int domain : 4;
     62        unsigned int should_be_zero_1 : 1;
     63        unsigned int access_permission : 2;
     64        unsigned int should_be_zero_2 : 8;
     65        unsigned int section_base_addr : 12;
     66} __attribute__((packed)) pte_level0_section_t;
    4767
    48 
    49 /** Struct holding information about single loaded task. */
    50 typedef struct {
    51         /** Address where the task was placed. */
    52         void *addr;
    53         /** Size of the task's binary. */
    54         unsigned int size;
    55         /** Task name. */
    56         char name[BOOTINFO_TASK_NAME_BUFLEN];
    57 } task_t;
    58 
    59 
    60 /** Struct holding information about loaded tasks. */
    61 typedef struct {
    62         /** Number of loaded tasks. */
    63         unsigned int cnt;
    64         /** Array of loaded tasks. */
    65         task_t tasks[TASKMAP_MAX_RECORDS];
    66 } bootinfo_t;
    67 
    68 
    69 extern void bootstrap(void);
     68extern void mmu_start(void);
    7069
    7170#endif
  • boot/arch/arm32/include/types.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2005 Martin Decky
     2 * Copyright (c) 2006 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_ppc32_MAIN_H_
    30 #define BOOT_ppc32_MAIN_H_
     29/** @addtogroup arm32boot
     30 * @{
     31 */
     32/** @file
     33 * @brief Definitions of basic types like #uintptr_t.
     34 */
    3135
    32 #include <ofw.h>
    33 #include <ofw_tree.h>
    34 #include <balloc.h>
    35 #include <types.h>
     36#ifndef BOOT_arm32_TYPES_H
     37#define BOOT_arm32_TYPES_H
    3638
    37 #define TASKMAP_MAX_RECORDS  32
    38 
    39 /** Size of buffer for storing task name in task_t. */
     39#define TASKMAP_MAX_RECORDS        32
    4040#define BOOTINFO_TASK_NAME_BUFLEN  32
    4141
     42typedef uint32_t size_t;
     43typedef uint32_t uintptr_t;
     44
     45typedef uint32_t pfn_t;
     46
    4247typedef struct {
     48        /** Address where the task was placed. */
    4349        void *addr;
    44         uint32_t size;
     50        /** Size of the task's binary. */
     51        size_t size;
     52        /** Task name. */
    4553        char name[BOOTINFO_TASK_NAME_BUFLEN];
    4654} task_t;
    4755
    4856typedef struct {
    49         uint32_t count;
     57        size_t cnt;
    5058        task_t tasks[TASKMAP_MAX_RECORDS];
    51 } taskmap_t;
    52 
    53 typedef struct {
    54         memmap_t memmap;
    55         taskmap_t taskmap;
    56         ballocs_t ballocs;
    57         ofw_tree_node_t *ofw_root;
    5859} bootinfo_t;
    5960
    60 extern void start(void);
    61 extern void bootstrap(void);
     61#endif
    6262
    63 #endif
     63/** @}
     64 */
  • boot/arch/arm32/src/asm.S

    rbb252ca r4872160  
    2727#
    2828
    29 
    30 #include "mm.h"
     29#include <arch/arch.h>
    3130
    3231.section BOOTSTRAP
    3332
    3433.global start
     34.global boot_pt
     35.global boot_stack
     36.global halt
     37.global memcpy
    3538.global jump_to_kernel
    36 .global page_table
    37 .global boot_stack
    3839
    3940start:
    4041        ldr sp, =boot_stack
    4142        b bootstrap
     43
     44.section BOOTPT
     45boot_pt:
     46        .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
     47
     48.section BOOTSTACK
     49        .space 4096
     50boot_stack:
     51
     52.text
     53
     54halt:
     55        b halt
     56
     57memcpy:
     58        add r3, r1, #3
     59        bic r3, r3, #3
     60        cmp r1, r3
     61        stmdb sp!, {r4, r5, lr}
     62        mov r5, r0
     63        beq 4f
     64       
     65        1:
     66                cmp r2, #0
     67                movne ip, #0
     68                beq 3f
     69       
     70        2:
     71                ldrb r3, [ip, r1]
     72                strb r3, [ip, r0]
     73                add ip, ip, #1
     74                cmp ip, r2
     75                bne 2b
     76       
     77        3:
     78                mov r0, r5
     79                ldmia sp!, {r4, r5, pc}
     80       
     81        4:
     82                add r3, r0, #3
     83                bic r3, r3, #3
     84                cmp r0, r3
     85                bne 1b
     86                movs r4, r2, lsr #2
     87                moveq lr, r4
     88                beq 6f
     89                mov lr, #0
     90                mov ip, lr
     91       
     92        5:
     93                ldr r3, [ip, r1]
     94                add lr, lr, #1
     95                cmp lr, r4
     96                str r3, [ip, r0]
     97                add ip, ip, #4
     98                bne 5b
     99       
     100        6:
     101                ands r4, r2, #3
     102                beq 3b
     103                mov r3, lr, lsl #2
     104                add r0, r3, r0
     105                add ip, r3, r1
     106                mov r2, #0
     107       
     108        7:
     109                ldrb r3, [r2, ip]
     110                strb r3, [r2, r0]
     111                add r2, r2, #1
     112                cmp r2, r4
     113                bne 7b
     114                b 3b
    42115
    43116jump_to_kernel:
     
    48121        #
    49122        bx r0
    50 
    51 #bootloader stack
    52 .section ST
    53         .space 4096
    54 boot_stack:
    55 
    56 # place page_table to PT section
    57 .section PT
    58 
    59 # make place for PTL0 page table
    60 page_table:
    61         .skip PTL0_ENTRIES * PTL0_ENTRY_SIZE
  • boot/arch/arm32/src/putchar.c

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2007 Michal Kebrt
     3 * Copyright (c) 2009 Vineeth Pillai
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup generic
     30/** @addtogroup arm32boot
    3031 * @{
    3132 */
    3233/** @file
     34 * @brief bootloader output logic
    3335 */
    3436
    35 #ifndef BOOT_STRING_H_
    36 #define BOOT_STRING_H_
     37#include <typedefs.h>
     38#include <arch/main.h>
     39#include <putchar.h>
     40#include <str.h>
    3741
    38 #include <types.h>
    39 
    40 extern size_t strlen(const char *str);
    41 extern int strcmp(const char *src, const char *dst);
    42 extern int strncmp(const char *src, const char *dst, size_t len);
    43 extern void strncpy(char *dest, const char *src, size_t len);
    44 extern unative_t atoi(const char *text);
    45 extern void *memmove(void *dst, const void *src, size_t len);
    46 
    47 #endif
     42void putchar(const wchar_t ch)
     43{
     44        if (ch == '\n')
     45                *((volatile char *) VIDEORAM_ADDRESS) = '\r';
     46       
     47        if (ascii_check(ch))
     48                *((volatile char *) VIDEORAM_ADDRESS) = ch;
     49        else
     50                *((volatile char *) VIDEORAM_ADDRESS) = U_SPECIAL;
     51}
    4852
    4953/** @}
Note: See TracChangeset for help on using the changeset viewer.