Mercurial > ecos
comparison packages/kernel/current/tests/kcache2.c @ 199:920b9b754b53
Merge from eCos master repository on 2001-12-15-12:00:33-GMT
| author | jlarmour |
|---|---|
| date | Sat, 15 Dec 2001 13:42:19 +0000 |
| parents | 67850532eebb |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 198:ea3f0bd33a73 | 199:920b9b754b53 |
|---|---|
| 560 // ------------------------------------------------------------------------- | 560 // ------------------------------------------------------------------------- |
| 561 // Test of instruction cache locking. | 561 // Test of instruction cache locking. |
| 562 // o Time difference between repeatedly executing a bunch of instructions | 562 // o Time difference between repeatedly executing a bunch of instructions |
| 563 // with and without locking. | 563 // with and without locking. |
| 564 #ifdef HAL_ICACHE_LOCK | 564 #ifdef HAL_ICACHE_LOCK |
| 565 static void iloop(unsigned long* start, unsigned long* end) | 565 static void iloop(unsigned long* start, unsigned long* end, int dummy) |
| 566 { | 566 { |
| 567 // dummy is just used to fool the compiler to not move the labels | |
| 568 // around. All callers should call with dummy=0; | |
| 569 | |
| 567 register char c; | 570 register char c; |
| 568 register CYG_INTERRUPT_STATE oldints; | 571 register CYG_INTERRUPT_STATE oldints; |
| 572 | |
| 573 if (1 == dummy) goto label_end; | |
| 569 | 574 |
| 570 label_start: | 575 label_start: |
| 571 // Invalidating shouldn't affect locked lines. | 576 // Invalidating shouldn't affect locked lines. |
| 572 HAL_DISABLE_INTERRUPTS(oldints); | 577 HAL_DISABLE_INTERRUPTS(oldints); |
| 573 HAL_ICACHE_DISABLE(); | 578 HAL_ICACHE_DISABLE(); |
| 642 | 647 |
| 643 label_end: | 648 label_end: |
| 644 | 649 |
| 645 *start = (unsigned long) &&label_start; | 650 *start = (unsigned long) &&label_start; |
| 646 *end = (unsigned long) &&label_end; | 651 *end = (unsigned long) &&label_end; |
| 652 | |
| 653 if (1 == dummy) goto label_start; | |
| 647 } | 654 } |
| 648 | 655 |
| 649 static void time_ilock(void) | 656 static void time_ilock(void) |
| 650 { | 657 { |
| 651 register cyg_ucount32 k; | 658 register cyg_ucount32 k; |
| 659 if (cyg_test_is_simulator) | 666 if (cyg_test_is_simulator) |
| 660 time_ilock_loops = 10; | 667 time_ilock_loops = 10; |
| 661 | 668 |
| 662 count0 = cyg_current_time(); | 669 count0 = cyg_current_time(); |
| 663 for (k = 0; k < time_ilock_loops; k++) { | 670 for (k = 0; k < time_ilock_loops; k++) { |
| 664 iloop(&start, &end); | 671 iloop(&start, &end, 0); |
| 665 } | 672 } |
| 666 count1 = cyg_current_time(); | 673 count1 = cyg_current_time(); |
| 667 t = count1 - count0; | 674 t = count1 - count0; |
| 668 diag_printf("time without lock: %d\n", t); | 675 diag_printf("time without lock: %d\n", t); |
| 669 | 676 |
| 670 HAL_ICACHE_LOCK(start, end-start); | 677 HAL_ICACHE_LOCK(start, end-start); |
| 671 | 678 |
| 672 count0 = cyg_current_time(); | 679 count0 = cyg_current_time(); |
| 673 for (k = 0; k < time_ilock_loops; k++) { | 680 for (k = 0; k < time_ilock_loops; k++) { |
| 674 iloop(&start, &end); | 681 iloop(&start, &end, 0); |
| 675 } | 682 } |
| 676 count1 = cyg_current_time(); | 683 count1 = cyg_current_time(); |
| 677 t = count1 - count0; | 684 t = count1 - count0; |
| 678 diag_printf("time with lock: %d\n", t); | 685 diag_printf("time with lock: %d\n", t); |
| 679 | 686 |
