[191] | 1 | #include <stdio.h> |
---|
| 2 | |
---|
[254] | 3 | #define NBLOCKS 32 // number of blocks per image (128 * 128) / 512 |
---|
[191] | 4 | |
---|
[254] | 5 | unsigned char buf0[128*128] __attribute__((aligned(64))); |
---|
| 6 | unsigned char buf1[128*128] __attribute__((aligned(64))); |
---|
[249] | 7 | |
---|
[191] | 8 | __attribute__((constructor)) int main(void) |
---|
| 9 | { |
---|
[218] | 10 | unsigned int x; |
---|
| 11 | unsigned int base = 0; |
---|
[207] | 12 | |
---|
[254] | 13 | /* initialise CDMA transfert (double buffer) */ |
---|
| 14 | |
---|
| 15 | giet_tty_printf( "*** Starting task DISPLAY_CMA on processor %d at cycle %d\n", |
---|
| 16 | giet_procid(), giet_proctime() ); |
---|
| 17 | giet_tty_printf( " - buf0 address (LSB) = %x\n", (unsigned int)buf0 ); |
---|
| 18 | giet_tty_printf( " - buf1 address (LSB) = %x\n", (unsigned int)buf1 ); |
---|
| 19 | |
---|
| 20 | x = giet_fb_cma_init( buf0, // buf0 base address |
---|
| 21 | buf1, // buf1 base address |
---|
| 22 | 128*128 ); // buffer size (bytes) |
---|
| 23 | giet_assert( (x==0), "echec giet_fb_cdma_init" ); |
---|
| 24 | |
---|
| 25 | while (base < 10 * NBLOCKS) |
---|
[191] | 26 | { |
---|
[254] | 27 | /* Phase 1 : transfer one image from disk to buf0 and display */ |
---|
[191] | 28 | |
---|
[254] | 29 | giet_tty_printf( "\n *** image %d *** at date = %d \n", |
---|
| 30 | (base/NBLOCKS), giet_proctime() ); |
---|
| 31 | |
---|
| 32 | x = giet_ioc_read( base, // lba on disk |
---|
| 33 | buf0, // user buffer address |
---|
| 34 | NBLOCKS ); // number of blocks |
---|
| 35 | giet_assert( (x==0) , "echec giet_ioc_read for buf0" ); |
---|
| 36 | |
---|
[191] | 37 | x = giet_ioc_completed(); |
---|
[254] | 38 | giet_assert( (x==0) , "echec giet_ioc_completed for buf0" ); |
---|
[191] | 39 | |
---|
[254] | 40 | giet_tty_printf( "ioc_read buf0 completed at date = %d \n", giet_proctime() ); |
---|
[207] | 41 | |
---|
[254] | 42 | x = giet_fb_cma_write( 0 ); // buf0 |
---|
| 43 | giet_assert( (x==0) , "echec giet_fb_cma_write for buf0" ); |
---|
| 44 | |
---|
| 45 | base = base + NBLOCKS; |
---|
[218] | 46 | |
---|
[254] | 47 | /* Phase 2 : transfer one image from disk to buf1 and display */ |
---|
[191] | 48 | |
---|
[254] | 49 | giet_tty_printf( "\n *** image %d *** at date = %d \n", |
---|
| 50 | (base/NBLOCKS), giet_proctime() ); |
---|
[191] | 51 | |
---|
[254] | 52 | x = giet_ioc_read( base, // lba on disk |
---|
| 53 | buf1, // user buffer address |
---|
| 54 | NBLOCKS ); // number of locks |
---|
| 55 | giet_assert( (x==0) , "echec giet_ioc_read for buf1"); |
---|
| 56 | |
---|
| 57 | x = giet_ioc_completed(); |
---|
| 58 | giet_assert( (x==0) , "echec giet_ioc_completed for buf1"); |
---|
| 59 | |
---|
| 60 | giet_tty_printf( "ioc_read buf1 completed at date = %d \n", giet_proctime() ); |
---|
| 61 | |
---|
| 62 | x = giet_fb_cma_write( 1 ); // buf1 |
---|
| 63 | giet_assert( (x==0) , "echec giet_fb_cma_write for buf1" ); |
---|
| 64 | |
---|
| 65 | base = base + NBLOCKS; |
---|
| 66 | } // end while |
---|
| 67 | |
---|
| 68 | giet_fb_cma_stop(); |
---|
[191] | 69 | giet_exit(); |
---|
| 70 | return 0; |
---|
| 71 | } |
---|