aboutsummaryrefslogtreecommitdiff
path: root/tools/smmu_payload.py
blob: 8961b251992139dbd5f8af1a6356a92ff06fab68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
Copyright (c) 2018 balika011

This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.

This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

from keystone import *

CODE = b'''
	LDR	X1, =0x70019010
	MOV X0, #0x1
	STR W0, [X1]

loop:
	IC	IALLUIS
	DSB ISH
	B loop
	MOV X0, #0x0
	STR W0, [X1]
	LDR	X0, =0x4002B000
	BR	X0
'''
try:
	ks = Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN)
	encoding, count = ks.asm(CODE, 0x0)
	print("%s = %s (number of statements: %u)" %(CODE, ', '.join([('0x%02x' % (x)) for x in encoding]), count))
except KsError as e:
	print("ERROR: %s" %e)