forked from isogashii/fernly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd-irq.c
61 lines (49 loc) · 1.03 KB
/
cmd-irq.c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <string.h>
#include "bionic.h"
#include "irq.h"
#include "printf.h"
static void print_help(void)
{
printf("Usage:\n");
printf("irq sim [num] Simulate IRQ [num]\n");
printf("irq enable [num] Enable IRQ [num]\n");
printf("irq disable [num] Disable IRQ [num]\n");
}
int cmd_irq(int argc, char **argv)
{
int num;
if (argc != 2) {
print_help();
return -1;
}
num = strtoul(argv[1], NULL, 0);
if (num >= __irq_max__) {
printf("Only %d IRQs present\n", __irq_max__);
return -1;
}
if (!_strcasecmp(argv[0], "sim")) {
printf("Simulating IRQ %d\n", num);
irq_stimulate(num);
}
else if (!_strcasecmp(argv[0], "enable")) {
printf("Enabling IRQ %d\n", num);
irq_enable(num);
}
else if (!_strcasecmp(argv[0], "disable")) {
printf("Disabling IRQ %d\n", num);
irq_disable(num);
}
else {
printf("Unknown command\n");
print_help();
return -1;
}
return 0;
}
int cmd_swi(int argc, char **argv)
{
printf("Generating SWI...\n");
asm volatile ("swi #0\n");
printf("Returned from SWI\n");
return 0;
}