Changeset 6b781c0 in mainline for kernel/arch/arm32/src
- Timestamp:
- 2007-06-08T15:02:49Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c03ee1c
- Parents:
- 3ee8a075
- Location:
- kernel/arch/arm32/src
- Files:
-
- 11 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/arm32.c
r3ee8a075 r6b781c0 1 1 /* 2 * Copyright (c) 200 3-2004 Jakub Jermar2 * Copyright (c) 2007 Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief ARM32 architecture specific functions. 33 34 */ 34 35 36 #include <arch.h> 37 #include <arch/boot.h> 38 #include <config.h> 39 #include <arch/console.h> 40 #include <ddi/device.h> 41 #include <genarch/fb/fb.h> 42 #include <genarch/fb/visuals.h> 43 #include <ddi/irq.h> 44 #include <arch/debug/print.h> 45 #include <print.h> 46 #include <config.h> 47 #include <interrupt.h> 48 #include <arch/regutils.h> 49 #include <arch/machine.h> 50 #include <userspace.h> 35 51 36 #include <arch.h> 52 /** Information about loaded tasks. */ 53 bootinfo_t bootinfo; 37 54 55 /** Performs arm32 specific initialization before main_bsp() is called. */ 38 56 void arch_pre_main(void) 39 57 { 40 /* TODO */ 58 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; 65 } 66 41 67 } 42 68 69 /** Performs arm32 specific initialization before mm is initialized. */ 43 70 void arch_pre_mm_init(void) 44 71 { 45 /* TODO */ 72 /* It is not assumed by default */ 73 interrupts_disable(); 46 74 } 47 75 76 /** Performs arm32 specific initialization afterr mm is initialized. */ 48 77 void arch_post_mm_init(void) 49 78 { 50 /* TODO */ 79 machine_hw_map_init(); 80 81 /* Initialize exception dispatch table */ 82 exception_init(); 83 84 interrupt_init(); 85 86 console_init(device_assign_devno()); 87 88 #ifdef CONFIG_FB 89 fb_init(machine_get_fb_address(), 640, 480, 1920, VISUAL_RGB_8_8_8); 90 #endif 51 91 } 52 92 93 /** Performs arm32 specific tasks needed after cpu is initialized. 94 * 95 * Currently the function is empty. 96 */ 53 97 void arch_post_cpu_init(void) 54 98 { 55 /* TODO */56 99 } 57 100 101 102 /** Performs arm32 specific tasks needed before the multiprocessing is 103 * initialized. 104 * 105 * Currently the function is empty because SMP is not supported. 106 */ 58 107 void arch_pre_smp_init(void) 59 108 { 60 /* TODO */61 109 } 62 110 111 112 /** Performs arm32 specific tasks needed after the multiprocessing is 113 * initialized. 114 * 115 * Currently the function is empty because SMP is not supported. 116 */ 63 117 void arch_post_smp_init(void) 64 118 { 65 /* TODO */66 119 } 67 120 68 /** Perform arm32 specific tasks needed before the new task is run. */ 121 122 /** Performs arm32 specific tasks needed before the new task is run. */ 69 123 void before_task_runs_arch(void) 70 124 { 71 /* TODO */125 tlb_invalidate_all(); 72 126 } 73 127 74 /** Perform arm32 specific tasks needed before the new thread is scheduled. */ 128 129 /** Performs arm32 specific tasks needed before the new thread is scheduled. 130 * 131 * It sets supervisor_sp. 132 */ 75 133 void before_thread_runs_arch(void) 76 134 { 77 /* TODO */ 135 uint8_t *stck; 136 137 stck = &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA]; 138 supervisor_sp = (uintptr_t) stck; 78 139 } 79 140 141 /** Performs arm32 specific tasks before a thread stops running. 142 * 143 * Currently the function is empty. 144 */ 80 145 void after_thread_ran_arch(void) 81 146 { 82 /* TODO */83 147 } 84 148 85 void arch_reboot(void) 149 /** Halts CPU. */ 150 void cpu_halt(void) 86 151 { 87 // TODO 88 while (1); 152 machine_cpu_halt(); 153 } 154 155 /** Reboot. */ 156 void arch_reboot() 157 { 158 /* not implemented */ 159 for (;;) 160 ; 89 161 } 90 162 -
kernel/arch/arm32/src/context.S
r3ee8a075 r6b781c0 1 1 # 2 # Copyright (c) 200 3-2004 Jakub Jermar2 # Copyright (c) 2007 Petr Stepan 3 3 # All rights reserved. 4 4 # … … 33 33 34 34 context_save_arch: 35 /* TODO */ 35 stmfd sp!, {r1} 36 mrs r1, cpsr 37 and r1, r1, #0x1f 38 stmia r0!, {r1} 39 ldmfd sp!, {r1} 40 41 stmia r0!, {sp, lr} 42 stmia r0!, {r4-r11} 43 44 mov r0, #1 45 mov pc, lr 46 47 48 context_restore_arch: 49 ldmia r0!, {r4} 50 mrs r5, cpsr 51 bic r5, r5, #0x1f 52 orr r5, r5, r4 53 msr cpsr_c, r5 54 55 ldmia r0!, {sp, lr} 56 ldmia r0!, {r4-r11} 36 57 37 context_restore_arch: 38 /* TODO */58 mov r0, #0 59 mov pc, lr -
kernel/arch/arm32/src/cpu/cpu.c
r3ee8a075 r6b781c0 1 1 /* 2 * Copyright (c) 200 3-2004 Jakub Jermar2 * Copyright (c) 2007 Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief CPU identification. 33 34 */ 34 35 36 #include <arch/cpu.h> 35 37 #include <cpu.h> 38 #include <arch.h> 36 39 #include <print.h> 37 40 41 /** Number of indexes left out in the #imp_data array */ 42 #define IMP_DATA_START_OFFSET 0x40 43 44 /** Implementators (vendor) names */ 45 static char *imp_data[] = { 46 "?", /* IMP_DATA_START_OFFSET */ 47 "ARM Ltd", /* 0x41 */ 48 "", /* 0x42 */ 49 "", /* 0x43 */ 50 "Digital Equipment Corporation", /* 0x44 */ 51 "", "", "", "", "", "", "", "", "", "", /* 0x45 - 0x4e */ 52 "", "", "", "", "", "", "", "", "", "", /* 0x4f - 0x58 */ 53 "", "", "", "", "", "", "", "", "", "", /* 0x59 - 0x62 */ 54 "", "", "", "", "", "", /* 0x63 - 0x68 */ 55 "Intel Corporation" /* 0x69 */ 56 }; 57 58 /** Length of the #imp_data array */ 59 static int imp_data_length = sizeof(imp_data) / sizeof(char *); 60 61 /** Architecture names */ 62 static char *arch_data[] = { 63 "?", /* 0x0 */ 64 "4", /* 0x1 */ 65 "4T", /* 0x2 */ 66 "5", /* 0x3 */ 67 "5T", /* 0x4 */ 68 "5TE", /* 0x5 */ 69 "5TEJ", /* 0x6 */ 70 "6" /* 0x7 */ 71 }; 72 73 /** Length of the #arch_data array */ 74 static int arch_data_length = sizeof(arch_data) / sizeof(char *); 75 76 77 /** Retrieves processor identification from CP15 register 0. 78 * 79 * @param cpu Structure for storing CPU identification. 80 */ 81 static void arch_cpu_identify(cpu_arch_t *cpu) 82 { 83 uint32_t ident; 84 asm volatile ( 85 "mrc p15, 0, %0, c0, c0, 0\n" 86 : "=r" (ident) 87 ); 88 89 cpu->imp_num = ident >> 24; 90 cpu->variant_num = (ident << 8) >> 28; 91 cpu->arch_num = (ident << 12) >> 28; 92 cpu->prim_part_num = (ident << 16) >> 20; 93 cpu->rev_num = (ident << 28) >> 28; 94 } 95 96 /** Does nothing on ARM. */ 38 97 void cpu_arch_init(void) 39 98 { 40 99 } 41 100 42 void cpu_identify(void) 101 /** Retrieves processor identification and stores it to #CPU.arch */ 102 void cpu_identify(void) 43 103 { 44 /* TODO */104 arch_cpu_identify(&CPU->arch); 45 105 } 46 106 107 /** Prints CPU identification. */ 47 108 void cpu_print_report(cpu_t *m) 48 109 { 49 /* TODO */ 110 char * vendor = imp_data[0]; 111 char * architecture = arch_data[0]; 112 cpu_arch_t * cpu_arch = &m->arch; 113 114 if ((cpu_arch->imp_num) > 0 && 115 (cpu_arch->imp_num < (imp_data_length + IMP_DATA_START_OFFSET))) { 116 vendor = imp_data[cpu_arch->imp_num - IMP_DATA_START_OFFSET]; 117 } 118 119 if ((cpu_arch->arch_num) > 0 && 120 (cpu_arch->arch_num < arch_data_length)) { 121 architecture = arch_data[cpu_arch->arch_num]; 122 } 123 124 printf("cpu%d: vendor=%s, architecture=ARM%s, part number=%x, " 125 "variant=%x, revision=%x\n", 126 m->id, vendor, architecture, cpu_arch->prim_part_num, 127 cpu_arch->variant_num, cpu_arch->rev_num); 50 128 } 51 129 -
kernel/arch/arm32/src/ddi/ddi.c
r3ee8a075 r6b781c0 31 31 */ 32 32 /** @file 33 * @brief DDI. 33 34 */ 34 35 -
kernel/arch/arm32/src/dummy.S
r3ee8a075 r6b781c0 1 1 # 2 # Copyright (c) 200 3-2004 Jakub Jermar2 # Copyright (c) 2007 Michal Kebry, Pavel Jancik, Petr Stepan 3 3 # All rights reserved. 4 4 # … … 31 31 .global calibrate_delay_loop 32 32 .global asm_delay_loop 33 .global dummy 34 .global arch_grab_console 35 .global arch_release_console 36 .global cpu_halt 33 37 34 .global fpu_context_restore 38 35 .global fpu_context_save 39 36 .global fpu_enable 40 37 .global fpu_init 41 .global interrupts_disable 42 .global interrupts_enable 43 .global interrupts_read 44 .global interrupts_restore 45 .global memcpy 46 .global memcpy_from_uspace 47 .global memcpy_to_uspace 48 .global memsetb 49 .global panic_printf 50 .global symbol_table 38 51 39 .global sys_tls_set 52 .global tlb_invalidate_asid 53 .global tlb_invalidate_pages 54 .global userspace 55 40 .global dummy 41 56 42 calibrate_delay_loop: 43 mov pc, lr 44 57 45 asm_delay_loop: 46 mov pc, lr 58 47 59 arch_grab_console:60 arch_release_console:61 cpu_halt:62 48 fpu_context_restore: 49 mov pc, lr 50 63 51 fpu_context_save: 52 mov pc, lr 53 64 54 fpu_enable: 55 mov pc, lr 56 65 57 fpu_init: 66 interrupts_disable: 67 interrupts_enable: 68 interrupts_read: 69 interrupts_restore: 70 memcpy: 71 memcpy_from_uspace: 72 memcpy_to_uspace: 73 memsetb: 74 panic_printf: 75 symbol_table: 58 mov pc, lr 59 60 # not used on ARM 76 61 sys_tls_set: 77 tlb_invalidate_asid:78 tlb_invalidate_pages:79 userspace:80 62 81 63 dummy: 82 83 0: 84 b 0b 64 mov pc, lr -
kernel/arch/arm32/src/mm/as.c
r3ee8a075 r6b781c0 1 1 /* 2 * Copyright (c) 200 5 Jakub Jermar2 * Copyright (c) 2007 Pavel Jancik, Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief Address space functions. 33 34 */ 34 35 … … 39 40 #include <arch.h> 40 41 41 /** Architecture dependent address space init. */ 42 /** Architecture dependent address space init. 43 * 44 * Since ARM supports page tables, #as_pt_operations are used. 45 */ 42 46 void as_arch_init(void) 43 47 { 44 as_operations = &as_pt_operations; 45 asid_fifo_init(); 46 } 47 48 /** Install address space. 49 * 50 * Install ASID. 51 * 52 * @param as Address space structure. 53 */ 54 void as_install_arch(as_t *as) 55 { 56 /* TODO */ 48 as_operations = &as_pt_operations; 57 49 } 58 50 -
kernel/arch/arm32/src/mm/frame.c
r3ee8a075 r6b781c0 1 1 /* 2 * Copyright (c) 200 5 Jakub Jermar2 * Copyright (c) 2007 Pavel Jancik, Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief Frame related functions. 33 34 */ 34 35 35 36 #include <mm/frame.h> 37 #include <arch/mm/frame.h> 38 #include <config.h> 39 #include <arch/debug/print.h> 36 40 37 /** Create memory zones. */ 41 /** Address of the last frame in the memory. */ 42 uintptr_t last_frame = 0; 43 44 /** Creates memory zones. */ 38 45 void frame_arch_init(void) 39 46 { 40 /* TODO */ 47 /* all memory as one zone */ 48 zone_create(0, ADDR2PFN(config.memory_size), 49 BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); 50 last_frame = config.memory_size; 51 52 /* blacklist boot page table */ 53 frame_mark_unavailable(BOOT_PAGE_TABLE_START_FRAME, 54 BOOT_PAGE_TABLE_SIZE_IN_FRAMES); 55 } 56 57 /** Frees the boot page table. */ 58 void boot_page_table_free(void) 59 { 60 int i; 61 for (i = 0; i < BOOT_PAGE_TABLE_SIZE_IN_FRAMES; i++) { 62 frame_free(i * FRAME_SIZE + BOOT_PAGE_TABLE_ADDRESS); 63 } 41 64 } 42 65 -
kernel/arch/arm32/src/mm/page.c
r3ee8a075 r6b781c0 1 1 /* 2 * Copyright (c) 200 3-2004 Jakub Jermar2 * Copyright (c) 2007 Pavel Jancik, Michal Kebrt 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief Paging related functions. 33 34 */ 34 35 … … 36 37 #include <genarch/mm/page_pt.h> 37 38 #include <mm/page.h> 39 #include <align.h> 40 #include <config.h> 41 #include <arch/exception.h> 42 #include <typedefs.h> 43 #include <arch/types.h> 44 #include <interrupt.h> 45 #include <arch/mm/frame.h> 38 46 47 /** Initializes page tables. 48 * 49 * 1:1 virtual-physical mapping is created in kernel address space. Mapping 50 * for table with exception vectors is also created. 51 */ 39 52 void page_arch_init(void) 40 53 { 54 uintptr_t cur; 55 int flags; 56 41 57 page_mapping_operations = &pt_mapping_operations; 58 59 flags = PAGE_CACHEABLE; 60 61 /* PA2KA(identity) mapping for all frames until last_frame */ 62 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { 63 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 64 } 65 66 /* create mapping for exception table at high offset */ 67 #ifdef HIGH_EXCEPTION_VECTORS 68 void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); 69 page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags); 70 #else 71 #error "Only high exception vector supported now" 72 #endif 73 74 as_switch(NULL, AS_KERNEL); 75 76 boot_page_table_free(); 42 77 } 43 78 44 /** Map device into kernel space. */ 79 /** Maps device into the kernel space. 80 * 81 * Maps physical address of device into kernel virtual address space (so it can 82 * be accessed only by kernel through virtual address). 83 * 84 * @param physaddr Physical address where device is connected. 85 * @param size Length of area where device is present. 86 * 87 * @return Virtual address where device will be accessible. 88 */ 45 89 uintptr_t hw_map(uintptr_t physaddr, size_t size) 46 90 { 47 /* TODO */ 48 return NULL; 91 if (last_frame + ALIGN_UP(size, PAGE_SIZE) > 92 KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { 93 panic("Unable to map physical memory %p (%d bytes)", 94 physaddr, size) 95 } 96 97 uintptr_t virtaddr = PA2KA(last_frame); 98 pfn_t i; 99 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { 100 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), 101 physaddr + PFN2ADDR(i), 102 PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); 103 } 104 105 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); 106 return virtaddr; 49 107 } 50 108 -
kernel/arch/arm32/src/start.S
r3ee8a075 r6b781c0 1 1 # 2 # Copyright (c) 200 3-2007 Jakub Jermar2 # Copyright (c) 2007 Michal Kebrt 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 #include <arch/asm/boot.h> 30 31 .text 32 29 33 .global kernel_image_start 34 .global exc_stack 35 .global supervisor_sp 36 30 37 kernel_image_start: 38 39 # switch to supervisor mode 40 mrs r3, cpsr 41 bic r3, r3, #0x1f 42 orr r3, r3, #0x13 43 msr cpsr_c, r3 44 45 ldr sp, =temp_stack 31 46 32 /* TODO */ 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 33 62 34 0: 35 b 0b 63 bootinfo_end: 64 65 bl arch_pre_main 66 67 bl main_bsp 68 69 .space TEMP_STACK_SIZE 70 temp_stack: 71 72 .space 1024 73 exc_stack: 74 75 supervisor_sp: 76 .space 4 77
Note:
See TracChangeset
for help on using the changeset viewer.