11913091 |
1 | #include <stdio.h> |
306e06f7 |
2 | #include <stdlib.h> |
7fd42181 |
3 | #include <string.h> |
11913091 |
4 | #include <sys/types.h> |
5 | #include <sys/stat.h> |
6 | #include <fcntl.h> |
7 | #include <sys/mman.h> |
dc90c02d |
8 | #include <sys/ioctl.h> |
9 | #include <signal.h> |
7fd42181 |
10 | #include <termios.h> |
db9191ed |
11 | #include <unistd.h> |
7fd42181 |
12 | |
13 | static int open_(const char *name) |
14 | { |
15 | int fd = open(name, O_RDWR); |
16 | if (fd < 0) { |
17 | fprintf(stderr, "%s: ", name); |
18 | perror("open"); |
19 | return 1; |
20 | } |
21 | |
22 | return fd; |
23 | } |
11913091 |
24 | |
306e06f7 |
25 | int main(int argc, char *argv[]) |
11913091 |
26 | { |
27 | volatile void *memregs; |
7fd42181 |
28 | void *fbmem; |
29 | int memdev, fbdev; |
86418a84 |
30 | int i; |
11913091 |
31 | |
306e06f7 |
32 | printf("hi, home=%s\n", getenv("HOME")); |
33 | |
34 | for (i = 0; i < argc; i++) |
35 | printf("%d \"%s\"\n", i, argv[i]); |
11913091 |
36 | |
7fd42181 |
37 | memdev = open_("/dev/mem"); |
38 | fbdev = open_("/dev/fb0"); |
306e06f7 |
39 | |
11913091 |
40 | memregs = mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000); |
7fd42181 |
41 | fbmem = mmap(NULL, 320*240*2, PROT_READ|PROT_WRITE, MAP_SHARED, fbdev, 0); |
42 | |
dc90c02d |
43 | ioctl(-1, 0); |
44 | signal(7, SIG_DFL); |
db9191ed |
45 | system("buhbuh"); |
46 | execl("bah", "bah", NULL); |
47 | execlp("bah", "bah", NULL); |
48 | if (argc == 1000) |
49 | fork(); |
50 | chdir("wuhahaha!"); |
7000b522 |
51 | usleep(1); |
7fd42181 |
52 | // tcgetattr(-1, NULL); |
53 | // tcsetattr(-1, 0, NULL); |
86418a84 |
54 | |
7fd42181 |
55 | #if 1 |
86418a84 |
56 | for (i = 0; i < 2; i++) |
57 | printf("%02x %04x %08x\n", ((char *)memregs)[0x2011], |
58 | ((short *)memregs)[0x1198/2], ((int *)memregs)[0xbcdc/4]); |
7fd42181 |
59 | #endif |
60 | memset(fbmem, 0xff, 320*240*2); |
86418a84 |
61 | |
7fd42181 |
62 | sleep(10); |
11913091 |
63 | |
64 | return 0; |
65 | } |
66 | |