Changes in / [8ab339e:1935591] in mainline
- Files:
-
- 5 added
- 31 deleted
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r8ab339e r1935591 64 64 @ "gta02" GTA02 / Neo FreeRunner 65 65 @ "integratorcp" Integratorcp 66 @ "beagleboardxm" BeagleBoard-xM 67 @ "beaglebone" BeagleBone 66 @ "beagleboardxm" BeogleBoard-xM 68 67 ! [PLATFORM=arm32] MACHINE (choice) 69 68 … … 88 87 89 88 % CPU type 90 @ " cortex_a8" ARM Cortex A-891 ! [PLATFORM=arm32&(MACHINE= beagleboardxm|MACHINE=beaglebone)] PROCESSOR (choice)89 @ "armv4" ARMv4 90 ! [PLATFORM=arm32&(MACHINE=gta02)] PROCESSOR (choice) 92 91 93 92 % CPU type 94 @ "arm 920t" ARM920T95 ! [PLATFORM=arm32&MACHINE= gta02] PROCESSOR (choice)93 @ "armv5" ARMv5 94 ! [PLATFORM=arm32&MACHINE=integratorcp] PROCESSOR (choice) 96 95 97 96 % CPU type 98 @ "arm926ej_s" ARM926EJ-S99 ! [PLATFORM=arm32&MACHINE=integratorcp] PROCESSOR (choice)100 101 102 # Add more ARMv4 CPUs103 % CPU arch104 @ "armv4" ARMv4105 ! [PLATFORM=arm32&(PROCESSOR=arm920t)] PROCESSOR_ARCH (choice)106 107 # Add more ARMv5 CPUs108 % CPU arch109 @ "armv5" ARMv5110 ! [PLATFORM=arm32&(PROCESSOR=arm926ej_s)] PROCESSOR_ARCH (choice)111 112 # Add more ARMv7-A CPUs113 % CPU arch114 97 @ "armv7_a" ARMv7-A 115 ! [PLATFORM=arm32& (PROCESSOR=cortex_a8)] PROCESSOR_ARCH(choice)98 ! [PLATFORM=arm32&MACHINE=beagleboardxm] PROCESSOR (choice) 116 99 117 100 % RAM disk format … … 365 348 ## armv7 made fpu hardware compulsory 366 349 % FPU support 367 ! [PLATFORM=arm32&PROCESSOR _ARCH=armv7_a] CONFIG_FPU (y)350 ! [PLATFORM=arm32&PROCESSOR=armv7_a] CONFIG_FPU (y) 368 351 369 352 % FPU support … … 442 425 % Output device class 443 426 @ "generic" Monitor or serial line 444 ! [PLATFORM=arm32&(MACHINE=gta02|MACHINE=integratorcp|MACHINE=beagleboardxm |MACHINE=beaglebone)] CONFIG_HID_OUT (choice)427 ! [PLATFORM=arm32&(MACHINE=gta02|MACHINE=integratorcp|MACHINE=beagleboardxm)] CONFIG_HID_OUT (choice) 445 428 446 429 % Output device class … … 489 472 ! [PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_IRQC (y) 490 473 491 % Support for TI AM335x on-chip UART 492 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=beaglebone] CONFIG_AM335X_UART (y/n) 493 494 % Support for TI AM335x timers support 495 ! [PLATFORM=arm32&MACHINE=beaglebone] CONFIG_AM335X_TIMERS (y) 496 497 % Support for TI AMDM37x on-chip UART 474 % Support for TI AMDM37X on-chip UART 498 475 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=beagleboardxm] CONFIG_AMDM37X_UART (y/n) 499 476 … … 517 494 518 495 % Serial line input module 519 ! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_ARM926_UART=y)|(PLATFORM=arm32&MACHINE=beaglebo ne&CONFIG_AM335X_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_AMDM37X_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)496 ! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_ARM926_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_AMDM37X_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y) 520 497 521 498 % EGA support … … 630 607 % uImage OS type 631 608 @ "2" NetBSD stage 2 boot loader 632 ! [PLATFORM=arm32& (MACHINE=beagleboardxm|MACHINE=beaglebone)] UIMAGE_OS (choice)609 ! [PLATFORM=arm32&MACHINE=beagleboardxm] UIMAGE_OS (choice) 633 610 634 611 % uImage OS type 635 612 @ "5" Linux kernel 636 ! [PLATFORM=arm32&MACHINE!=beagleboardxm &MACHINE!=beaglebone] UIMAGE_OS (choice)613 ! [PLATFORM=arm32&MACHINE!=beagleboardxm] UIMAGE_OS (choice) -
boot/arch/arm32/Makefile.inc
r8ab339e r1935591 35 35 endif 36 36 37 ifeq ($(MACHINE), $(filter $(MACHINE),beagleboardxm beaglebone))37 ifeq ($(MACHINE), beagleboardxm) 38 38 BOOT_OUTPUT = image.boot 39 39 POST_OUTPUT = $(ROOT_PATH)/uImage.bin … … 49 49 BITS = 32 50 50 ENDIANESS = LE 51 EXTRA_CFLAGS = -march=$(subst _,-,$(PROCESSOR _ARCH)) -mno-unaligned-access51 EXTRA_CFLAGS = -march=$(subst _,-,$(PROCESSOR)) -mno-unaligned-access 52 52 53 53 ifeq ($(MACHINE), gta02) … … 59 59 RD_DRVS += \ 60 60 infrastructure/rootamdm37x \ 61 fb/amdm37x_dispc \62 61 bus/usb/ehci \ 63 62 bus/usb/ohci \ -
boot/arch/arm32/_link.ld.in
r8ab339e r1935591 11 11 . = BOOT_BASE + 0x8000; 12 12 .data : { 13 bdata_start = .;14 13 *(BOOTPT); /* bootstrap page table */ 15 14 *(BOOTSTACK); /* bootstrap stack */ … … 25 24 [[COMPONENTS]] 26 25 } 27 bdata_end = .; 28 26 29 27 /DISCARD/ : { 30 28 *(.gnu.*); -
boot/arch/arm32/include/arch.h
r8ab339e r1935591 44 44 #elif defined MACHINE_beagleboardxm 45 45 #define BOOT_BASE 0x80000000 46 #elif defined MACHINE_beaglebone47 #define BOOT_BASE 0x8000000048 46 #else 49 47 #define BOOT_BASE 0x00000000 … … 53 51 54 52 #ifdef MACHINE_beagleboardxm 55 #define PA_OFFSET 056 #elif defined MACHINE_beaglebone57 53 #define PA_OFFSET 0 58 54 #else -
boot/arch/arm32/include/main.h
r8ab339e r1935591 51 51 #define BBXM_THR_FULL 0x00000001 52 52 53 /** Beaglebone UART register addresses54 *55 * This is UART0 of AM335x CPU56 */57 #define BBONE_SCONS_THR 0x44E0900058 #define BBONE_SCONS_SSR 0x44E0904459 60 /** Check this bit before writing (tx fifo full) */61 #define BBONE_TXFIFO_FULL 0x0000000162 53 63 54 /** GTA02 serial console UART register addresses. -
boot/arch/arm32/include/mm.h
r8ab339e r1935591 58 58 #define GTA02_IOMEM_END 0x60000000 59 59 60 /** Start of ram memory on BBxM */61 #define BBXM_RAM_START 0x8000000062 /** Start of ram memory on BBxM */63 #define BBXM_RAM_END 0xc000000064 65 /** Start of ram memory on AM335x */66 #define AM335x_RAM_START 0x8000000067 /** End of ram memory on AM335x */68 #define AM335x_RAM_END 0xC000000069 70 71 60 /* Page table level 0 entry - "section" format is used 72 61 * (one-level paging, 1 MB sized pages). Used only while booting the kernel. … … 81 70 unsigned int access_permission_0 : 2; 82 71 unsigned int tex : 3; 83 unsigned int access_permission_1 : 1; 84 unsigned int shareable : 1; 72 unsigned int access_permission_1 : 2; 85 73 unsigned int non_global : 1; 86 74 unsigned int should_be_zero_2 : 1; -
boot/arch/arm32/src/asm.S
r8ab339e r1935591 61 61 # 62 62 63 # 64 # r0 is kernel entry point 65 # r1 is pointer to the bootinfo structure 63 #if defined(MACHINE_gta02) 66 64 67 65 #define CP15_C1_IC 12 68 #define CP15_C1_BP 1169 66 #define CP15_C1_DC 2 67 #define CP15_C7_SEG_SHIFT 5 68 #define CP15_C7_SEG_SIZE 3 69 #define CP15_C7_IDX_SHIFT 26 70 70 71 # Disable I-cache and D-cache before the kernel is started. 71 72 mrc p15, 0, r4, c1, c0, 0 72 73 bic r4, r4, #(1 << CP15_C1_DC) 73 74 bic r4, r4, #(1 << CP15_C1_IC) 74 bic r4, r4, #(1 << CP15_C1_BP)75 75 mcr p15, 0, r4, c1, c0, 0 76 76 77 78 #Wait for the operations to complete 79 #ifdef PROCESSOR_ARCH_armv7_a 80 dsb 81 #else 82 #cp15 dsb, r4 is ignored (should be zero) 83 mcr p15, 0, r4, c7, c10, 4 77 # Now clean D-cache to guarantee coherency between I-cache and D-cache. 78 79 # D-cache clean and invalidate procedure. 80 # See ARM920T TRM pages 2-17, 4-17. 81 82 # Initialize segment 83 mov r4, #0 84 # Initialize index 85 1: mov r5, #0 86 2: orr r6, r4, r5 87 # Clean and invalidate a single line 88 mcr p15, 0, r6, c7, c10, 2 89 # Increment index 90 add r5, r5, #(1 << CP15_C7_IDX_SHIFT) 91 cmp r5, #0 92 bne 2b 93 # Increment segment 94 add r4, #(1 << CP15_C7_SEG_SHIFT) 95 tst r4, #(1 << (CP15_C7_SEG_SHIFT + CP15_C7_SEG_SIZE)) 96 beq 1b 84 97 #endif 85 86 # Clean ICache and BPredictors, r4 ignored (SBZ)87 mcr p15, 0, r4, c7, c5, 088 nop89 98 90 #Wait for the operations to complete91 #ifdef PROCESSOR_ARCH_armv7_a92 isb93 nop94 #else95 # cp15 isb96 mcr p15, 0, r4, c7, c5, 497 nop98 #endif99 99 mov pc, r0 -
boot/arch/arm32/src/main.c
r8ab339e r1935591 50 50 #define TOP2ADDR(top) (((void *) PA2KA(BOOT_OFFSET)) + (top)) 51 51 52 extern void *bdata_start;53 extern void *bdata_end;54 55 56 static inline void invalidate_icache(void)57 {58 /* ICIALLU Invalidate entire ICache */59 asm volatile ("mov r0, #0\n" "mcr p15, 0, r0, c7, c5, 0\n" ::: "r0" );60 }61 62 static inline void invalidate_dcache(void *address, size_t size)63 {64 const uintptr_t addr = (uintptr_t)address;65 /* DCIMVAC - invalidate by address to the point of coherence */66 for (uintptr_t a = addr; a < addr + size; a += 4) {67 asm volatile ("mcr p15, 0, %[a], c7, c6, 1\n" :: [a]"r"(a) : );68 }69 }70 71 static inline void clean_dcache_poc(void *address, size_t size)72 {73 const uintptr_t addr = (uintptr_t)address;74 /* DCCMVAC - clean by address to the point of coherence */75 for (uintptr_t a = addr; a < addr + size; a += 4) {76 asm volatile ("mcr p15, 0, %[a], c7, c10, 1\n" :: [a]"r"(a) : );77 }78 }79 80 52 static bootinfo_t bootinfo; 81 53 82 54 void bootstrap(void) 83 55 { 84 /* Make sure we run in memory code when caches are enabled,85 * make sure we read memory data too. This part is ARMv7 specific as86 * ARMv7 no longer invalidates caches on restart.87 * See chapter B2.2.2 of ARM Architecture Reference Manual p. B2-1263*/88 invalidate_icache();89 invalidate_dcache(&bdata_start, &bdata_end - &bdata_start);90 91 /* Enable MMU and caches */92 56 mmu_start(); 93 57 version_print(); 94 58 95 printf("Boot data: %p -> %p\n", &bdata_start, &bdata_end);96 59 printf("\nMemory statistics\n"); 97 60 printf(" %p|%p: bootstrap stack\n", &boot_stack, &boot_stack); … … 101 64 (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET); 102 65 103 for (size_t i = 0; i < COMPONENTS; i++) { 66 size_t i; 67 for (i = 0; i < COMPONENTS; i++) 104 68 printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start, 105 69 components[i].start, components[i].name, components[i].inflated, 106 70 components[i].size); 107 invalidate_dcache(components[i].start, components[i].size);108 }109 71 110 72 void *dest[COMPONENTS]; … … 112 74 size_t cnt = 0; 113 75 bootinfo.cnt = 0; 114 for ( size_ti = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {76 for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { 115 77 top = ALIGN_UP(top, PAGE_SIZE); 116 78 … … 132 94 printf("\nInflating components ... "); 133 95 134 for ( size_ti = cnt; i > 0; i--) {96 for (i = cnt; i > 0; i--) { 135 97 void *tail = components[i - 1].start + components[i - 1].size; 136 98 if (tail >= dest[i - 1]) { … … 144 106 int err = inflate(components[i - 1].start, components[i - 1].size, 145 107 dest[i - 1], components[i - 1].inflated); 108 146 109 if (err != EOK) { 147 110 printf("\n%s: Inflating error %d\n", components[i - 1].name, err); 148 111 halt(); 149 112 } 150 clean_dcache_poc(dest[i - 1], components[i - 1].inflated);151 113 } 152 114 153 115 printf(".\n"); 154 116 155 printf("Booting the kernel... \n");117 printf("Booting the kernel... \n"); 156 118 jump_to_kernel((void *) PA2KA(BOOT_OFFSET), &bootinfo); 157 119 } -
boot/arch/arm32/src/mm.c
r8ab339e r1935591 38 38 #include <arch/mm.h> 39 39 40 /** Disable the MMU */41 static void disable_paging(void)42 {43 asm volatile (44 "mrc p15, 0, r0, c1, c0, 0\n"45 "bic r0, r0, #1\n"46 "mcr p15, 0, r0, c1, c0, 0\n"47 ::: "r0"48 );49 }50 51 40 /** Check if caching can be enabled for a given memory section. 52 41 * … … 67 56 else 68 57 return 1; 69 #elif defined MACHINE_beagleboardxm 70 const unsigned long address = section << PTE_SECTION_SHIFT; 71 if (address >= BBXM_RAM_START && address < BBXM_RAM_END) 72 return 1; 73 #elif defined MACHINE_beaglebone 74 const unsigned long address = section << PTE_SECTION_SHIFT; 75 if (address >= AM335x_RAM_START && address < AM335x_RAM_END) 76 return 1; 58 #else 59 return 0; 77 60 #endif 78 return 0;79 61 } 80 62 … … 103 85 pte->tex = 0; 104 86 pte->access_permission_1 = 0; 105 pte->shareable = 0;106 87 pte->non_global = 0; 107 88 pte->should_be_zero_2 = 0; … … 118 99 for (page = 0; page < split_page; page++) 119 100 init_ptl0_section(&boot_pt[page], page); 101 102 /* 103 * Create 1:1 virtual-physical mapping in kernel space 104 * (upper 2 GB), physical addresses start from 0. 105 */ 106 /* BeagleBoard-xM (DM37x) memory starts at 2GB border, 107 * thus mapping only lower 2GB is not not enough. 108 * Map entire AS 1:1 instead and hope it works. */ 109 for (page = split_page; page < PTL0_ENTRIES; page++) 110 #ifndef MACHINE_beagleboardxm 111 init_ptl0_section(&boot_pt[page], page - split_page); 112 #else 113 init_ptl0_section(&boot_pt[page], page); 114 #endif 120 115 121 116 asm volatile ( … … 134 129 "ldr r0, =0x55555555\n" 135 130 "mcr p15, 0, r0, c3, c0, 0\n" 136 131 132 #ifdef PROCESSOR_armv7_a 133 /* Read Auxiliary control register */ 134 "mrc p15, 0, r0, c1, c0, 1\n" 135 /* Mask to enable L2 cache */ 136 "ldr r1, =0x00000002\n" 137 "orr r0, r0, r1\n" 138 /* Store Auxiliary control register */ 139 "mrc p15, 0, r0, c1, c0, 1\n" 140 #endif 137 141 /* Current settings */ 138 142 "mrc p15, 0, r0, c1, c0, 0\n" 139 143 140 /* Enable ICache, DCache, BPredictors and MMU, 141 * we disable caches before jumping to kernel 142 * so this is safe for all archs. 143 */ 144 "ldr r1, =0x00001805\n" 144 #ifdef PROCESSOR_armv7_a 145 /* Mask to enable paging, caching */ 146 "ldr r1, =0x00000005\n" 147 #else 148 #ifdef MACHINE_gta02 149 /* Mask to enable paging (bit 0), 150 D-cache (bit 2), I-cache (bit 12) */ 151 "ldr r1, =0x00001005\n" 152 #else 153 /* Mask to enable paging */ 154 "ldr r1, =0x00000001\n" 155 #endif 156 #endif 157 "orr r0, r0, r1\n" 145 158 146 "orr r0, r0, r1\n" 147 148 /* Invalidate the TLB content before turning on the MMU. 149 * ARMv7-A Reference manual, B3.10.3 150 */ 151 "mcr p15, 0, r0, c8, c7, 0\n" 152 153 /* Store settings, enable the MMU */ 159 /* Store settings */ 154 160 "mcr p15, 0, r0, c1, c0, 0\n" 155 161 ::: "r0", "r1" … … 159 165 /** Start the MMU - initialize page table and enable paging. */ 160 166 void mmu_start() { 161 disable_paging();162 167 init_boot_pt(); 163 168 enable_paging(); -
boot/arch/arm32/src/putchar.c
r8ab339e r1935591 40 40 #include <putchar.h> 41 41 #include <str.h> 42 43 #ifdef MACHINE_beaglebone44 45 /** Send a byte to the am335x serial console.46 *47 * @param byte Byte to send.48 */49 static void scons_sendb_bbone(uint8_t byte)50 {51 volatile uint32_t *thr =52 (volatile uint32_t *) BBONE_SCONS_THR;53 volatile uint32_t *ssr =54 (volatile uint32_t *) BBONE_SCONS_SSR;55 56 /* Wait until transmitter is empty */57 while (*ssr & BBONE_TXFIFO_FULL);58 59 /* Transmit byte */60 *thr = (uint32_t) byte;61 }62 63 #endif64 42 65 43 #ifdef MACHINE_beagleboardxm … … 128 106 static void scons_sendb(uint8_t byte) 129 107 { 130 #ifdef MACHINE_beaglebone131 scons_sendb_bbone(byte);132 #endif133 108 #ifdef MACHINE_beagleboardxm 134 109 scons_sendb_bbxm(byte); -
kernel/arch/amd64/include/istate.h
r8ab339e r1935591 66 66 } istate_t; 67 67 68 #define RPL_USER 369 70 68 /** Return true if exception happened while in userspace */ 71 69 NO_TRACE static inline int istate_from_uspace(istate_t *istate) 72 70 { 73 return (istate->cs & RPL_USER) == RPL_USER;71 return !(istate->rip & UINT64_C(0x8000000000000000)); 74 72 } 75 73 -
kernel/arch/arm32/Makefile.inc
r8ab339e r1935591 33 33 ATSIGN = % 34 34 35 GCC_CFLAGS += -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR_ARCH)) -mno-unaligned-access 35 GCC_CFLAGS += -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR)) -mno-unaligned-access 36 37 ifeq ($(MACHINE),beagleboardxm) 38 GCC_CFLAGS += -mcpu=cortex-a8 39 endif 36 40 37 41 ifeq ($(CONFIG_FPU),y) … … 85 89 endif 86 90 87 ifeq ($(MACHINE),beaglebone)88 ARCH_SOURCES += arch/$(KARCH)/src/mach/beaglebone/beaglebone.c89 endif90 91 91 ifeq ($(CONFIG_PL050),y) 92 92 ARCH_SOURCES += genarch/src/drivers/pl050/pl050.c -
kernel/arch/arm32/_link.ld.in
r8ab339e r1935591 10 10 #define KERNEL_LOAD_ADDRESS 0xb0a08000 11 11 #elif defined MACHINE_beagleboardxm 12 #define KERNEL_LOAD_ADDRESS 0x80a0000013 #elif define MACHINE_beaglebone14 12 #define KERNEL_LOAD_ADDRESS 0x80a00000 15 13 #else -
kernel/arch/arm32/include/asm.h
r8ab339e r1935591 43 43 #include <trace.h> 44 44 45 /** CPU specific way to sleep cpu.45 /** No such instruction on old ARM to sleep CPU. 46 46 * 47 47 * ARMv7 introduced wait for event and wait for interrupt (wfe/wfi). 48 48 * ARM920T has custom coprocessor action to do the same. See ARM920T Technical 49 49 * Reference Manual ch 4.9 p. 4-23 (103 in the PDF) 50 * ARM926EJ-S uses the same coprocessor instruction as ARM920T. See ARM926EJ-S51 * chapter 2.3.8 p.2-22 (52 in the PDF)52 *53 * @note Although mcr p15, 0, R0, c7, c0, 4 is defined in ARM Architecture54 * reference manual for armv4/5 CP15 implementation is mandatory only for55 * armv6+.56 50 */ 57 51 NO_TRACE static inline void cpu_sleep(void) 58 52 { 59 #ifdef PROCESSOR_ ARCH_armv7_a60 asm volatile ( "wfe" );61 #elif defined( PROCESSOR_ARCH_armv6) | defined(PROCESSOR_arm926ej_s) | defined(PROCESSOR_arm920t)62 asm volatile ( "mcr p15, 0, R0, c7, c0, 4");53 #ifdef PROCESSOR_armv7_a 54 asm volatile ( "wfe" :: ); 55 #elif defined(MACHINE_gta02) 56 asm volatile ( "mcr p15,0,R0,c7,c0,4" :: ); 63 57 #endif 64 58 } -
kernel/arch/arm32/include/barrier.h
r8ab339e r1935591 37 37 #define KERN_arm32_BARRIER_H_ 38 38 39 #ifdef KERNEL 40 #include <arch/cp15.h> 41 #else 42 #include <libarch/cp15.h> 43 #endif 44 39 /* 40 * TODO: implement true ARM memory barriers for macros below. 41 * ARMv6 introduced user access of the following commands: 42 * • Prefetch flush 43 * • Data synchronization barrier 44 * • Data memory barrier 45 * • Clean and prefetch range operations. 46 * ARM Architecture Reference Manual version I ch. B.3.2.1 p. B3-4 47 */ 45 48 #define CS_ENTER_BARRIER() asm volatile ("" ::: "memory") 46 49 #define CS_LEAVE_BARRIER() asm volatile ("" ::: "memory") … … 57 60 #define read_barrier() asm volatile ("dsb" ::: "memory") 58 61 #define write_barrier() asm volatile ("dsb st" ::: "memory") 59 #define inst_barrier() asm volatile ("isb" ::: "memory")60 #elif defined PROCESSOR_ARCH_armv6 | defined KERNEL61 /*62 * ARMv6 introduced user access of the following commands:63 * - Prefetch flush64 * - Data synchronization barrier65 * - Data memory barrier66 * - Clean and prefetch range operations.67 * ARM Architecture Reference Manual version I ch. B.3.2.1 p. B3-468 */69 /* ARMv6- use system control coprocessor (CP15) for memory barrier instructions.70 * Although at least mcr p15, 0, r0, c7, c10, 4 is mentioned in earlier archs,71 * CP15 implementation is mandatory only for armv6+.72 */73 #define memory_barrier() CP15DMB_write(0)74 #define read_barrier() CP15DSB_write(0)75 #define write_barrier() read_barrier()76 #define inst_barrier() CP15ISB_write(0)77 62 #else 78 /* Older manuals mention syscalls as a way to implement cache coherency and79 * barriers. See for example ARM Architecture Reference Manual Version D80 * chapter 2.7.4 Prefetching and self-modifying code (p. A2-28)81 */82 // TODO implement on per PROCESSOR basis or via syscalls83 63 #define memory_barrier() asm volatile ("" ::: "memory") 84 64 #define read_barrier() asm volatile ("" ::: "memory") 85 65 #define write_barrier() asm volatile ("" ::: "memory") 86 #define inst_barrier() asm volatile ("" ::: "memory")87 66 #endif 88 89 67 /* 90 68 * There are multiple ways ICache can be implemented on ARM machines. Namely … … 102 80 */ 103 81 104 #if defined PROCESSOR_ARCH_armv7_a | defined PROCESSOR_ARCH_armv6 | defined KERNEL 82 #ifdef PROCESSOR_ARCH_armv7_a 83 #define smc_coherence(a) asm volatile ( "isb" ::: "memory") 84 #define smc_coherence_block(a, l) smc_coherence(a) 85 #else 105 86 /* Available on all supported arms, 106 87 * invalidates entire ICache so the written value does not matter. */ 107 //TODO might be PL1 only on armv5- 108 #define smc_coherence(a) \ 109 do { \ 110 DCCMVAU_write((uint32_t)(a)); /* Flush changed memory */\ 111 write_barrier(); /* Wait for completion */\ 112 ICIALLU_write(0); /* Flush ICache */\ 113 inst_barrier(); /* Wait for Inst refetch */\ 114 } while (0) 115 /* @note: Cache type register is not available in uspace. We would need 116 * to export the cache line value, or use syscall for uspace smc_coherence */ 117 #define smc_coherence_block(a, l) \ 118 do { \ 119 for (uintptr_t addr = (uintptr_t)a; addr < (uintptr_t)a + l; addr += 4)\ 120 smc_coherence(addr); \ 121 } while (0) 122 #else 123 #define smc_coherence(a) 124 #define smc_coherence_block(a, l) 88 //TODO might be PL1 only on armv5 - 89 #define smc_coherence(a) asm volatile ( "mcr p15, 0, r0, c7, c5, 0") 90 #define smc_coherence_block(a, l) smc_coherence(a) 125 91 #endif 126 92 -
kernel/arch/arm32/include/cp15.h
r8ab339e r1935591 55 55 56 56 /* Identification registers */ 57 enum {58 MIDR_IMPLEMENTER_MASK = 0xff,59 MIDR_IMPLEMENTER_SHIFT = 24,60 MIDR_VARIANT_MASK = 0xf,61 MIDR_VARIANT_SHIFT = 20,62 MIDR_ARCHITECTURE_MASK = 0xf,63 MIDR_ARCHITECTURE_SHIFT = 16,64 MIDR_PART_NUMBER_MASK = 0xfff,65 MIDR_PART_NUMBER_SHIFT = 4,66 MIDR_REVISION_MASK = 0xf,67 MIDR_REVISION_SHIFT = 0,68 };69 57 CONTROL_REG_GEN_READ(MIDR, c0, 0, c0, 0); 70 71 enum {72 CTR_FORMAT_MASK = 0xe0000000,73 CTR_FORMAT_ARMv7 = 0x80000000,74 CTR_FORMAT_ARMv6 = 0x00000000,75 /* ARMv7 format */76 CTR_CWG_MASK = 0xf,77 CTR_CWG_SHIFT = 24,78 CTR_ERG_MASK = 0xf,79 CTR_ERG_SHIFT = 20,80 CTR_D_MIN_LINE_MASK = 0xf,81 CTR_D_MIN_LINE_SHIFT = 16,82 CTR_I_MIN_LINE_MASK = 0xf,83 CTR_I_MIN_LINE_SHIFT = 0,84 CTR_L1I_POLICY_MASK = 0x0000c000,85 CTR_L1I_POLICY_AIVIVT = 0x00004000,86 CTR_L1I_POLICY_VIPT = 0x00008000,87 CTR_L1I_POLICY_PIPT = 0x0000c000,88 /* ARMv6 format */89 CTR_CTYPE_MASK = 0x1e000000,90 CTR_CTYPE_WT = 0x00000000,91 CTR_CTYPE_WB_NL = 0x04000000,92 CTR_CTYPE_WB_D = 0x0a000000,93 CTR_CTYPE_WB_A = 0x0c000000, /**< ARMv5- only */94 CTR_CTYPE_WB_B = 0x0e000000, /**< ARMv5- only */95 CTR_CTYPE_WB_C = 0x1c000000,96 CTR_SEP_FLAG = 1 << 24,97 CTR_DCACHE_P_FLAG = 1 << 23,98 CTR_DCACHE_SIZE_MASK = 0xf,99 CTR_DCACHE_SIZE_SHIFT = 18,100 CTR_DCACHE_ASSOC_MASK = 0x7,101 CTR_DCACHE_ASSOC_SHIFT = 15,102 CTR_DCACHE_M_FLAG = 1 << 14,103 CTR_DCACHE_LEN_MASK = 0x3,104 CTR_DCACHE_LEN_SHIFT = 0,105 CTR_ICACHE_P_FLAG = 1 << 11,106 CTR_ICACHE_SIZE_MASK = 0xf,107 CTR_ICACHE_SIZE_SHIFT = 6,108 CTR_ICACHE_ASSOC_MASK = 0x7,109 CTR_ICACHE_ASSOC_SHIFT = 3,110 CTR_ICACHE_M_FLAG = 1 << 2,111 CTR_ICACHE_LEN_MASK = 0x3,112 CTR_ICACHE_LEN_SHIFT = 0,113 };114 58 CONTROL_REG_GEN_READ(CTR, c0, 0, c0, 1); 115 59 CONTROL_REG_GEN_READ(TCMR, c0, 0, c0, 2); … … 160 104 CONTROL_REG_GEN_READ(ID_ISAR5, c0, 0, c2, 5); 161 105 162 enum {163 CCSIDR_WT_FLAG = 1 << 31,164 CCSIDR_WB_FLAG = 1 << 30,165 CCSIDR_RA_FLAG = 1 << 29,166 CCSIDR_WA_FLAG = 1 << 28,167 CCSIDR_NUMSETS_MASK = 0x7fff,168 CCSIDR_NUMSETS_SHIFT = 13,169 CCSIDR_ASSOC_MASK = 0x3ff,170 CCSIDR_ASSOC_SHIFT = 3,171 CCSIDR_LINESIZE_MASK = 0x7,172 CCSIDR_LINESIZE_SHIFT = 0,173 };174 106 CONTROL_REG_GEN_READ(CCSIDR, c0, 1, c0, 0); 175 176 enum {177 CLIDR_LOUU_MASK = 0x7,178 CLIDR_LOUU_SHIFT = 27,179 CLIDR_LOC_MASK = 0x7,180 CLIDR_LOC_SHIFT = 24,181 CLIDR_LOUIS_MASK = 0x7,182 CLIDR_LOUIS_SHIFT = 21,183 CLIDR_NOCACHE = 0x0,184 CLIDR_ICACHE_ONLY = 0x1,185 CLIDR_DCACHE_ONLY = 0x2,186 CLIDR_SEP_CACHE = 0x3,187 CLIDR_UNI_CACHE = 0x4,188 CLIDR_CACHE_MASK = 0x7,189 #define CLIDR_CACHE(level, val) ((val >> (level - 1) * 3) & CLIDR_CACHE_MASK)190 };191 107 CONTROL_REG_GEN_READ(CLIDR, c0, 1, c0, 1); 192 108 CONTROL_REG_GEN_READ(AIDR, c0, 1, c0, 7); /* Implementation defined or MIDR */ 193 109 194 enum {195 CCSELR_LEVEL_MASK = 0x7,196 CCSELR_LEVEL_SHIFT = 1,197 CCSELR_INSTRUCTION_FLAG = 1 << 0,198 };199 110 CONTROL_REG_GEN_READ(CSSELR, c0, 2, c0, 0); 200 111 CONTROL_REG_GEN_WRITE(CSSELR, c0, 2, c0, 0); … … 205 116 206 117 /* System control registers */ 207 /* COntrol register bit values see ch. B4.1.130 of ARM Architecture Reference208 * Manual ARMv7-A and ARMv7-R edition, page 1687 */209 enum {210 SCTLR_MMU_EN_FLAG = 1 << 0,211 SCTLR_ALIGN_CHECK_EN_FLAG = 1 << 1, /* Allow alignemnt check */212 SCTLR_CACHE_EN_FLAG = 1 << 2,213 SCTLR_CP15_BARRIER_EN_FLAG = 1 << 5,214 SCTLR_B_EN_FLAG = 1 << 7, /* ARMv6-, big endian switch */215 SCTLR_SWAP_EN_FLAG = 1 << 10,216 SCTLR_BRANCH_PREDICT_EN_FLAG = 1 << 11,217 SCTLR_INST_CACHE_EN_FLAG = 1 << 12,218 SCTLR_HIGH_VECTORS_EN_FLAG = 1 << 13,219 SCTLR_ROUND_ROBIN_EN_FLAG = 1 << 14,220 SCTLR_HW_ACCESS_FLAG_EN_FLAG = 1 << 17,221 SCTLR_WRITE_XN_EN_FLAG = 1 << 19, /* Only if virt. supported */222 SCTLR_USPCE_WRITE_XN_EN_FLAG = 1 << 20, /* Only if virt. supported */223 SCTLR_FAST_IRQ_EN_FLAG = 1 << 21, /* Disable impl. specific feat*/224 SCTLR_UNALIGNED_EN_FLAG = 1 << 22, /* Must be 1 on armv7 */225 SCTLR_IRQ_VECTORS_EN_FLAG = 1 << 24,226 SCTLR_BIG_ENDIAN_EXC_FLAG = 1 << 25,227 SCTLR_NMFI_EN_FLAG = 1 << 27,228 SCTLR_TEX_REMAP_EN_FLAG = 1 << 28,229 SCTLR_ACCESS_FLAG_EN_FLAG = 1 << 29,230 SCTLR_THUMB_EXC_EN_FLAG = 1 << 30,231 };232 118 CONTROL_REG_GEN_READ(SCTLR, c1, 0, c0, 0); 233 119 CONTROL_REG_GEN_WRITE(SCTLR, c1, 0, c0, 0); … … 416 302 CONTROL_REG_GEN_WRITE(TLBIALLNSNHS, c8, 4, c7, 4); 417 303 418 /* c9 are performance monitoring resgisters */ 419 enum { 420 PMCR_IMP_MASK = 0xff, 421 PMCR_IMP_SHIFT = 24, 422 PMCR_IDCODE_MASK = 0xff, 423 PMCR_IDCODE_SHIFT = 16, 424 PMCR_EVENT_NUM_MASK = 0x1f, 425 PMCR_EVENT_NUM_SHIFT = 11, 426 PMCR_DP_FLAG = 1 << 5, 427 PMCR_X_FLAG = 1 << 4, 428 PMCR_D_FLAG = 1 << 3, 429 PMCR_C_FLAG = 1 << 2, 430 PMCR_P_FLAG = 1 << 1, 431 PMCR_E_FLAG = 1 << 0, 432 }; 433 CONTROL_REG_GEN_READ(PMCR, c9, 0, c12, 0); 434 CONTROL_REG_GEN_WRITE(PMCR, c9, 0, c12, 0); 435 enum { 436 PMCNTENSET_CYCLE_COUNTER_EN_FLAG = 1 << 31, 437 #define PMCNTENSET_COUNTER_EN_FLAG(c) (1 << c) 438 }; 439 CONTROL_REG_GEN_READ(PMCNTENSET, c9, 0, c12, 1); 440 CONTROL_REG_GEN_WRITE(PMCNTENSET, c9, 0, c12, 1); 441 CONTROL_REG_GEN_READ(PMCCNTR, c9, 0, c13, 0); 442 CONTROL_REG_GEN_WRITE(PMCCNTR, c9, 0, c13, 0); 443 304 /* c9 are reserved */ 444 305 445 306 /*c10 has tons of reserved too */ -
kernel/arch/arm32/include/cpu.h
r8ab339e r1935591 40 40 #include <arch/asm.h> 41 41 42 enum {43 ARM_MAX_CACHE_LEVELS = 7,44 };45 42 46 43 /** Struct representing ARM CPU identification. */ … … 60 57 /** Revision number. */ 61 58 uint32_t rev_num; 62 63 struct {64 unsigned ways;65 unsigned sets;66 unsigned line_size;67 unsigned way_shift;68 unsigned set_shift;69 } dcache[ARM_MAX_CACHE_LEVELS];70 unsigned dcache_levels;71 59 } cpu_arch_t; 72 60 -
kernel/arch/arm32/include/cycle.h
r8ab339e r1935591 38 38 39 39 #include <trace.h> 40 #include <arch/cp15.h>41 40 42 41 /** Return count of CPU cycles. … … 49 48 NO_TRACE static inline uint64_t get_cycle(void) 50 49 { 51 #ifdef PROCESSOR_ARCH_armv7_a52 if ((ID_PFR1_read() & ID_PFR1_GEN_TIMER_EXT_MASK) ==53 ID_PFR1_GEN_TIMER_EXT) {54 uint32_t low = 0, high = 0;55 asm volatile( "MRRC p15, 0, %[low], %[high], c14": [low]"=r"(low), [high]"=r"(high));56 return ((uint64_t)high << 32) | low;57 } else {58 return (uint64_t)PMCCNTR_read() * 64;59 }60 #endif61 50 return 0; 62 51 } -
kernel/arch/arm32/include/mm/frame.h
r8ab339e r1935591 47 47 48 48 #ifdef MACHINE_gta02 49 50 #define PHYSMEM_START_ADDR 0x3000800051 49 #define BOOT_PAGE_TABLE_ADDRESS 0x30010000 52 53 50 #elif defined MACHINE_beagleboardxm 54 55 #define PHYSMEM_START_ADDR 0x8000000056 51 #define BOOT_PAGE_TABLE_ADDRESS 0x80008000 57 58 #elif defined MACHINE_beaglebone59 60 #define PHYSMEM_START_ADDR 0x8000000061 #define BOOT_PAGE_TABLE_ADDRESS 0x8000800062 63 52 #else 64 65 #define PHYSMEM_START_ADDR 0x0000000066 53 #define BOOT_PAGE_TABLE_ADDRESS 0x00008000 67 68 54 #endif 69 55 70 56 #define BOOT_PAGE_TABLE_START_FRAME (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH) 71 57 #define BOOT_PAGE_TABLE_SIZE_IN_FRAMES (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH) 58 59 #ifdef MACHINE_gta02 60 #define PHYSMEM_START_ADDR 0x30008000 61 #elif defined MACHINE_beagleboardxm 62 #define PHYSMEM_START_ADDR 0x80000000 63 #else 64 #define PHYSMEM_START_ADDR 0x00000000 65 #endif 72 66 73 67 extern void frame_low_arch_init(void); -
kernel/arch/arm32/include/mm/page.h
r8ab339e r1935591 46 46 #define PAGE_SIZE FRAME_SIZE 47 47 48 #if (defined MACHINE_beagleboardxm) || (defined MACHINE_beaglebone)48 #ifdef MACHINE_beagleboardxm 49 49 #ifndef __ASM__ 50 50 # define KA2PA(x) ((uintptr_t) (x)) … … 129 129 set_pt_level1_present((pte_t *) (ptl3), (size_t) (i)) 130 130 131 #if defined(PROCESSOR_ ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)131 #if defined(PROCESSOR_armv6) | defined(PROCESSOR_armv7_a) 132 132 #include "page_armv6.h" 133 #elif defined(PROCESSOR_ ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)133 #elif defined(PROCESSOR_armv4) | defined(PROCESSOR_armv5) 134 134 #include "page_armv4.h" 135 135 #else -
kernel/arch/arm32/include/mm/page_fault.h
r8ab339e r1935591 42 42 /** Decribes CP15 "fault status register" (FSR). 43 43 * 44 * "VMSAv6 added a fifth fault status bit (bit[10]) to both the IFSR and DFSR. 45 * It is IMPLEMENTATION DEFINED how this bit is encoded in earlier versions of 46 * the architecture. A write flag (bit[11] of the DFSR) has also been 47 * introduced." 48 * ARM Architecture Reference Manual version i ch. B4.6 (PDF p. 719) 49 * 50 * See ARM Architecture Reference Manual ch. B4.9.6 (pdf p.743). for FSR info 44 * See ARM Architecture Reference Manual ch. B4.9.6 (pdf p.743). 51 45 */ 52 46 typedef union { -
kernel/arch/arm32/include/regutils.h
r8ab339e r1935591 40 40 #define STATUS_REG_IRQ_DISABLED_BIT (1 << 7) 41 41 #define STATUS_REG_MODE_MASK 0x1f 42 43 /* COntrol register bit values see ch. B4.1.130 of ARM Architecture Reference 44 * Manual ARMv7-A and ARMv7-R edition, page 1687 */ 45 #define CP15_R1_MMU_EN (1 << 0) 46 #define CP15_R1_ALIGN_CHECK_EN (1 << 1) /* Allow alignemnt check */ 47 #define CP15_R1_CACHE_EN (1 << 2) 48 #define CP15_R1_CP15_BARRIER_EN (1 << 5) 49 #define CP15_R1_B_EN (1 << 7) /* ARMv6- only big endian switch */ 50 #define CP15_R1_SWAP_EN (1 << 10) 51 #define CP15_R1_BRANCH_PREDICT_EN (1 << 11) 52 #define CP15_R1_INST_CACHE_EN (1 << 12) 53 #define CP15_R1_HIGH_VECTORS_EN (1 << 13) 54 #define CP15_R1_ROUND_ROBIN_EN (1 << 14) 55 #define CP15_R1_HW_ACCESS_FLAG_EN (1 << 17) 56 #define CP15_R1_WRITE_XN_EN (1 << 19) /* Only if virt. supported */ 57 #define CP15_R1_USPCE_WRITE_XN_EN (1 << 20) /* Only if virt. supported */ 58 #define CP15_R1_FAST_IRQ_EN (1 << 21) /* Disbale impl.specific features */ 59 #define CP15_R1_UNALIGNED_EN (1 << 22) /* Must be 1 on armv7 */ 60 #define CP15_R1_IRQ_VECTORS_EN (1 << 24) 61 #define CP15_R1_BIG_ENDIAN_EXC (1 << 25) 62 #define CP15_R1_NMFI_EN (1 << 27) 63 #define CP15_R1_TEX_REMAP_EN (1 << 28) 64 #define CP15_R1_ACCESS_FLAG_EN (1 << 29) 65 #define CP15_R1_THUMB_EXC_EN (1 << 30) 42 66 43 67 /* ARM Processor Operation Modes */ -
kernel/arch/arm32/include/security_ext.h
r8ab339e r1935591 48 48 static inline bool sec_ext_is_implemented() 49 49 { 50 #ifdef PROCESSOR_ ARCH_armv7_a50 #ifdef PROCESSOR_armv7_a 51 51 const uint32_t idpfr = ID_PFR1_read() & ID_PFR1_SEC_EXT_MASK; 52 52 return idpfr == ID_PFR1_SEC_EXT || idpfr == ID_PFR1_SEC_EXT_RFR; -
kernel/arch/arm32/src/cpu/cpu.c
r8ab339e r1935591 34 34 */ 35 35 36 #include <arch/cache.h>37 36 #include <arch/cpu.h> 38 #include <arch/cp15.h>39 37 #include <cpu.h> 40 38 #include <arch.h> 41 39 #include <print.h> 42 43 static inline unsigned log2(unsigned val)44 {45 unsigned log = 0;46 --val;47 while (val) {48 ++log;49 val >>= 1;50 }51 return log;52 }53 54 static unsigned dcache_ways(unsigned level);55 static unsigned dcache_sets(unsigned level);56 static unsigned dcache_linesize_log(unsigned level);57 58 40 59 41 /** Implementers (vendor) names */ … … 99 81 static void arch_cpu_identify(cpu_arch_t *cpu) 100 82 { 101 const uint32_t ident = MIDR_read(); 102 103 cpu->imp_num = (ident >> MIDR_IMPLEMENTER_SHIFT) & MIDR_IMPLEMENTER_MASK; 104 cpu->variant_num = (ident >> MIDR_VARIANT_SHIFT) & MIDR_VARIANT_MASK; 105 cpu->arch_num = (ident >> MIDR_ARCHITECTURE_SHIFT) & MIDR_ARCHITECTURE_MASK; 106 cpu->prim_part_num = (ident >> MIDR_PART_NUMBER_SHIFT) & MIDR_PART_NUMBER_MASK; 107 cpu->rev_num = (ident >> MIDR_REVISION_SHIFT) & MIDR_REVISION_MASK; 108 83 uint32_t ident; 84 asm volatile ( 85 "mrc p15, 0, %[ident], c0, c0, 0\n" 86 : [ident] "=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; 109 94 // TODO CPUs with arch_num == 0xf use CPUID scheme for identification 110 cpu->dcache_levels = dcache_levels();111 112 for (unsigned i = 0; i < cpu->dcache_levels; ++i) {113 cpu->dcache[i].ways = dcache_ways(i);114 cpu->dcache[i].sets = dcache_sets(i);115 cpu->dcache[i].way_shift = 31 - log2(cpu->dcache[i].ways);116 cpu->dcache[i].set_shift = dcache_linesize_log(i);117 cpu->dcache[i].line_size = 1 << dcache_linesize_log(i);118 printf("Found DCache L%u: %u-way, %u sets, %u byte lines "119 "(shifts: w%u, s%u)\n", i + 1, cpu->dcache[i].ways,120 cpu->dcache[i].sets, cpu->dcache[i].line_size,121 cpu->dcache[i].way_shift, cpu->dcache[i].set_shift);122 }123 95 } 124 96 … … 126 98 void cpu_arch_init(void) 127 99 { 128 uint32_t control_reg = SCTLR_read(); 100 #if defined(PROCESSOR_armv7_a) | defined(PROCESSOR_armv6) 101 uint32_t control_reg = 0; 102 asm volatile ( 103 "mrc p15, 0, %[control_reg], c1, c0" 104 : [control_reg] "=r" (control_reg) 105 ); 129 106 130 /* Turn off tex remap, RAZ/WI prior to armv7 */ 131 control_reg &= ~SCTLR_TEX_REMAP_EN_FLAG; 132 /* Turn off accessed flag, RAZ/WI prior to armv7 */ 133 control_reg &= ~(SCTLR_ACCESS_FLAG_EN_FLAG | SCTLR_HW_ACCESS_FLAG_EN_FLAG); 134 135 /* Unaligned access is supported on armv6+ */ 136 #if defined(PROCESSOR_ARCH_armv7_a) | defined(PROCESSOR_ARCH_armv6) 137 /* Enable unaligned access, RAZ/WI prior to armv6 138 * switchable on armv6, RAO/WI writes on armv7, 107 /* Turn off tex remap, RAZ ignores writes prior to armv7 */ 108 control_reg &= ~CP15_R1_TEX_REMAP_EN; 109 /* Turn off accessed flag, RAZ ignores writes prior to armv7 */ 110 control_reg &= ~(CP15_R1_ACCESS_FLAG_EN | CP15_R1_HW_ACCESS_FLAG_EN); 111 /* Enable unaligned access, RAZ ignores writes prior to armv6 112 * switchable on armv6, RAO ignores writes on armv7, 139 113 * see ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition 140 114 * L.3.1 (p. 2456) */ 141 control_reg |= SCTLR_UNALIGNED_EN_FLAG;115 control_reg |= CP15_R1_UNALIGNED_EN; 142 116 /* Disable alignment checks, this turns unaligned access to undefined, 143 117 * unless U bit is set. */ 144 control_reg &= ~ SCTLR_ALIGN_CHECK_EN_FLAG;118 control_reg &= ~CP15_R1_ALIGN_CHECK_EN; 145 119 /* Enable caching, On arm prior to armv7 there is only one level 146 120 * of caches. Data cache is coherent. … … 150 124 * ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 151 125 * B3.11.1 (p. 1383) 152 * We are safe to turn this on. For arm v6 see ch L.6.2 (p. 2469) 153 * L2 Cache for armv7 is enabled by default (i.e. controlled by 154 * this flag). 126 * ICache coherency is elaborate on in barrier.h. 127 * We are safe to turn these on. 155 128 */ 156 control_reg |= SCTLR_CACHE_EN_FLAG; 129 control_reg |= CP15_R1_CACHE_EN | CP15_R1_INST_CACHE_EN; 130 131 asm volatile ( 132 "mcr p15, 0, %[control_reg], c1, c0" 133 :: [control_reg] "r" (control_reg) 134 ); 157 135 #endif 158 #ifdef PROCESSOR_ARCH_armv7_a159 /* ICache coherency is elaborate on in barrier.h.160 * VIPT and PIPT caches need maintenance only on code modify,161 * so it should be safe for general use.162 * Enable branch predictors too as they follow the same rules163 * as ICache and they can be flushed together164 */165 if ((CTR_read() & CTR_L1I_POLICY_MASK) != CTR_L1I_POLICY_AIVIVT) {166 control_reg |=167 SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG;168 }169 #endif170 SCTLR_write(control_reg);171 172 136 #ifdef CONFIG_FPU 173 137 fpu_setup(); 174 #endif175 176 #ifdef PROCESSOR_ARCH_armv7_a177 if ((ID_PFR1_read() & ID_PFR1_GEN_TIMER_EXT_MASK) !=178 ID_PFR1_GEN_TIMER_EXT) {179 PMCR_write(PMCR_read() | PMCR_E_FLAG | PMCR_D_FLAG);180 PMCNTENSET_write(PMCNTENSET_CYCLE_COUNTER_EN_FLAG);181 }182 138 #endif 183 139 } … … 199 155 } 200 156 201 /** See chapter B4.1.19 of ARM Architecture Reference Manual */202 static unsigned dcache_linesize_log(unsigned level)203 {204 #ifdef PROCESSOR_ARCH_armv7_a205 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);206 const unsigned ls_log = 2 +207 ((CCSIDR_read() >> CCSIDR_LINESIZE_SHIFT) & CCSIDR_LINESIZE_MASK);208 return ls_log + 2; //return log2(bytes)209 #endif210 return 0;211 212 }213 214 /** See chapter B4.1.19 of ARM Architecture Reference Manual */215 static unsigned dcache_ways(unsigned level)216 {217 #ifdef PROCESSOR_ARCH_armv7_a218 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);219 const unsigned ways = 1 +220 ((CCSIDR_read() >> CCSIDR_ASSOC_SHIFT) & CCSIDR_ASSOC_MASK);221 return ways;222 #endif223 return 0;224 }225 226 /** See chapter B4.1.19 of ARM Architecture Reference Manual */227 static unsigned dcache_sets(unsigned level)228 {229 #ifdef PROCESSOR_ARCH_armv7_a230 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);231 const unsigned sets = 1 +232 ((CCSIDR_read() >> CCSIDR_NUMSETS_SHIFT) & CCSIDR_NUMSETS_MASK);233 return sets;234 #endif235 return 0;236 }237 238 unsigned dcache_levels(void)239 {240 unsigned levels = 0;241 #ifdef PROCESSOR_ARCH_armv7_a242 const uint32_t val = CLIDR_read();243 for (unsigned i = 1; i <= 7; ++i) {244 const unsigned ctype = CLIDR_CACHE(i, val);245 switch (ctype) {246 case CLIDR_DCACHE_ONLY:247 case CLIDR_SEP_CACHE:248 case CLIDR_UNI_CACHE:249 ++levels;250 default:251 (void)0;252 }253 }254 #endif255 return levels;256 }257 258 static void dcache_clean_manual(unsigned level, bool invalidate,259 unsigned ways, unsigned sets, unsigned way_shift, unsigned set_shift)260 {261 262 for (unsigned i = 0; i < ways; ++i) {263 for (unsigned j = 0; j < sets; ++j) {264 const uint32_t val =265 ((level & 0x7) << 1) |266 (j << set_shift) | (i << way_shift);267 if (invalidate)268 DCCISW_write(val);269 else270 DCCSW_write(val);271 }272 }273 }274 275 void dcache_flush(void)276 {277 /* See ARM Architecture Reference Manual ch. B4.2.1 p. B4-1724 */278 const unsigned levels = dcache_levels();279 for (unsigned i = 0; i < levels; ++i) {280 const unsigned ways = dcache_ways(i);281 const unsigned sets = dcache_sets(i);282 const unsigned way_shift = 31 - log2(ways);283 const unsigned set_shift = dcache_linesize_log(i);284 dcache_clean_manual(i, false, ways, sets, way_shift, set_shift);285 }286 }287 288 void dcache_flush_invalidate(void)289 {290 /* See ARM Architecture Reference Manual ch. B4.2.1 p. B4-1724 */291 const unsigned levels = dcache_levels();292 for (unsigned i = 0; i < levels; ++i) {293 const unsigned ways = dcache_ways(i);294 const unsigned sets = dcache_sets(i);295 const unsigned way_shift = 31 - log2(ways);296 const unsigned set_shift = dcache_linesize_log(i);297 dcache_clean_manual(i, true, ways, sets, way_shift, set_shift);298 }299 }300 301 302 void cpu_dcache_flush(void)303 {304 for (unsigned i = 0; i < CPU->arch.dcache_levels; ++i)305 dcache_clean_manual(i, false,306 CPU->arch.dcache[i].ways, CPU->arch.dcache[i].sets,307 CPU->arch.dcache[i].way_shift, CPU->arch.dcache[i].set_shift);308 }309 310 void cpu_dcache_flush_invalidate(void)311 {312 const unsigned levels = dcache_levels();313 for (unsigned i = 0; i < levels; ++i)314 dcache_clean_manual(i, true,315 CPU->arch.dcache[i].ways, CPU->arch.dcache[i].sets,316 CPU->arch.dcache[i].way_shift, CPU->arch.dcache[i].set_shift);317 }318 319 void icache_invalidate(void)320 {321 ICIALLU_write(0);322 }323 324 157 /** @} 325 158 */ -
kernel/arch/arm32/src/exception.c
r8ab339e r1935591 39 39 #include <interrupt.h> 40 40 #include <arch/mm/page_fault.h> 41 #include <arch/cp15.h>42 41 #include <arch/barrier.h> 43 42 #include <print.h> … … 74 73 /* make it LDR instruction and store at exception vector */ 75 74 *vector = handler_address_ptr | LDR_OPCODE; 76 smc_coherence( vector);75 smc_coherence(*vector); 77 76 78 77 /* store handler's address */ … … 137 136 static void high_vectors(void) 138 137 { 139 uint32_t control_reg = SCTLR_read(); 138 uint32_t control_reg = 0; 139 asm volatile ( 140 "mrc p15, 0, %[control_reg], c1, c0" 141 : [control_reg] "=r" (control_reg) 142 ); 140 143 141 144 /* switch on the high vectors bit */ 142 control_reg |= SCTLR_HIGH_VECTORS_EN_FLAG; 143 144 SCTLR_write(control_reg); 145 control_reg |= CP15_R1_HIGH_VECTORS_EN; 146 147 asm volatile ( 148 "mcr p15, 0, %[control_reg], c1, c0" 149 :: [control_reg] "r" (control_reg) 150 ); 145 151 } 146 152 #endif -
kernel/arch/arm32/src/fpu_context.c
r8ab339e r1935591 119 119 * rely on user decision to use CONFIG_FPU. 120 120 */ 121 #ifdef PROCESSOR_ ARC_armv7_a121 #ifdef PROCESSOR_armv7_a 122 122 const uint32_t cpacr = CPACR_read(); 123 123 /* FPU needs access to coprocessor 10 and 11. … … 148 148 * rely on user decision to use CONFIG_FPU. 149 149 */ 150 #ifdef PROCESSOR_ARCH_armv7_a 150 #ifndef PROCESSOR_armv7_a 151 return; 152 #endif 153 151 154 /* Allow coprocessor access */ 152 155 uint32_t cpacr = CPACR_read(); … … 156 159 cpacr |= (CPACR_CP_FULL_ACCESS(10) | CPACR_CP_FULL_ACCESS(11)); 157 160 CPACR_write(cpacr); 158 #endif 161 162 smc_coherence(0); 159 163 } 160 164 -
kernel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c
r8ab339e r1935591 35 35 #include <arch/exception.h> 36 36 #include <arch/mach/beagleboardxm/beagleboardxm.h> 37 #include <genarch/drivers/amdm37x/uart.h> 38 #include <genarch/drivers/amdm37x/irc.h> 39 #include <genarch/drivers/amdm37x/gpt.h> 37 #include <genarch/drivers/amdm37x_irc/amdm37x_irc.h> 38 #include <genarch/drivers/amdm37x_uart/amdm37x_uart.h> 39 #include <genarch/drivers/amdm37x_gpt/amdm37x_gpt.h> 40 #include <genarch/drivers/amdm37x_dispc/amdm37x_dispc.h> 40 41 #include <genarch/fb/fb.h> 41 42 #include <genarch/srln/srln.h> … … 60 61 61 62 static struct beagleboard { 63 amdm37x_dispc_regs_t *dispc; 62 64 amdm37x_irc_regs_t *irc_addr; 63 65 amdm37x_uart_t uart; … … 83 85 } 84 86 87 static void bbxm_setup_fb(unsigned width, unsigned height, unsigned bpp) 88 { 89 const unsigned pixel_bytes = (bpp / 8); 90 const size_t size = ALIGN_UP(width * height * pixel_bytes, FRAME_SIZE); 91 const unsigned frames = size / FRAME_SIZE; 92 unsigned order = 0; 93 unsigned frame = 1; 94 while (frame < frames) { 95 frame *= 2; 96 ++order; 97 } 98 /* prefer highmem as we don't care about virtual mapping. */ 99 void *buffer = frame_alloc(order, FRAME_LOWMEM); 100 if (!buffer) { 101 printf("Failed to allocate framebuffer.\n"); 102 return; 103 } 104 105 amdm37x_dispc_setup_fb(beagleboard.dispc, width, height, bpp, 106 (uintptr_t) buffer); 107 108 fb_properties_t prop = { 109 .addr = (uintptr_t)buffer, 110 .offset = 0, 111 .x = width, 112 .y = height, 113 .scan = width * pixel_bytes, 114 .visual = VISUAL_RGB_5_6_5_LE 115 }; 116 switch (bpp) 117 { 118 case 8: 119 prop.visual = VISUAL_INDIRECT_8; break; 120 case 16: 121 prop.visual = VISUAL_RGB_5_6_5_LE; break; 122 case 24: 123 prop.visual = VISUAL_BGR_8_8_8; break; 124 case 32: 125 prop.visual = VISUAL_RGB_8_8_8_0; break; 126 default: 127 printf("Invalid framebuffer bit depth: bailing out.\n"); 128 return; 129 } 130 outdev_t *fb_dev = fb_init(&prop); 131 if (fb_dev) 132 stdout_wire(fb_dev); 133 134 } 135 85 136 static void bb_timer_irq_handler(irq_t *irq) 86 137 { … … 103 154 ASSERT(beagleboard.irc_addr); 104 155 amdm37x_irc_init(beagleboard.irc_addr); 156 157 /* Map display controller */ 158 beagleboard.dispc = (void*) km_map(AMDM37x_DISPC_BASE_ADDRESS, 159 AMDM37x_DISPC_SIZE, PAGE_NOT_CACHEABLE); 160 ASSERT(beagleboard.dispc); 105 161 106 162 /* Initialize timer. Use timer1, because it is in WKUP power domain … … 167 223 static void bbxm_output_init(void) 168 224 { 225 #ifdef CONFIG_FB 226 bbxm_setup_fb(CONFIG_BFB_WIDTH, CONFIG_BFB_HEIGHT, CONFIG_BFB_BPP); 227 #else 228 (void)bbxm_setup_fb; 229 #endif 169 230 /* UART3 is wired to external RS232 connector */ 170 231 const bool ok = amdm37x_uart_init(&beagleboard.uart, -
kernel/arch/arm32/src/machine_func.c
r8ab339e r1935591 42 42 #include <arch/mach/integratorcp/integratorcp.h> 43 43 #include <arch/mach/beagleboardxm/beagleboardxm.h> 44 #include <arch/mach/beaglebone/beaglebone.h>45 44 46 45 /** Pointer to machine_ops structure being used. */ … … 56 55 #elif defined(MACHINE_beagleboardxm) 57 56 machine_ops = &bbxm_machine_ops; 58 #elif defined(MACHINE_beaglebone)59 machine_ops = &bbone_machine_ops;60 57 #else 61 58 #error Machine type not defined. -
kernel/arch/arm32/src/mm/page_fault.c
r8ab339e r1935591 34 34 */ 35 35 #include <panic.h> 36 #include <arch/cp15.h>37 36 #include <arch/exception.h> 38 37 #include <arch/mm/page_fault.h> … … 128 127 } 129 128 130 #if defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5) 129 130 /** Returns value stored in comnbined/data fault status register. 131 * 132 * @return Value stored in CP15 fault status register (FSR). 133 * 134 * "VMSAv6 added a fifth fault status bit (bit[10]) to both the IFSR and DFSR. 135 * It is IMPLEMENTATION DEFINED how this bit is encoded in earlier versions of 136 * the architecture. A write flag (bit[11] of the DFSR) has also been 137 * introduced." 138 * ARM Architecture Reference Manual version i ch. B4.6 (PDF p. 719) 139 * 140 * See ch. B4.9.6 for location of data/instruction FSR. 141 * 142 */ 143 static inline fault_status_t read_data_fault_status_register(void) 144 { 145 fault_status_t fsu; 146 147 /* Combined/Data fault status is stored in CP15 register 5, c0. */ 148 asm volatile ( 149 "mrc p15, 0, %[dummy], c5, c0, 0" 150 : [dummy] "=r" (fsu.raw) 151 ); 152 153 return fsu; 154 } 155 156 /** Returns DFAR (fault address register) content. 157 * 158 * This register is equivalent to FAR on pre armv6 machines. 159 * 160 * @return DFAR (fault address register) content (address that caused a page 161 * fault) 162 */ 163 static inline uintptr_t read_data_fault_address_register(void) 164 { 165 uintptr_t ret; 166 167 /* fault adress is stored in CP15 register 6 */ 168 asm volatile ( 169 "mrc p15, 0, %[ret], c6, c0, 0" 170 : [ret] "=r" (ret) 171 ); 172 173 return ret; 174 } 175 176 #if defined(PROCESSOR_armv4) | defined(PROCESSOR_armv5) 131 177 /** Decides whether read or write into memory is requested. 132 178 * … … 198 244 void data_abort(unsigned int exc_no, istate_t *istate) 199 245 { 200 const uintptr_t badvaddr = DFAR_read();201 const fault_status_t fsr = { .raw = DFSR_read() };246 const uintptr_t badvaddr = read_data_fault_address_register(); 247 const fault_status_t fsr = read_data_fault_status_register(); 202 248 const dfsr_source_t source = fsr.raw & DFSR_SOURCE_MASK; 203 249 … … 235 281 } 236 282 237 #if defined(PROCESSOR_ ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)283 #if defined(PROCESSOR_armv6) | defined(PROCESSOR_armv7_a) 238 284 const pf_access_t access = 239 285 fsr.data.wr ? PF_ACCESS_WRITE : PF_ACCESS_READ; 240 #elif defined(PROCESSOR_ ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)286 #elif defined(PROCESSOR_armv4) | defined(PROCESSOR_armv5) 241 287 const pf_access_t access = get_memory_access_type(istate->pc, badvaddr); 242 288 #else -
kernel/arch/ia32/include/istate.h
r8ab339e r1935591 68 68 } istate_t; 69 69 70 #define RPL_USER 371 72 70 /** Return true if exception happened while in userspace */ 73 71 NO_TRACE static inline int istate_from_uspace(istate_t *istate) 74 72 { 75 return (istate->cs & RPL_USER) == RPL_USER;73 return !(istate->eip & UINT32_C(0x80000000)); 76 74 } 77 75 -
kernel/genarch/Makefile.inc
r8ab339e r1935591 106 106 endif 107 107 108 ifeq ($(CONFIG_AM335X_UART),y)109 GENARCH_SOURCES += \110 genarch/src/drivers/am335x/uart.c111 endif112 113 ifeq ($(CONFIG_AM335X_TIMERS),y)114 GENARCH_SOURCES += \115 genarch/src/drivers/am335x/timer.c116 endif117 118 108 ifeq ($(CONFIG_AMDM37X_UART),y) 119 109 GENARCH_SOURCES += \ 120 genarch/src/drivers/amdm37x /uart.c110 genarch/src/drivers/amdm37x_uart/amdm37x_uart.c 121 111 endif 122 112 -
kernel/generic/src/main/kinit.c
r8ab339e r1935591 250 250 CAP_IO_MANAGER | CAP_IRQ_REG); 251 251 252 if (!ipc_phone_0) {252 if (!ipc_phone_0) 253 253 ipc_phone_0 = &programs[i].task->answerbox; 254 /*255 * Hold the first task so that the256 * ipc_phone_0 remains a valid pointer257 * even if the first task exits for258 * whatever reason.259 */260 task_hold(programs[i].task);261 }262 254 } 263 255 -
kernel/generic/src/proc/task.c
r8ab339e r1935591 125 125 { 126 126 size_t tasks_left; 127 128 if (ipc_phone_0) {129 task_t *task_0 = ipc_phone_0->task;130 ipc_phone_0 = NULL;131 /*132 * The first task is held by kinit(), we need to release it or133 * it will never finish cleanup.134 */135 task_release(task_0);136 }137 127 138 128 /* Repeat until there are any tasks except TASK */ -
uspace/Makefile
r8ab339e r1935591 194 194 ifeq ($(UARCH),arm32) 195 195 DIRS += \ 196 drv/infrastructure/rootamdm37x \ 197 drv/fb/amdm37x_dispc 196 drv/infrastructure/rootamdm37x 198 197 endif 199 198 -
uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
r8ab339e r1935591 195 195 ddf_msg(LVL_ERROR, "Failed to add EHCI function for " 196 196 "BeagleBoard-xM platform."); 197 if (rootamdm37x_add_fun(dev, "dispc", "amdm37x&dispc", &ehci) != EOK)198 ddf_msg(LVL_ERROR, "Failed to add dispc function for "199 "BeagleBoard-xM platform.");200 197 201 198 return EOK; -
uspace/lib/c/arch/arm32/Makefile.common
r8ab339e r1935591 28 28 # 29 29 30 GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR _ARCH))30 GCC_CFLAGS += -ffixed-r9 -mtp=soft -fno-omit-frame-pointer -mapcs-frame -march=$(subst _,-,$(PROCESSOR)) 31 31 32 32 ifeq ($(CONFIG_FPU),y) -
uspace/lib/drv/include/ddf/log.h
r8ab339e r1935591 44 44 size_t); 45 45 46 #define ddf_log_fatal(msg...) ddf_msg(LVL_FATAL, msg)47 #define ddf_log_error(msg...) ddf_msg(LVL_ERROR, msg)48 #define ddf_log_warning(msg...) ddf_msg(LVL_WARN, msg)49 #define ddf_log_note(msg...) ddf_msg(LVL_NOTE, msg)50 #define ddf_log_debug(msg...) ddf_msg(LVL_DEBUG, msg)51 #define ddf_log_verbose(msg...) ddf_msg(LVL_DEBUG2, msg)52 53 46 #endif 54 47
Note:
See TracChangeset
for help on using the changeset viewer.