Changeset cf1f72e in rtems
- Timestamp:
- 06/13/00 21:53:38 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 7d52750
- Parents:
- f0b11d63
- Files:
-
- 8 added
- 2 deleted
- 19 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libcsupport/src/malloc.c
rf0b11d63 rcf1f72e 420 420 } 421 421 422 423 /* 424 * rtems_cache_aligned_malloc 425 * 426 * DESCRIPTION: 427 * 428 * This function is used to allocate storage that spans an 429 * integral number of cache blocks. 430 */ 431 RTEMS_INLINE_ROUTINE void * rtems_cache_aligned_malloc ( 432 size_t nbytes 433 ) 434 { 435 /* 436 * Arrange to have the user storage start on the first cache 437 * block beyond the header. 438 */ 439 return (void *) ((((unsigned long) malloc( nbytes + _CPU_DATA_CACHE_ALIGNMENT - 1 )) 440 + _CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(_CPU_DATA_CACHE_ALIGNMENT - 1)) ); 441 } 442 443 #endif 444 422 #endif -
c/src/exec/rtems/include/rtems.h
rf0b11d63 rcf1f72e 43 43 #include <rtems/rtems/tasks.h> 44 44 #include <rtems/rtems/intr.h> 45 #include <rtems/rtems/cache.h> 45 46 #include <rtems/rtems/clock.h> 46 47 #include <rtems/extension.h> -
c/src/exec/rtems/src/Makefile.am
rf0b11d63 rcf1f72e 51 51 dpmemident.c dpmeminternal2external.c 52 52 53 STD_C_FILES = attr.c cache.c$(TASK_C_FILES) $(RATEMON_C_FILES) $(INTR_C_FILES) \53 STD_C_FILES = attr.c $(TASK_C_FILES) $(RATEMON_C_FILES) $(INTR_C_FILES) \ 54 54 $(CLOCK_C_FILES) $(TIMER_C_FILES) $(SEMAPHORE_C_FILES) \ 55 55 $(MESSAGE_QUEUE_C_FILES) $(EVENT_C_FILES) $(SIGNAL_C_FILES) \ -
c/src/exec/score/cpu/i386/rtems/score/i386.h
rf0b11d63 rcf1f72e 186 186 } 187 187 188 /*189 * Disable the entire cache190 */191 void _CPU_disable_cache() {192 cr0 regCr0;193 194 regCr0.i = i386_get_cr0();195 regCr0.cr0.page_level_cache_disable = 1;196 regCr0.cr0.no_write_through = 1;197 i386_set_cr0( regCr0.i );198 rtems_flush_entire_data_cache();199 }200 201 /*202 * Enable the entire cache203 */204 static inline void _CPU_enable_cache() {205 cr0 regCr0;206 207 regCr0.i = i386_get_cr0();208 regCr0.cr0.page_level_cache_disable = 0;209 regCr0.cr0.no_write_through = 0;210 i386_set_cr0( regCr0.i );211 /*rtems_flush_entire_data_cache();*/212 }213 214 /*215 * CACHE MANAGER: The following functions are CPU-specific.216 * They provide the basic implementation for the rtems_* cache217 * management routines. If a given function has no meaning for the CPU,218 * it does nothing by default.219 *220 * FIXME: Definitions for I386_CACHE_ALIGNMENT are missing above for221 * each CPU. The routines below should be implemented per CPU,222 * to accomodate the capabilities of each.223 */224 225 /* FIXME: I don't belong here. */226 #define I386_CACHE_ALIGNMENT 16227 228 #if defined(I386_CACHE_ALIGNMENT)229 #define _CPU_DATA_CACHE_ALIGNMENT I386_CACHE_ALIGNMENT230 #define _CPU_INST_CACHE_ALIGNEMNT I386_CACHE_ALIGNMENT231 232 static inline void _CPU_flush_1_data_cache_line (const void * d_addr) {}233 static inline void _CPU_invalidate_1_data_cache_line (const void * d_addr) {}234 static inline void _CPU_freeze_data_cache (void) {}235 static inline void _CPU_unfreeze_data_cache (void) {}236 static inline void _CPU_invalidate_1_inst_cache_line const void * d_addr() {}237 static inline void _CPU_freeze_inst_cache (void) {}238 static inline void _CPU_unfreeze_inst_cache (void) {}239 240 static inline void _CPU_flush_entire_data_cache (241 const void * d_addr )242 {243 asm ("wbinvd");244 }245 static inline void _CPU_invalidate_entire_data_cache (246 const void * d_addr )247 {248 asm ("invd");249 }250 251 static inline void _CPU_enable_data_cache (252 void )253 {254 _CPU_enable_cache();255 }256 257 static inline void _CPU_disable_data_cache (258 void )259 {260 _CPU_disable_cache();261 }262 263 static inline void _CPU_invalidate_entire_inst_cache (264 const void * i_addr )265 {266 asm ("invd");267 }268 269 static inline void _CPU_enable_inst_cache (270 void )271 {272 _CPU_enable_cache();273 }274 275 static inline void _CPU_disable_inst_cache (276 void )277 {278 _CPU_disable_cache();279 }280 #endif281 282 283 188 /* routines */ 284 189 -
c/src/exec/score/cpu/m68k/rtems/score/m68k.h
rf0b11d63 rcf1f72e 374 374 375 375 376 /*377 * Since the cacr is common to all mc680x0, provide macros378 * for masking values in that register.379 */380 381 /*382 * Used to clear bits in the cacr.383 */384 #define _CPU_CACR_AND(mask) \385 { \386 register unsigned long _value = mask; \387 register unsigned long _ctl = 0; \388 asm volatile ( "movec %%cacr, %0; /* read the cacr */ \389 andl %2, %0; /* and with _val */ \390 movec %1, %%cacr" /* write the cacr */ \391 : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" ); \392 }393 394 395 /*396 * Used to set bits in the cacr.397 */398 #define _CPU_CACR_OR(mask) \399 { \400 register unsigned long _value = mask; \401 register unsigned long _ctl = 0; \402 asm volatile ( "movec %%cacr, %0; /* read the cacr */ \403 orl %2, %0; /* or with _val */ \404 movec %1, %%cacr" /* write the cacr */ \405 : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" ); \406 }407 408 409 /*410 * CACHE MANAGER: The following functions are CPU-specific.411 * They provide the basic implementation for the rtems_* cache412 * management routines. If a given function has no meaning for the CPU,413 * it does nothing by default.414 */415 #if ( defined(__mc68020__) || defined(__mc68030__) )416 #define M68K_INST_CACHE_ALIGNMENT 16417 418 #if defined(__mc68030__)419 #define M68K_DATA_CACHE_ALIGNMENT 16420 421 /* Only the mc68030 has a data cache; it is writethrough only. */422 423 static inline void _CPU_flush_1_data_cache_line ( const void * d_addr ) {}424 static inline void _CPU_flush_entire_data_cache ( const void * d_addr ) {}425 426 static inline void _CPU_invalidate_1_data_cache_line (427 const void * d_addr )428 {429 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );430 asm volatile ( "movec %0, %%caar" :: "a" (p_address) ); /* write caar */431 _CPU_CACR_OR(0x00000400);432 }433 434 static inline void _CPU_invalidate_entire_data_cache (435 void )436 {437 _CPU_CACR_OR( 0x00000800 );438 }439 440 static inline void _CPU_freeze_data_cache (441 void )442 {443 _CPU_CACR_OR( 0x00000200 );444 }445 446 static inline void _CPU_unfreeze_data_cache (447 void )448 {449 _CPU_CACR_AND( 0xFFFFFDFF );450 }451 452 static inline void _CPU_enable_data_cache ( void )453 {454 _CPU_CACR_OR( 0x00000100 );455 }456 static inline void _CPU_disable_data_cache ( void )457 {458 _CPU_CACR_AND( 0xFFFFFEFF );459 }460 #endif461 462 463 /* Both the 68020 and 68030 have instruction caches */464 465 static inline void _CPU_invalidate_1_inst_cache_line (466 const void * d_addr )467 {468 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );469 asm volatile ( "movec %0, %%caar" :: "a" (p_address) ); /* write caar */470 _CPU_CACR_OR( 0x00000004 );471 }472 473 static inline void _CPU_invalidate_entire_inst_cache (474 void )475 {476 _CPU_CACR_OR( 0x00000008 );477 }478 479 static inline void _CPU_freeze_inst_cache (480 void )481 {482 _CPU_CACR_OR( 0x00000002);483 }484 485 static inline void _CPU_unfreeze_inst_cache (486 void )487 {488 _CPU_CACR_AND( 0xFFFFFFFD );489 }490 491 static inline void _CPU_enable_inst_cache ( void )492 {493 _CPU_CACR_OR( 0x00000001 );494 }495 496 static inline void _CPU_disable_inst_cache ( void )497 {498 _CPU_CACR_AND( 0xFFFFFFFE );499 }500 501 502 #elif ( defined(__mc68040__) || defined (__mc68060__) )503 504 #define M68K_INST_CACHE_ALIGNMENT 16505 #define M68K_DATA_CACHE_ALIGNMENT 16506 507 /* Cannot be frozen */508 static inline void _CPU_freeze_data_cache ( void ) {}509 static inline void _CPU_unfreeze_data_cache ( void ) {}510 static inline void _CPU_freeze_inst_cache ( void ) {}511 static inline void _CPU_unfreeze_inst_cache ( void ) {}512 513 static inline void _CPU_flush_1_data_cache_line (514 const void * d_addr )515 {516 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );517 asm volatile ( "cpushl %%dc,(%0)" :: "a" (p_address) );518 }519 520 static inline void _CPU_invalidate_1_data_cache_line (521 const void * d_addr )522 {523 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );524 asm volatile ( "cinvl %%dc,(%0)" :: "a" (p_address) );525 }526 527 static inline void _CPU_flush_entire_data_cache (528 void )529 {530 asm volatile ( "cpusha %%dc" :: );531 }532 533 static inline void _CPU_invalidate_entire_data_cache (534 void )535 {536 asm volatile ( "cinva %%dc" :: );537 }538 539 static inline void _CPU_enable_data_cache (540 void )541 {542 _CPU_CACR_OR( 0x80000000 );543 }544 545 static inline void _CPU_disable_data_cache (546 void )547 {548 _CPU_CACR_AND( 0x7FFFFFFF );549 }550 551 static inline void _CPU_invalidate_1_inst_cache_line (552 const void * i_addr )553 {554 void * p_address = (void *) _CPU_virtual_to_physical( i_addr );555 asm volatile ( "cinvl %%ic,(%0)" :: "a" (p_address) );556 }557 558 static inline void _CPU_invalidate_entire_inst_cache (559 void )560 {561 asm volatile ( "cinva %%ic" :: );562 }563 564 static inline void _CPU_enable_inst_cache (565 void )566 {567 _CPU_CACR_OR( 0x00008000 );568 }569 570 static inline void _CPU_disable_inst_cache (571 void )572 {573 _CPU_CACR_AND( 0xFFFF7FFF );574 }575 #endif576 577 578 #if defined(M68K_DATA_CACHE_ALIGNMENT)579 #define _CPU_DATA_CACHE_ALIGNMENT M68K_DATA_CACHE_ALIGNMENT580 #endif581 582 #if defined(M68K_INST_CACHE_ALIGNMENT)583 #define _CPU_INST_CACHE_ALIGNMENT M68K_INST_CACHE_ALIGNMENT584 #endif585 586 587 376 #endif /* !ASM */ 588 377 -
c/src/lib/libbsp/i386/i386ex/wrapup/Makefile.am
rf0b11d63 rcf1f72e 14 14 15 15 # bummer; have to use $foreach since % pattern subst rules only replace 1x 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ 17 $(wildcard ../../../../libcpu/i386/$(ARCH)/*.o) 17 18 LIB = $(ARCH)/libbsp.a 18 19 -
c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am
rf0b11d63 rcf1f72e 14 14 15 15 # bummer; have to use $foreach since % pattern subst rules only replace 1x 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ 17 $(wildcard ../../../../libcpu/i386/$(ARCH)/*.o) 17 18 LIB = $(ARCH)/libbsp.a 18 19 -
c/src/lib/libbsp/i386/ts_386ex/wrapup/Makefile.am
rf0b11d63 rcf1f72e 14 14 15 15 # bummer; have to use $foreach since % pattern subst rules only replace 1x 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) 16 OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ 17 $(wildcard ../../../../libcpu/i386/$(ARCH)/*.o) 17 18 LIB = $(ARCH)/libbsp.a 18 19 -
c/src/lib/libbsp/m68k/mvme167/wrapup/Makefile.am
rf0b11d63 rcf1f72e 14 14 # bummer; have to use $foreach since % pattern subst rules only replace 1x 15 15 OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ 16 $(wildcard ../../../../libcpu/$(RTEMS_CPU)/shared/*/$(ARCH)/*.o) \ 16 17 $(wildcard ../../../../libcpu/$(RTEMS_CPU)/$(RTEMS_CPU_MODEL)/fpsp/$(ARCH)/fpsp.rel) 17 18 -
c/src/lib/libc/malloc.c
rf0b11d63 rcf1f72e 420 420 } 421 421 422 423 /* 424 * rtems_cache_aligned_malloc 425 * 426 * DESCRIPTION: 427 * 428 * This function is used to allocate storage that spans an 429 * integral number of cache blocks. 430 */ 431 RTEMS_INLINE_ROUTINE void * rtems_cache_aligned_malloc ( 432 size_t nbytes 433 ) 434 { 435 /* 436 * Arrange to have the user storage start on the first cache 437 * block beyond the header. 438 */ 439 return (void *) ((((unsigned long) malloc( nbytes + _CPU_DATA_CACHE_ALIGNMENT - 1 )) 440 + _CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(_CPU_DATA_CACHE_ALIGNMENT - 1)) ); 441 } 442 443 #endif 444 422 #endif -
c/src/lib/libcpu/i386/Makefile.am
rf0b11d63 rcf1f72e 6 6 ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal 7 7 8 LIBNAME = libcpu 9 LIB = $(ARCH)/$(LIBNAME).a 8 VPATH = @srcdir@:@srcdir@/../shared/src 10 9 11 C_FILES = c pu.c displayCpu.c page.c10 C_FILES = cache.c cache_aligned_malloc.c cache_manager.c displayCpu.c idt.c page.c 12 11 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 13 12 14 H_FILES = cpu.h registers.h cpuModel.h 13 H_FILES = cache_.h 14 INSTALLED_H_FILES = cpu.h registers.h cpuModel.h 15 15 16 S_FILES = cpu _asm.S cpuModel.S16 S_FILES = cpuModel.S idtr.S 17 17 S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.o) 18 18 … … 22 22 include $(top_srcdir)/../../../../../automake/lib.am 23 23 24 $(LIB): $(OBJS) 25 $(make-library) 24 AM_CPPFLAGS += -I$(srcdir) 26 25 27 26 $(PROJECT_INCLUDE)/libcpu: … … 31 30 $(INSTALL_DATA) $< $@ 32 31 33 $(PROJECT_ RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB)32 $(PROJECT_INCLUDE)/libcpu/cache.h: $(top_srcdir)/../shared/include/cache.h 34 33 $(INSTALL_DATA) $< $@ 35 34 36 35 PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu \ 37 $(H_FILES:%=$(PROJECT_INCLUDE)/libcpu/%) 36 $(PROJECT_INCLUDE)/libcpu/cache.h \ 37 $(INSTALLED_H_FILES:%=$(PROJECT_INCLUDE)/libcpu/%) 38 38 39 TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a 39 all-local: $(ARCH) $(PREINSTALL_FILES) $(OBJS) 40 40 41 all-local: $(ARCH) $(PREINSTALL_FILES) $(OBJS) $(LIB) $(TMPINSTALL_FILES) 42 43 .PRECIOUS: $(LIB) 44 45 EXTRA_DIST = cpu.c cpu.h cpuModel.S cpuModel.h cpu_asm.S displayCpu.c page.c \ 46 registers.h 41 EXTRA_DIST = cache.c cache_.h cpu.h cpuModel.S cpuModel.h \ 42 displayCpu.c idt.c idtr.S page.c registers.h 47 43 48 44 include $(top_srcdir)/../../../../../automake/local.am -
c/src/lib/libcpu/m68k/Makefile.am
rf0b11d63 rcf1f72e 6 6 ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal 7 7 8 SUBDIRS = m68040 8 if shared 9 SHARED_LIB = shared 10 endif 11 12 if m68040 13 CPU_SUBDIR = m68040 14 endif 15 16 SUBDIRS = $(SHARED_LIB) $(CPU_SUBDIR) 9 17 10 18 include $(top_srcdir)/../../../../../automake/subdirs.am -
c/src/lib/libcpu/m68k/configure.in
rf0b11d63 rcf1f72e 27 27 RTEMS_CHECK_BSP_CACHE(RTEMS_BSP) 28 28 29 AM_CONDITIONAL(shared, test "$RTEMS_CPU_MODEL" = "m68020" \ 30 || test "$RTEMS_CPU_MODEL" = "m68020" \ 31 || test "$RTEMS_CPU_MODEL" = "m68030" \ 32 || test "$RTEMS_CPU_MODEL" = "m68lc040" \ 33 || test "$RTEMS_CPU_MODEL" = "m68040" \ 34 || test "$RTEMS_CPU_MODEL" = "m68060" ) 35 29 36 AM_CONDITIONAL(m68040, test "$RTEMS_CPU_MODEL" = "m68040") 30 37 … … 32 39 AC_OUTPUT( 33 40 Makefile 41 shared/Makefile 42 shared/cache/Makefile 34 43 m68040/Makefile 35 44 m68040/fpsp/Makefile) -
c/src/lib/libcpu/shared/src/cache_manager.c
rf0b11d63 rcf1f72e 1 /* cache.c 2 * 1 /* 3 2 * Cache Manager 4 3 * … … 11 10 * 12 11 * 13 * The functions in this file definethe API to the RTEMS Cache Manager and12 * The functions in this file implement the API to the RTEMS Cache Manager and 14 13 * are divided into data cache and instruction cache functions. Data cache 15 14 * functions are only declared if a data cache is supported. Instruction … … 31 30 */ 32 31 33 #include <rtems /system.h>32 #include <rtems.h> 34 33 #include <sys/types.h> 35 #include < rtems/rtems/cache.h>36 37 38 /* 39 * THESE FUNCTIONS ONLY EXIST IF WE HAVE A DATA CACHE 40 * /41 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 34 #include <libcpu/cache.h> 35 #include "cache_.h" 36 37 38 /* 39 * THESE FUNCTIONS ONLY HAVE BODIES IF WE HAVE A DATA CACHE 40 */ 42 41 43 42 /* … … 49 48 rtems_flush_multiple_data_cache_lines( const void * d_addr, size_t n_bytes ) 50 49 { 51 const void * final_address; 52 /* 53 * Set d_addr to the beginning of the cache line; final_address indicates 54 * the last address_t which needs to be pushed. Increment d_addr and push 55 * the resulting line until final_address is passed. 56 */ 57 final_address = (void *)((size_t)d_addr + n_bytes - 1); 58 d_addr = (void *)((size_t)d_addr & ~(_CPU_DATA_CACHE_ALIGNMENT - 1)); 59 while( d_addr <= final_address ) { 60 _CPU_flush_1_data_cache_line( d_addr ); 61 d_addr = (void *)((size_t)d_addr + _CPU_DATA_CACHE_ALIGNMENT); 62 } 50 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 51 const void * final_address; 52 53 /* 54 * Set d_addr to the beginning of the cache line; final_address indicates 55 * the last address_t which needs to be pushed. Increment d_addr and push 56 * the resulting line until final_address is passed. 57 */ 58 59 final_address = (void *)((size_t)d_addr + n_bytes - 1); 60 d_addr = (void *)((size_t)d_addr & ~(_CPU_DATA_CACHE_ALIGNMENT - 1)); 61 while( d_addr <= final_address ) { 62 _CPU_flush_1_data_cache_line( d_addr ); 63 d_addr = (void *)((size_t)d_addr + _CPU_DATA_CACHE_ALIGNMENT); 64 } 65 #endif 63 66 } 64 67 … … 69 72 * perform the invalidations. 70 73 */ 74 71 75 void 72 76 rtems_invalidate_multiple_data_cache_lines( const void * d_addr, size_t n_bytes ) 73 77 { 74 const void * final_address; 75 /* 76 * Set d_addr to the beginning of the cache line; final_address indicates 77 * the last address_t which needs to be invalidated. Increment d_addr and 78 * invalidate the resulting line until final_address is passed. 79 */ 80 final_address = (void *)((size_t)d_addr + n_bytes - 1); 81 d_addr = (void *)((size_t)d_addr & ~(_CPU_DATA_CACHE_ALIGNMENT - 1)); 82 while( final_address > d_addr ) { 83 _CPU_invalidate_1_data_cache_line( d_addr ); 84 d_addr = (void *)((size_t)d_addr + _CPU_DATA_CACHE_ALIGNMENT); 85 } 78 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 79 const void * final_address; 80 81 /* 82 * Set d_addr to the beginning of the cache line; final_address indicates 83 * the last address_t which needs to be invalidated. Increment d_addr and 84 * invalidate the resulting line until final_address is passed. 85 */ 86 87 final_address = (void *)((size_t)d_addr + n_bytes - 1); 88 d_addr = (void *)((size_t)d_addr & ~(_CPU_DATA_CACHE_ALIGNMENT - 1)); 89 while( final_address > d_addr ) { 90 _CPU_invalidate_1_data_cache_line( d_addr ); 91 d_addr = (void *)((size_t)d_addr + _CPU_DATA_CACHE_ALIGNMENT); 92 } 93 #endif 86 94 } 87 95 … … 94 102 rtems_flush_entire_data_cache( void ) 95 103 { 104 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 96 105 /* 97 106 * Call the CPU-specific routine 98 107 */ 99 108 _CPU_flush_entire_data_cache(); 100 109 #endif 101 110 } 102 111 … … 109 118 rtems_invalidate_entire_data_cache( void ) 110 119 { 111 /* 112 * Call the CPU-specific routine 113 */ 114 _CPU_invalidate_entire_data_cache(); 120 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 121 /* 122 * Call the CPU-specific routine 123 */ 124 125 _CPU_invalidate_entire_data_cache(); 126 #endif 115 127 } 116 128 … … 122 134 rtems_get_data_cache_line_size( void ) 123 135 { 124 return _CPU_DATA_CACHE_ALIGNMENT; 136 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 137 return _CPU_DATA_CACHE_ALIGNMENT; 138 #else 139 return 0; 140 #endif 125 141 } 126 142 … … 133 149 rtems_freeze_data_cache( void ) 134 150 { 135 _CPU_freeze_data_cache(); 151 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 152 _CPU_freeze_data_cache(); 153 #endif 136 154 } 137 155 … … 142 160 void rtems_unfreeze_data_cache( void ) 143 161 { 144 _CPU_unfreeze_data_cache(); 162 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 163 _CPU_unfreeze_data_cache(); 164 #endif 145 165 } 146 166 … … 150 170 rtems_enable_data_cache( void ) 151 171 { 152 _CPU_enable_data_cache(); 172 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 173 _CPU_enable_data_cache(); 174 #endif 153 175 } 154 176 … … 158 180 rtems_disable_data_cache( void ) 159 181 { 160 _CPU_disable_data_cache(); 161 } 162 #endif 163 164 165 166 /* 167 * THESE FUNCTIONS ONLY EXIST IF WE HAVE AN INSTRUCTION CACHE 168 * /169 #if defined(_CPU_INST_CACHE_ALIGNMENT) 182 #if defined(_CPU_DATA_CACHE_ALIGNMENT) 183 _CPU_disable_data_cache(); 184 #endif 185 } 186 187 188 189 /* 190 * THESE FUNCTIONS ONLY HAVE BODIES IF WE HAVE AN INSTRUCTION CACHE 191 */ 170 192 171 193 /* … … 177 199 rtems_invalidate_multiple_inst_cache_lines( const void * i_addr, size_t n_bytes ) 178 200 { 179 const void * final_address; 180 /* 181 * Set i_addr to the beginning of the cache line; final_address indicates 182 * the last address_t which needs to be invalidated. Increment i_addr and 183 * invalidate the resulting line until final_address is passed. 184 */ 185 final_address = (void *)((size_t)i_addr + n_bytes - 1); 186 i_addr = (void *)((size_t)i_addr & ~(_CPU_INST_CACHE_ALIGNMENT - 1)); 187 while( final_address > i_addr ) { 188 _CPU_invalidate_1_inst_cache_line( i_addr ); 189 i_addr = (void *)((size_t)i_addr + _CPU_INST_CACHE_ALIGNMENT); 190 } 201 #if defined(_CPU_INST_CACHE_ALIGNMENT) 202 const void * final_address; 203 204 /* 205 * Set i_addr to the beginning of the cache line; final_address indicates 206 * the last address_t which needs to be invalidated. Increment i_addr and 207 * invalidate the resulting line until final_address is passed. 208 */ 209 210 final_address = (void *)((size_t)i_addr + n_bytes - 1); 211 i_addr = (void *)((size_t)i_addr & ~(_CPU_INST_CACHE_ALIGNMENT - 1)); 212 while( final_address > i_addr ) { 213 _CPU_invalidate_1_inst_cache_line( i_addr ); 214 i_addr = (void *)((size_t)i_addr + _CPU_INST_CACHE_ALIGNMENT); 215 } 216 #endif 191 217 } 192 218 … … 199 225 rtems_invalidate_entire_inst_cache( void ) 200 226 { 201 /* 202 * Call the CPU-specific routine 203 */ 204 _CPU_invalidate_entire_inst_cache(); 227 #if defined(_CPU_INST_CACHE_ALIGNMENT) 228 /* 229 * Call the CPU-specific routine 230 */ 231 232 _CPU_invalidate_entire_inst_cache(); 233 #endif 205 234 } 206 235 … … 212 241 rtems_get_inst_cache_line_size( void ) 213 242 { 214 return _CPU_INST_CACHE_ALIGNMENT; 243 #if defined(_CPU_INST_CACHE_ALIGNMENT) 244 return _CPU_INST_CACHE_ALIGNMENT; 245 #else 246 return 0; 247 #endif 215 248 } 216 249 … … 223 256 rtems_freeze_inst_cache( void ) 224 257 { 225 _CPU_freeze_inst_cache(); 258 #if defined(_CPU_INST_CACHE_ALIGNMENT) 259 _CPU_freeze_inst_cache(); 260 #endif 226 261 } 227 262 … … 232 267 void rtems_unfreeze_inst_cache( void ) 233 268 { 234 _CPU_unfreeze_inst_cache(); 269 #if defined(_CPU_INST_CACHE_ALIGNMENT) 270 _CPU_unfreeze_inst_cache(); 271 #endif 235 272 } 236 273 … … 240 277 rtems_enable_inst_cache( void ) 241 278 { 242 _CPU_enable_inst_cache(); 279 #if defined(_CPU_INST_CACHE_ALIGNMENT) 280 _CPU_enable_inst_cache(); 281 #endif 243 282 } 244 283 … … 248 287 rtems_disable_inst_cache( void ) 249 288 { 250 _CPU_disable_inst_cache(); 251 } 252 #endif 289 #if defined(_CPU_INST_CACHE_ALIGNMENT) 290 _CPU_disable_inst_cache(); 291 #endif 292 } -
c/src/tests/configure.in
rf0b11d63 rcf1f72e 45 45 if test "$tests_enabled" = "yes"; then 46 46 # do functionality tests first, then performance tests 47 cfg_subdirs="libtests sptests "47 cfg_subdirs="libtests sptests libffi" 48 48 if test "$HAS_MP" = "yes"; then 49 49 cfg_subdirs="$cfg_subdirs mptests" … … 68 68 AC_CONFIG_SUBDIRS(support) 69 69 AC_CONFIG_SUBDIRS(samples) 70 AC_CONFIG_SUBDIRS(libffi)71 70 AC_CONFIG_SUBDIRS($cfg_subdirs) 72 71 -
cpukit/libcsupport/src/malloc.c
rf0b11d63 rcf1f72e 420 420 } 421 421 422 423 /* 424 * rtems_cache_aligned_malloc 425 * 426 * DESCRIPTION: 427 * 428 * This function is used to allocate storage that spans an 429 * integral number of cache blocks. 430 */ 431 RTEMS_INLINE_ROUTINE void * rtems_cache_aligned_malloc ( 432 size_t nbytes 433 ) 434 { 435 /* 436 * Arrange to have the user storage start on the first cache 437 * block beyond the header. 438 */ 439 return (void *) ((((unsigned long) malloc( nbytes + _CPU_DATA_CACHE_ALIGNMENT - 1 )) 440 + _CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(_CPU_DATA_CACHE_ALIGNMENT - 1)) ); 441 } 442 443 #endif 444 422 #endif -
cpukit/rtems/include/rtems.h
rf0b11d63 rcf1f72e 43 43 #include <rtems/rtems/tasks.h> 44 44 #include <rtems/rtems/intr.h> 45 #include <rtems/rtems/cache.h> 45 46 #include <rtems/rtems/clock.h> 46 47 #include <rtems/extension.h> -
cpukit/rtems/src/Makefile.am
rf0b11d63 rcf1f72e 51 51 dpmemident.c dpmeminternal2external.c 52 52 53 STD_C_FILES = attr.c cache.c$(TASK_C_FILES) $(RATEMON_C_FILES) $(INTR_C_FILES) \53 STD_C_FILES = attr.c $(TASK_C_FILES) $(RATEMON_C_FILES) $(INTR_C_FILES) \ 54 54 $(CLOCK_C_FILES) $(TIMER_C_FILES) $(SEMAPHORE_C_FILES) \ 55 55 $(MESSAGE_QUEUE_C_FILES) $(EVENT_C_FILES) $(SIGNAL_C_FILES) \ -
cpukit/score/cpu/i386/rtems/score/i386.h
rf0b11d63 rcf1f72e 186 186 } 187 187 188 /*189 * Disable the entire cache190 */191 void _CPU_disable_cache() {192 cr0 regCr0;193 194 regCr0.i = i386_get_cr0();195 regCr0.cr0.page_level_cache_disable = 1;196 regCr0.cr0.no_write_through = 1;197 i386_set_cr0( regCr0.i );198 rtems_flush_entire_data_cache();199 }200 201 /*202 * Enable the entire cache203 */204 static inline void _CPU_enable_cache() {205 cr0 regCr0;206 207 regCr0.i = i386_get_cr0();208 regCr0.cr0.page_level_cache_disable = 0;209 regCr0.cr0.no_write_through = 0;210 i386_set_cr0( regCr0.i );211 /*rtems_flush_entire_data_cache();*/212 }213 214 /*215 * CACHE MANAGER: The following functions are CPU-specific.216 * They provide the basic implementation for the rtems_* cache217 * management routines. If a given function has no meaning for the CPU,218 * it does nothing by default.219 *220 * FIXME: Definitions for I386_CACHE_ALIGNMENT are missing above for221 * each CPU. The routines below should be implemented per CPU,222 * to accomodate the capabilities of each.223 */224 225 /* FIXME: I don't belong here. */226 #define I386_CACHE_ALIGNMENT 16227 228 #if defined(I386_CACHE_ALIGNMENT)229 #define _CPU_DATA_CACHE_ALIGNMENT I386_CACHE_ALIGNMENT230 #define _CPU_INST_CACHE_ALIGNEMNT I386_CACHE_ALIGNMENT231 232 static inline void _CPU_flush_1_data_cache_line (const void * d_addr) {}233 static inline void _CPU_invalidate_1_data_cache_line (const void * d_addr) {}234 static inline void _CPU_freeze_data_cache (void) {}235 static inline void _CPU_unfreeze_data_cache (void) {}236 static inline void _CPU_invalidate_1_inst_cache_line const void * d_addr() {}237 static inline void _CPU_freeze_inst_cache (void) {}238 static inline void _CPU_unfreeze_inst_cache (void) {}239 240 static inline void _CPU_flush_entire_data_cache (241 const void * d_addr )242 {243 asm ("wbinvd");244 }245 static inline void _CPU_invalidate_entire_data_cache (246 const void * d_addr )247 {248 asm ("invd");249 }250 251 static inline void _CPU_enable_data_cache (252 void )253 {254 _CPU_enable_cache();255 }256 257 static inline void _CPU_disable_data_cache (258 void )259 {260 _CPU_disable_cache();261 }262 263 static inline void _CPU_invalidate_entire_inst_cache (264 const void * i_addr )265 {266 asm ("invd");267 }268 269 static inline void _CPU_enable_inst_cache (270 void )271 {272 _CPU_enable_cache();273 }274 275 static inline void _CPU_disable_inst_cache (276 void )277 {278 _CPU_disable_cache();279 }280 #endif281 282 283 188 /* routines */ 284 189 -
cpukit/score/cpu/m68k/rtems/score/m68k.h
rf0b11d63 rcf1f72e 374 374 375 375 376 /*377 * Since the cacr is common to all mc680x0, provide macros378 * for masking values in that register.379 */380 381 /*382 * Used to clear bits in the cacr.383 */384 #define _CPU_CACR_AND(mask) \385 { \386 register unsigned long _value = mask; \387 register unsigned long _ctl = 0; \388 asm volatile ( "movec %%cacr, %0; /* read the cacr */ \389 andl %2, %0; /* and with _val */ \390 movec %1, %%cacr" /* write the cacr */ \391 : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" ); \392 }393 394 395 /*396 * Used to set bits in the cacr.397 */398 #define _CPU_CACR_OR(mask) \399 { \400 register unsigned long _value = mask; \401 register unsigned long _ctl = 0; \402 asm volatile ( "movec %%cacr, %0; /* read the cacr */ \403 orl %2, %0; /* or with _val */ \404 movec %1, %%cacr" /* write the cacr */ \405 : "=d" (_ctl) : "0" (_ctl), "d" (_value) : "%%cc" ); \406 }407 408 409 /*410 * CACHE MANAGER: The following functions are CPU-specific.411 * They provide the basic implementation for the rtems_* cache412 * management routines. If a given function has no meaning for the CPU,413 * it does nothing by default.414 */415 #if ( defined(__mc68020__) || defined(__mc68030__) )416 #define M68K_INST_CACHE_ALIGNMENT 16417 418 #if defined(__mc68030__)419 #define M68K_DATA_CACHE_ALIGNMENT 16420 421 /* Only the mc68030 has a data cache; it is writethrough only. */422 423 static inline void _CPU_flush_1_data_cache_line ( const void * d_addr ) {}424 static inline void _CPU_flush_entire_data_cache ( const void * d_addr ) {}425 426 static inline void _CPU_invalidate_1_data_cache_line (427 const void * d_addr )428 {429 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );430 asm volatile ( "movec %0, %%caar" :: "a" (p_address) ); /* write caar */431 _CPU_CACR_OR(0x00000400);432 }433 434 static inline void _CPU_invalidate_entire_data_cache (435 void )436 {437 _CPU_CACR_OR( 0x00000800 );438 }439 440 static inline void _CPU_freeze_data_cache (441 void )442 {443 _CPU_CACR_OR( 0x00000200 );444 }445 446 static inline void _CPU_unfreeze_data_cache (447 void )448 {449 _CPU_CACR_AND( 0xFFFFFDFF );450 }451 452 static inline void _CPU_enable_data_cache ( void )453 {454 _CPU_CACR_OR( 0x00000100 );455 }456 static inline void _CPU_disable_data_cache ( void )457 {458 _CPU_CACR_AND( 0xFFFFFEFF );459 }460 #endif461 462 463 /* Both the 68020 and 68030 have instruction caches */464 465 static inline void _CPU_invalidate_1_inst_cache_line (466 const void * d_addr )467 {468 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );469 asm volatile ( "movec %0, %%caar" :: "a" (p_address) ); /* write caar */470 _CPU_CACR_OR( 0x00000004 );471 }472 473 static inline void _CPU_invalidate_entire_inst_cache (474 void )475 {476 _CPU_CACR_OR( 0x00000008 );477 }478 479 static inline void _CPU_freeze_inst_cache (480 void )481 {482 _CPU_CACR_OR( 0x00000002);483 }484 485 static inline void _CPU_unfreeze_inst_cache (486 void )487 {488 _CPU_CACR_AND( 0xFFFFFFFD );489 }490 491 static inline void _CPU_enable_inst_cache ( void )492 {493 _CPU_CACR_OR( 0x00000001 );494 }495 496 static inline void _CPU_disable_inst_cache ( void )497 {498 _CPU_CACR_AND( 0xFFFFFFFE );499 }500 501 502 #elif ( defined(__mc68040__) || defined (__mc68060__) )503 504 #define M68K_INST_CACHE_ALIGNMENT 16505 #define M68K_DATA_CACHE_ALIGNMENT 16506 507 /* Cannot be frozen */508 static inline void _CPU_freeze_data_cache ( void ) {}509 static inline void _CPU_unfreeze_data_cache ( void ) {}510 static inline void _CPU_freeze_inst_cache ( void ) {}511 static inline void _CPU_unfreeze_inst_cache ( void ) {}512 513 static inline void _CPU_flush_1_data_cache_line (514 const void * d_addr )515 {516 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );517 asm volatile ( "cpushl %%dc,(%0)" :: "a" (p_address) );518 }519 520 static inline void _CPU_invalidate_1_data_cache_line (521 const void * d_addr )522 {523 void * p_address = (void *) _CPU_virtual_to_physical( d_addr );524 asm volatile ( "cinvl %%dc,(%0)" :: "a" (p_address) );525 }526 527 static inline void _CPU_flush_entire_data_cache (528 void )529 {530 asm volatile ( "cpusha %%dc" :: );531 }532 533 static inline void _CPU_invalidate_entire_data_cache (534 void )535 {536 asm volatile ( "cinva %%dc" :: );537 }538 539 static inline void _CPU_enable_data_cache (540 void )541 {542 _CPU_CACR_OR( 0x80000000 );543 }544 545 static inline void _CPU_disable_data_cache (546 void )547 {548 _CPU_CACR_AND( 0x7FFFFFFF );549 }550 551 static inline void _CPU_invalidate_1_inst_cache_line (552 const void * i_addr )553 {554 void * p_address = (void *) _CPU_virtual_to_physical( i_addr );555 asm volatile ( "cinvl %%ic,(%0)" :: "a" (p_address) );556 }557 558 static inline void _CPU_invalidate_entire_inst_cache (559 void )560 {561 asm volatile ( "cinva %%ic" :: );562 }563 564 static inline void _CPU_enable_inst_cache (565 void )566 {567 _CPU_CACR_OR( 0x00008000 );568 }569 570 static inline void _CPU_disable_inst_cache (571 void )572 {573 _CPU_CACR_AND( 0xFFFF7FFF );574 }575 #endif576 577 578 #if defined(M68K_DATA_CACHE_ALIGNMENT)579 #define _CPU_DATA_CACHE_ALIGNMENT M68K_DATA_CACHE_ALIGNMENT580 #endif581 582 #if defined(M68K_INST_CACHE_ALIGNMENT)583 #define _CPU_INST_CACHE_ALIGNMENT M68K_INST_CACHE_ALIGNMENT584 #endif585 586 587 376 #endif /* !ASM */ 588 377
Note: See TracChangeset
for help on using the changeset viewer.