Advertisement
mindrunner

Untitled

Apr 3rd, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. int nandRead(int cl, int al, char *buf, int count) {
  2.     unsigned int cmds[count];
  3.  
  4.     int x, i, ret;
  5.     i = count;
  6.     ret = 0;
  7.     cmds[0] = cl;
  8.     printf("Cmd:\n");
  9.     for (x = 0; x < i; x++)
  10.         printf("%x %s", cmds[x], ((x & 15) == 15) ? "\n" : "");
  11.     printf("\n\n");
  12.  
  13.     if (!nanddmaw_busy_read()) {
  14.         printf("writing %d bytes\n", count);
  15.         nanddmaw_reset_write(1);
  16.         nanddmaw_base_write((unsigned int)cmds);
  17.         nanddmaw_length_write(count);
  18.         nanddmaw_shoot_write(1);
  19.     } else {
  20.         printf("DMA busy :(\n");
  21.         return -4;
  22.     }
  23.  
  24.     flush_l2_cache();
  25.  
  26.     for (x = 0; x < count; x++)
  27.         buf[x] = cmds[x];
  28.  
  29.     printf("Buf:\n");
  30.     for (x = 0; x < count; x++)
  31.         printf("%x %s", buf[x], ((x & 15) == 15) ? "\n" : "");
  32.     printf("\n\n");
  33.     return ret;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement