nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /*************************************************************************** |
2 | * * |
||
3 | * ########### ########### ########## ########## * |
||
4 | * ############ ############ ############ ############ * |
||
5 | * ## ## ## ## ## ## ## * |
||
6 | * ## ## ## ## ## ## ## * |
||
7 | * ########### #### ###### ## ## ## ## ###### * |
||
8 | * ########### #### # ## ## ## ## # # * |
||
9 | * ## ## ###### ## ## ## ## # # * |
||
10 | * ## ## # ## ## ## ## # # * |
||
11 | * ############ ##### ###### ## ## ## ##### ###### * |
||
12 | * ########### ########### ## ## ## ########## * |
||
13 | * * |
||
14 | * S E C U R E M O B I L E N E T W O R K I N G * |
||
15 | * * |
||
16 | * This file is part of NexMon. * |
||
17 | * * |
||
18 | * Copyright (c) 2016 NexMon Team * |
||
19 | * * |
||
20 | * NexMon is free software: you can redistribute it and/or modify * |
||
21 | * it under the terms of the GNU General Public License as published by * |
||
22 | * the Free Software Foundation, either version 3 of the License, or * |
||
23 | * (at your option) any later version. * |
||
24 | * * |
||
25 | * NexMon is distributed in the hope that it will be useful, * |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
28 | * GNU General Public License for more details. * |
||
29 | * * |
||
30 | * You should have received a copy of the GNU General Public License * |
||
31 | * along with NexMon. If not, see <http://www.gnu.org/licenses/>. * |
||
32 | * * |
||
33 | **************************************************************************/ |
||
34 | |||
35 | #define BLPatch(name, func) \ |
||
36 | __attribute__((naked)) void \ |
||
37 | bl_ ## name(void) { asm("bl " #func "\n"); } |
||
38 | |||
39 | #define BPatch(name, func) \ |
||
40 | __attribute__((naked)) void \ |
||
41 | b_ ## name(void) { asm("b " #func "\n"); } |
||
42 | |||
43 | #define HookPatch4(name, func, inst) \ |
||
44 | void b_ ## name(void); \ |
||
45 | __attribute__((naked)) void \ |
||
46 | hook_ ## name(void) \ |
||
47 | { \ |
||
48 | asm( \ |
||
49 | "push {r0-r3,lr}\n" \ |
||
50 | "bl " #func "\n" \ |
||
51 | "pop {r0-r3,lr}\n" \ |
||
52 | inst "\n" \ |
||
53 | "b b_" #name " + 4\n" \ |
||
54 | ); \ |
||
55 | } \ |
||
56 | __attribute__((naked)) void \ |
||
57 | b_ ## name(void) { asm("b hook_" #name "\n"); } |
||
58 | |||
59 | #define GenericPatch4(name, val) \ |
||
60 | unsigned int gp4_ ## name = (unsigned int) (val); |
||
61 | |||
62 | #define GenericPatch2(name, val) \ |
||
63 | unsigned short gp2_ ## name = (unsigned short) (val); |
||
64 | |||
65 | #define GenericPatch1(name, val) \ |
||
66 | unsigned char gp1_ ## name = (unsigned char) (val); |
||
67 | |||
68 | #define StringPatch(name, val) \ |
||
69 | __attribute__((naked)) \ |
||
70 | void str_ ## name(void) { asm(".ascii \"" val "\"\n.byte 0x00"); } |
||
71 | |||
72 | #define Dummy(name) \ |
||
73 | void dummy_ ## name(void) { ; } |