Instantly share code, notes, and snippets.

@xyzz /challenge.txt Secret
Created Oct 28, 2018

Embed
What would you like to do?
ROM:510147C8 get_cpu_aff
ROM:510147C8 MRC p15, 0, R0,c0,c0, 5
ROM:510147CC AND.W R0, R0, #0xF
ROM:510147D0 BX LR
ROM:510147D0 ; End of function get_cpu_aff
ROM:51014810 wait_field0_zero_and_set_field0
ROM:51014810 LDREX.W R1, [R0]
ROM:51014814 CBNZ R1, loc_51014822
ROM:51014816 STREX.W R1, LR, [R0]
ROM:5101481A CBNZ R1, loc_51014824
ROM:5101481C DMB.W SY
ROM:51014820 BX LR
ROM:51014822 ; ---------------------------------------------------------------------------
ROM:51014822
ROM:51014822 loc_51014822
ROM:51014822 WFE
ROM:51014824
ROM:51014824 loc_51014824
ROM:51014824 B wait_field0_zero_and_set_field0
ROM:51014824 ; End of function wait_field0_zero_and_set_field0
ROM:510145F4 atomic_dec
ROM:510145F4 DMB SY
ROM:510145F8
ROM:510145F8 loc_510145F8
ROM:510145F8 LDREXH R2, [R0]
ROM:510145FC SUB R3, R2, R1
ROM:51014600 STREXH R12, R3, [R0]
ROM:51014604 TEQ R12, #0
ROM:51014608 BNE loc_510145F8
ROM:5101460C DMB SY
ROM:51014610 SXTH R0, R2
ROM:51014614 BX LR
ROM:51014614 ; End of function atomic_dec
ROM:51014828 zero_field0
ROM:51014828 MOVS R1, #0
ROM:5101482A DMB.W SY
ROM:5101482E STR R1, [R0]
ROM:51014830 DSB.W SY
ROM:51014834 SEV
ROM:51014836 BX LR
ROM:51014836 ; End of function zero_field0
ROM:5101490C cpu_barrier_start
ROM:5101490C PUSH {R3-R5,LR}
ROM:5101490E MOV R4, R0
ROM:51014910 MOV R5, R1
ROM:51014912 BL get_cpu_aff
ROM:51014916 DMB.W SY
ROM:5101491A CMP R0, R5
ROM:5101491C BEQ loc_5101493C
ROM:5101491E LDRH R3, [R4,#6]
ROM:51014920 SXTH R2, R0
ROM:51014922 ADDS R1, R4, #6
ROM:51014924 SXTH R3, R3
ROM:51014926 CMP R2, R3
ROM:51014928 BEQ loc_51014934
ROM:5101492A
ROM:5101492A loc_5101492A
ROM:5101492A WFE
ROM:5101492C LDRH R3, [R1]
ROM:5101492E SXTH R3, R3
ROM:51014930 CMP R3, R2
ROM:51014932 BNE loc_5101492A
ROM:51014934
ROM:51014934 loc_51014934
ROM:51014934 MOV R0, R4
ROM:51014936 BL wait_field0_zero_and_set_field0
ROM:5101493A POP {R3-R5,PC}
ROM:5101493C ; ---------------------------------------------------------------------------
ROM:5101493C
ROM:5101493C loc_5101493C
ROM:5101493C STRH R0, [R4,#6]
ROM:5101493E POP {R3-R5,PC}
ROM:5101493E ; End of function cpu_barrier_start
ROM:51014940 cpu_barrier_end
ROM:51014940 PUSH {R4-R6,LR}
ROM:51014942 MOV R5, R0
ROM:51014944 BL get_cpu_aff
ROM:51014948 ADDS R0, #1
ROM:5101494A CMP R0, #4
ROM:5101494C ITE NE
ROM:5101494E UXTHNE R0, R0
ROM:51014950 MOVEQ R0, #0
ROM:51014952 DMB.W SY
ROM:51014956 ADDS R4, R5, #4
ROM:51014958 STRH R0, [R5,#6]
ROM:5101495A MOVS R1, #1
ROM:5101495C MOV R0, R4
ROM:5101495E BLX atomic_dec
ROM:51014962 MOV R6, R0
ROM:51014964 MOV R0, R5
ROM:51014966 BL zero_field0
ROM:5101496A DSB.W SY
ROM:5101496E SEV
ROM:51014970 CMP R6, #4
ROM:51014972 LDRH R3, [R5,#4]
ROM:51014974 BEQ loc_51014988
ROM:51014976 CMP R3, #4
ROM:51014978 BEQ locret_510149A0
ROM:5101497A
ROM:5101497A loc_5101497A
ROM:5101497A WFE
ROM:5101497C LDRH R3, [R4]
ROM:5101497E CMP R3, #4
ROM:51014980 BNE loc_5101497A
ROM:51014982 POP {R4-R6,PC}
ROM:51014984 ; ---------------------------------------------------------------------------
ROM:51014984
ROM:51014984 loc_51014984
ROM:51014984 WFE
ROM:51014986 LDRH R3, [R4]
ROM:51014988
ROM:51014988 loc_51014988
ROM:51014988 SXTH R3, R3
ROM:5101498A CMP R3, #0
ROM:5101498C BGT loc_51014984
ROM:5101498E MOVS R3, #4
ROM:51014990 MOVS R2, #1
ROM:51014992 STR R2, [R5]
ROM:51014994 STRH R3, [R5,#4]
ROM:51014996 STRH R3, [R5,#6]
ROM:51014998 DSB.W SY
ROM:5101499C SEV
ROM:5101499E POP {R4-R6,PC}
ROM:510149A0 ; ---------------------------------------------------------------------------
ROM:510149A0
ROM:510149A0 locret_510149A0
ROM:510149A0 POP {R4-R6,PC}
ROM:510149A0 ; End of function cpu_barrier_end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment