Guest User

Untitled

a guest
May 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int has_elapsed (int, int, int, int);
  7. void clock_get_system_microtime(int& , int&); // known
  8. int Bit1_Set_Timer (int);
  9. int Bit2_Set_Timer (int);
  10. int Bit3_Set_Timer (int);
  11. int Bit3_6_Set_Timer (int);
  12. int sub_1801692E(int,uint16_t); // pending
  13. int sub_18016A14(uint32_t,int,uint16_t) //pending
  14.  
  15. // function - has_elapsed
  16. int has_elapsed (int stime, int sstep, int etimer, int estep) {
  17.  
  18. int new_time, new_step;
  19.  
  20. clock_get_system_microtime (new_time,new_step);
  21. new_step = new_step - estep;
  22. if (new_tep < 0) || ((new_step == 0) && (new_time - stime) < etimer)))
  23. {return 0;}
  24. else
  25. {return (1);}
  26. }
  27.  
  28.  
  29. // function - Bit1_Set_Timer
  30. int Bit1_Set_Timer (int Timer) {
  31.  
  32. int start_time, start_step, elapsed_timer;
  33. bool bit_set = true;
  34. unsigned int Unit = 1000;
  35. uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
  36. int elapsed_timer = Timer*Unit;
  37.  
  38. if ((*mmio_38A00048 & 1) != 0) // bit1 is set
  39. {return 0;}
  40. else {
  41. clock_get_system_microtime (start_time,start_step); // known function
  42. while ((*mmio_38A00048 & 1) == 0) {
  43. if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
  44. {bit_set = false; // Timeout or Stepout
  45. break;}
  46. }
  47. if (bit_set == true)
  48. {return 0;}
  49. else {return (31);}
  50. }
  51. }
  52.  
  53.  
  54. // function - Bit2_Set_Timer
  55. int Bit2_Set_Timer (int Timer) {
  56.  
  57. int start_time, start_step, elapsed_timer;
  58. bool bit_set = true;
  59. unsigned int Unit = 1000;
  60. uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
  61. int elapsed_timer = Timer*Unit;
  62.  
  63. if ((*mmio_38A00048 & 4) != 0) // bit2 is set
  64. {*mmio_38A00048 = 4;
  65. return 0;}
  66. else {
  67. clock_get_system_microtime (start_time,start_step); // known function
  68. while ((*mmio_38A00048 & 1) == 0) {
  69. if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
  70. {bit_set = false; // Timeout or Stepout
  71. break;}
  72. }
  73. if (bit_set == true)
  74. {*mmio_38A00048 = 4;
  75. return 0;}
  76. else {return (31);}
  77. }
  78. }
  79.  
  80. // function - Bit3_Set_Timer
  81. int Bit3_Set_Timer (int Timer) {
  82.  
  83. int start_time, start_step, elapsed_timer, ret_6A14;
  84. bool bit_set = true;
  85. unsigned int Unit = 1000;
  86. uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
  87. int elapsed_timer = Timer*Unit;
  88.  
  89. if ((*mmio_38A00048 & 8) != 0) // bit3 is set
  90. {*mmio_38A00048 = 8;
  91. return 0;}
  92. else {
  93. clock_get_system_microtime (start_time,start_step); // known function
  94. while ((*mmio_38A00048 & 1) == 0) {
  95. if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
  96. {bit_set = false; // Timeout or Stepout
  97. break;}
  98. }
  99. if (bit_set == true)
  100. {*mmio_38A00048 = 8;
  101. return 0;}
  102. else {return (31);}
  103. }
  104. }
  105.  
  106. // function - Bit3_6_Set_Timer
  107. int Bit3_6_Set_Timer(int arg0) {
  108.  
  109. int start_time, start_step, elapsed_timer, bit_set;
  110. bool bit_set = true;
  111. unsigned int Unit = 1000;
  112. uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
  113. uint32_t *mmio_38A00080 = (uint32_t*)0x38A00080;
  114.  
  115. part_1 = ((*byte_1802185E++ & Seven) << 16) | ((*byte_1802185E & Seven) << 12);
  116. *mmio_38A00000 = (1 << ((struct_180253C4_fieldx + 1))| part_1 | ORR_801);
  117.  
  118. if (*mmio_38A00048 & (1 << (arg0+4)) == 0) { // bit (arg0+4) is set?
  119. *mmio_38A00048 = 1 << (arg0+4);
  120. }
  121. *mmio_38A00004 = 192;
  122. *mmio_38A00008 = 112;
  123. bit_set = Bit1_Set_Timer(Timer_index);
  124. clock_get_system_microtime (start_time,start_step);
  125. while bit_set == true
  126. {
  127. *mmio_38A00030 = 0;
  128. *mmio_38A00004 = 2;
  129. if (Bit3_Set_Timer(Timer_index) != 0)
  130. {return (31);}
  131. else {
  132. *mmio_38A00004 = 128;
  133. if (*mmio_38A00080 & 64) == 0) { // bit 6 is set?
  134. *mmio_38A00008 = 0;
  135. bit_set = Bit1_Set_Timer(Timer_index);
  136. return(bit_set);
  137. }
  138. else {
  139. if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
  140. {bit_set = false; // Timeout or Stepout
  141. return(31);}
  142. }
  143.  
  144. }
  145. }
  146. }
  147.  
  148. _FTL_Read_Sub_18016FE0 (arg0, arg1, arg2, arg3, arg4, arg5) {
  149.  
  150. unsigned int Timer_index = 500;
  151.  
  152. uint8_t *byte_1802185E = (uint8_t*)0x1802185E; // assume typedef is done for data type
  153.  
  154. uint32_t *mmio_38A00000 = (uint32_t*)0x38A00000;
  155. uint32_t *mmio_38A00004 = (uint32_t*)0x38A00004;
  156. uint32_t *mmio_38A00008 = (uint32_t*)0x38A00008;
  157. uint32_t *mmio_38A0000C = (uint32_t*)0x38A0000C;
  158. uint32_t *mmio_38A00010 = (uint32_t*)0x38A00010;
  159. uint32_t *mmio_38A0002C = (uint32_t*)0x38A0002C;
  160. uint32_t *mmio_38A00030 = (uint32_t*)0x38A00030;
  161.  
  162.  
  163. *byte_1802185E = 0x07;
  164. *byte_1802185E++ = 0x07;
  165. const unsigned char Seven = 0x07;
  166. uint32_t ORR_801 = 0x801;
  167.  
  168. tNANData *pNandata = &NANData;
  169.  
  170. if ((arg0 < pNandata->BANKS_TOTAL && arg1 < pNANdata->PAGES_PERBANK ) && (arg2 != 0 || arg3 != 0 ))
  171. { part_1 = ((*byte_1802185E++ & Seven) << 16) | ((*byte_1802185E & Seven) << 12); // part_1 seems to be 0x77000
  172.  
  173. switch (arg0) { // don't how else to represent it
  174. case 0:
  175. struct_180253C4_fieldx = struct_180253C4.field_0;
  176. break;
  177. case 1:
  178. struct_180253C4_fieldx = struct_180253C4.field_1;
  179. break;
  180. case 2:
  181. struct_180253C4_fieldx = struct_180253C4.field_2;
  182. break;
  183. case 3:
  184. struct_180253C4_fieldx = struct_180253C4.field_3;
  185. break;
  186. case 4:
  187. struct_180253C4_fieldx = struct_180253C4.field_4;
  188. break;
  189. default: }
  190.  
  191. *mmio_38A00000 = (1 << ((struct_180253C4_fieldx + 1))| part_1 | ORR_801);
  192. if (arg2 == 0) {SUB_7116();}
  193. else
  194. {*mmio_38A00008 = 0;
  195. if (Bit1_Set_Timer(Timer_index) == 0) // function @ 18016850
  196. {*mmio_38A0002C = 4;
  197. *mmio_38A0000C = arg1 << 16;
  198. *mmio_38A00010 = arg1 >> 16;
  199. *mmio_38A00004 = 1;
  200. if (Bit2_Set_Timer(Timer_index) == 0)
  201. {*mmio_38A00008 = 48;
  202. if (Bit1_Set_Timer(Timer_index) == 0)
  203. {if (Bit3_6_Set_Timer(arg0) == 0)
  204. {if (sub_692E(arg2,pNANData->field1E) ==0)
  205. {if (sub_1801692E(struct_180254E0.field_0,pNANData->BYTES_PER_SPARE) ==0)
  206. {if (arg4!=0)
  207. {ret_6A14 = sub_18016A14(struct_18025580.field_0,arg2,pNANData->PAGES_PER_BANK);
  208. memcpy(
  209. }
  210. else
  211. { loc_180171C8 ;}
  212.  
  213.  
  214. }
  215. else {sub_TimeOut();}
  216. }
  217. else {sub_TimeOut();}
  218. }
  219. else {sub_TimeOut();}
  220. }
  221. else {sub_TimeOut();}
  222. }
  223. else {sub_TimeOut()};
  224. }
  225. else {sub_TimeOut()};
  226.  
  227. }
  228. }
  229. else {SUB_7220();}
  230.  
  231. return 0;
Add Comment
Please, Sign In to add comment