wip, some dynamic stuff works
[ginge.git] / loader / tools / static.c
... / ...
CommitLineData
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <sys/types.h>
5#include <sys/stat.h>
6#include <fcntl.h>
7#include <sys/mman.h>
8#include <sys/ioctl.h>
9#include <signal.h>
10#include <termios.h>
11
12static int open_(const char *name)
13{
14 int fd = open(name, O_RDWR);
15 if (fd < 0) {
16 fprintf(stderr, "%s: ", name);
17 perror("open");
18 return 1;
19 }
20
21 return fd;
22}
23
24int main(int argc, char *argv[])
25{
26 volatile void *memregs;
27 void *fbmem;
28 int memdev, fbdev;
29 int i;
30
31 printf("hi, home=%s\n", getenv("HOME"));
32
33 for (i = 0; i < argc; i++)
34 printf("%d \"%s\"\n", i, argv[i]);
35
36 memdev = open_("/dev/mem");
37 fbdev = open_("/dev/fb0");
38
39 memregs = mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
40 fbmem = mmap(NULL, 320*240*2, PROT_READ|PROT_WRITE, MAP_SHARED, fbdev, 0);
41
42 ioctl(-1, 0);
43 signal(7, SIG_DFL);
44// tcgetattr(-1, NULL);
45// tcsetattr(-1, 0, NULL);
46
47#if 1
48 for (i = 0; i < 2; i++)
49 printf("%02x %04x %08x\n", ((char *)memregs)[0x2011],
50 ((short *)memregs)[0x1198/2], ((int *)memregs)[0xbcdc/4]);
51#endif
52 memset(fbmem, 0xff, 320*240*2);
53
54 sleep(10);
55
56 return 0;
57}
58