Changeset 4872160 in mainline for boot/arch/arm32
- Timestamp:
- 2010-05-04T10:44:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 568db0f
- Parents:
- bb252ca
- Location:
- boot/arch/arm32
- Files:
-
- 3 added
- 8 deleted
- 1 edited
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/arm32/Makefile.inc
rbb252ca r4872160 27 27 # 28 28 29 include Makefile.common 29 BFD_NAME = elf32-littlearm 30 BFD_OUTPUT = $(BFD_NAME) 31 BFD_ARCH = arm 30 32 31 build: $(BASE)/image.boot 33 BITS = 32 34 ENDIANESS = LE 35 PAGE_SIZE = 4096 32 36 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 $@ 37 RD_SRVS += \ 38 $(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd 36 39 37 clean: 38 $(MAKE) -C arch/$(BARCH)/loader clean 39 rm -f $(BASE)/image.boot 40 SOURCES = \ 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 1 1 /* 2 * Copyright (c) 20 06Martin Decky2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_ ia64_TYPES_H_30 #define BOOT_ ia64_TYPES_H_29 #ifndef BOOT_arm32_ARCH_H 30 #define BOOT_arm32_ARCH_H 31 31 32 #include <gentypes.h> 32 #define PAGE_WIDTH 12 33 #define PAGE_SIZE (1 << PAGE_WIDTH) 33 34 34 typedef signed char int8_t; 35 #define PTL0_ENTRIES 4096 36 #define PTL0_ENTRY_SIZE 4 35 37 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 40 39 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 43 45 44 46 #endif 47 48 /** @} 49 */ -
boot/arch/arm32/include/asm.h
rbb252ca r4872160 27 27 */ 28 28 29 30 29 /** @addtogroup arm32boot 31 30 * @{ 32 31 */ 33 32 /** @file 34 * 33 * @brief Functions implemented in assembly. 35 34 */ 36 37 35 38 36 #ifndef BOOT_arm32_ASM_H 39 37 #define BOOT_arm32_ASM_H 40 38 39 #include <arch/arch.h> 40 #include <arch/mm.h> 41 41 42 /** Called when the CPU is switched on. 42 extern pte_level0_section_t boot_pt[PTL0_ENTRIES]; 43 extern void *boot_stack; 44 45 /** Jump to the kernel entry point. 43 46 * 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. 53 48 * @param bootinfo Structure holding information about loaded tasks. 54 49 * 55 50 */ 56 extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));57 51 extern void jump_to_kernel(void *entry, void *bootinfo) 52 __attribute__((noreturn)); 58 53 59 54 #endif -
boot/arch/arm32/include/main.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 6 Martin Decky2 * Copyright (c) 2007 Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 30 29 /** @addtogroup arm32boot 31 30 * @{ 32 31 */ 33 /** @file 34 * @brief Definitions of basic types like #uintptr_t.35 */ 32 /** @file 33 * @brief Boot related declarations. 34 */ 36 35 36 #ifndef BOOT_arm32_MAIN_H 37 #define BOOT_arm32_MAIN_H 37 38 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 40 43 44 #ifdef MACHINE_integratorcp 45 #define VIDEORAM_ADDRESS 0x16000000 46 #endif 41 47 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 48 extern void bootstrap(void); 54 49 55 50 #endif 56 51 57 58 52 /** @} 59 53 */ -
boot/arch/arm32/include/mm.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 2007 Pavel Jancik 2 3 * Copyright (c) 2007 Michal Kebrt 3 4 * All rights reserved. … … 27 28 */ 28 29 29 30 30 /** @addtogroup arm32boot 31 31 * @{ 32 32 */ 33 33 /** @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. 35 40 */ 36 41 42 #ifndef BOOT_arm32__MM_H 43 #define BOOT_arm32__MM_H 37 44 38 #ifndef BOOT_arm32_MAIN_H 39 #define BOOT_arm32_MAIN_H 45 #include <typedefs.h> 40 46 47 /** Describe "section" page table entry (one-level paging with 1 MB sized pages). */ 48 #define PTE_DESCRIPTOR_SECTION 0x02 41 49 42 /** Maximum number of tasks in the #bootinfo_t struct. */43 #define TASKMAP_MAX_RECORDS 3250 /** Page table access rights: user - no access, kernel - read/write. */ 51 #define PTE_AP_USER_NO_KERNEL_RW 0x01 44 52 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 */ 56 typedef 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; 47 67 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); 68 extern void mmu_start(void); 70 69 71 70 #endif -
boot/arch/arm32/include/types.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 5Martin Decky2 * Copyright (c) 2006 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 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 */ 31 35 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 36 38 37 #define TASKMAP_MAX_RECORDS 32 38 39 /** Size of buffer for storing task name in task_t. */ 39 #define TASKMAP_MAX_RECORDS 32 40 40 #define BOOTINFO_TASK_NAME_BUFLEN 32 41 41 42 typedef uint32_t size_t; 43 typedef uint32_t uintptr_t; 44 45 typedef uint32_t pfn_t; 46 42 47 typedef struct { 48 /** Address where the task was placed. */ 43 49 void *addr; 44 uint32_t size; 50 /** Size of the task's binary. */ 51 size_t size; 52 /** Task name. */ 45 53 char name[BOOTINFO_TASK_NAME_BUFLEN]; 46 54 } task_t; 47 55 48 56 typedef struct { 49 uint32_t count;57 size_t cnt; 50 58 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;58 59 } bootinfo_t; 59 60 60 extern void start(void); 61 extern void bootstrap(void); 61 #endif 62 62 63 #endif 63 /** @} 64 */ -
boot/arch/arm32/src/asm.S
rbb252ca r4872160 27 27 # 28 28 29 30 #include "mm.h" 29 #include <arch/arch.h> 31 30 32 31 .section BOOTSTRAP 33 32 34 33 .global start 34 .global boot_pt 35 .global boot_stack 36 .global halt 37 .global memcpy 35 38 .global jump_to_kernel 36 .global page_table37 .global boot_stack38 39 39 40 start: 40 41 ldr sp, =boot_stack 41 42 b bootstrap 43 44 .section BOOTPT 45 boot_pt: 46 .space PTL0_ENTRIES * PTL0_ENTRY_SIZE 47 48 .section BOOTSTACK 49 .space 4096 50 boot_stack: 51 52 .text 53 54 halt: 55 b halt 56 57 memcpy: 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 42 115 43 116 jump_to_kernel: … … 48 121 # 49 122 bx r0 50 51 #bootloader stack52 .section ST53 .space 409654 boot_stack:55 56 # place page_table to PT section57 .section PT58 59 # make place for PTL0 page table60 page_table:61 .skip PTL0_ENTRIES * PTL0_ENTRY_SIZE -
boot/arch/arm32/src/putchar.c
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 2001-2004 Jakub Jermar 2 * Copyright (c) 2007 Michal Kebrt 3 * Copyright (c) 2009 Vineeth Pillai 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup generic30 /** @addtogroup arm32boot 30 31 * @{ 31 32 */ 32 33 /** @file 34 * @brief bootloader output logic 33 35 */ 34 36 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> 37 41 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 42 void 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 } 48 52 49 53 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.