Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <string.h>
- int has_elapsed (int, int, int, int);
- void clock_get_system_microtime(int& , int&); // known
- int Bit1_Set_Timer (int);
- int Bit2_Set_Timer (int);
- int Bit3_Set_Timer (int);
- int Bit3_6_Set_Timer (int);
- int sub_1801692E(int,uint16_t); // pending
- int sub_18016A14(uint32_t,int,uint16_t) //pending
- // function - has_elapsed
- int has_elapsed (int stime, int sstep, int etimer, int estep) {
- int new_time, new_step;
- clock_get_system_microtime (new_time,new_step);
- new_step = new_step - estep;
- if (new_tep < 0) || ((new_step == 0) && (new_time - stime) < etimer)))
- {return 0;}
- else
- {return (1);}
- }
- // function - Bit1_Set_Timer
- int Bit1_Set_Timer (int Timer) {
- int start_time, start_step, elapsed_timer;
- bool bit_set = true;
- unsigned int Unit = 1000;
- uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
- int elapsed_timer = Timer*Unit;
- if ((*mmio_38A00048 & 1) != 0) // bit1 is set
- {return 0;}
- else {
- clock_get_system_microtime (start_time,start_step); // known function
- while ((*mmio_38A00048 & 1) == 0) {
- if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
- {bit_set = false; // Timeout or Stepout
- break;}
- }
- if (bit_set == true)
- {return 0;}
- else {return (31);}
- }
- }
- // function - Bit2_Set_Timer
- int Bit2_Set_Timer (int Timer) {
- int start_time, start_step, elapsed_timer;
- bool bit_set = true;
- unsigned int Unit = 1000;
- uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
- int elapsed_timer = Timer*Unit;
- if ((*mmio_38A00048 & 4) != 0) // bit2 is set
- {*mmio_38A00048 = 4;
- return 0;}
- else {
- clock_get_system_microtime (start_time,start_step); // known function
- while ((*mmio_38A00048 & 1) == 0) {
- if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
- {bit_set = false; // Timeout or Stepout
- break;}
- }
- if (bit_set == true)
- {*mmio_38A00048 = 4;
- return 0;}
- else {return (31);}
- }
- }
- // function - Bit3_Set_Timer
- int Bit3_Set_Timer (int Timer) {
- int start_time, start_step, elapsed_timer, ret_6A14;
- bool bit_set = true;
- unsigned int Unit = 1000;
- uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
- int elapsed_timer = Timer*Unit;
- if ((*mmio_38A00048 & 8) != 0) // bit3 is set
- {*mmio_38A00048 = 8;
- return 0;}
- else {
- clock_get_system_microtime (start_time,start_step); // known function
- while ((*mmio_38A00048 & 1) == 0) {
- if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
- {bit_set = false; // Timeout or Stepout
- break;}
- }
- if (bit_set == true)
- {*mmio_38A00048 = 8;
- return 0;}
- else {return (31);}
- }
- }
- // function - Bit3_6_Set_Timer
- int Bit3_6_Set_Timer(int arg0) {
- int start_time, start_step, elapsed_timer, bit_set;
- bool bit_set = true;
- unsigned int Unit = 1000;
- uint32_t *mmio_38A00048 = (uint32_t*)0x38A00048;
- uint32_t *mmio_38A00080 = (uint32_t*)0x38A00080;
- part_1 = ((*byte_1802185E++ & Seven) << 16) | ((*byte_1802185E & Seven) << 12);
- *mmio_38A00000 = (1 << ((struct_180253C4_fieldx + 1))| part_1 | ORR_801);
- if (*mmio_38A00048 & (1 << (arg0+4)) == 0) { // bit (arg0+4) is set?
- *mmio_38A00048 = 1 << (arg0+4);
- }
- *mmio_38A00004 = 192;
- *mmio_38A00008 = 112;
- bit_set = Bit1_Set_Timer(Timer_index);
- clock_get_system_microtime (start_time,start_step);
- while bit_set == true
- {
- *mmio_38A00030 = 0;
- *mmio_38A00004 = 2;
- if (Bit3_Set_Timer(Timer_index) != 0)
- {return (31);}
- else {
- *mmio_38A00004 = 128;
- if (*mmio_38A00080 & 64) == 0) { // bit 6 is set?
- *mmio_38A00008 = 0;
- bit_set = Bit1_Set_Timer(Timer_index);
- return(bit_set);
- }
- else {
- if (has_elapsed (start_time, start_step, elapsed_timer, 0) != 0)
- {bit_set = false; // Timeout or Stepout
- return(31);}
- }
- }
- }
- }
- _FTL_Read_Sub_18016FE0 (arg0, arg1, arg2, arg3, arg4, arg5) {
- unsigned int Timer_index = 500;
- uint8_t *byte_1802185E = (uint8_t*)0x1802185E; // assume typedef is done for data type
- uint32_t *mmio_38A00000 = (uint32_t*)0x38A00000;
- uint32_t *mmio_38A00004 = (uint32_t*)0x38A00004;
- uint32_t *mmio_38A00008 = (uint32_t*)0x38A00008;
- uint32_t *mmio_38A0000C = (uint32_t*)0x38A0000C;
- uint32_t *mmio_38A00010 = (uint32_t*)0x38A00010;
- uint32_t *mmio_38A0002C = (uint32_t*)0x38A0002C;
- uint32_t *mmio_38A00030 = (uint32_t*)0x38A00030;
- *byte_1802185E = 0x07;
- *byte_1802185E++ = 0x07;
- const unsigned char Seven = 0x07;
- uint32_t ORR_801 = 0x801;
- tNANData *pNandata = &NANData;
- if ((arg0 < pNandata->BANKS_TOTAL && arg1 < pNANdata->PAGES_PERBANK ) && (arg2 != 0 || arg3 != 0 ))
- { part_1 = ((*byte_1802185E++ & Seven) << 16) | ((*byte_1802185E & Seven) << 12); // part_1 seems to be 0x77000
- switch (arg0) { // don't how else to represent it
- case 0:
- struct_180253C4_fieldx = struct_180253C4.field_0;
- break;
- case 1:
- struct_180253C4_fieldx = struct_180253C4.field_1;
- break;
- case 2:
- struct_180253C4_fieldx = struct_180253C4.field_2;
- break;
- case 3:
- struct_180253C4_fieldx = struct_180253C4.field_3;
- break;
- case 4:
- struct_180253C4_fieldx = struct_180253C4.field_4;
- break;
- default: }
- *mmio_38A00000 = (1 << ((struct_180253C4_fieldx + 1))| part_1 | ORR_801);
- if (arg2 == 0) {SUB_7116();}
- else
- {*mmio_38A00008 = 0;
- if (Bit1_Set_Timer(Timer_index) == 0) // function @ 18016850
- {*mmio_38A0002C = 4;
- *mmio_38A0000C = arg1 << 16;
- *mmio_38A00010 = arg1 >> 16;
- *mmio_38A00004 = 1;
- if (Bit2_Set_Timer(Timer_index) == 0)
- {*mmio_38A00008 = 48;
- if (Bit1_Set_Timer(Timer_index) == 0)
- {if (Bit3_6_Set_Timer(arg0) == 0)
- {if (sub_692E(arg2,pNANData->field1E) ==0)
- {if (sub_1801692E(struct_180254E0.field_0,pNANData->BYTES_PER_SPARE) ==0)
- {if (arg4!=0)
- {ret_6A14 = sub_18016A14(struct_18025580.field_0,arg2,pNANData->PAGES_PER_BANK);
- memcpy(
- }
- else
- { loc_180171C8 ;}
- }
- else {sub_TimeOut();}
- }
- else {sub_TimeOut();}
- }
- else {sub_TimeOut();}
- }
- else {sub_TimeOut();}
- }
- else {sub_TimeOut()};
- }
- else {sub_TimeOut()};
- }
- }
- else {SUB_7220();}
- return 0;
Add Comment
Please, Sign In to add comment