rdram2data.c
2.59 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <verify.h>
#include <em.h>
#include "rdram.h"
#define BYTE_TO_DOUBLE(n) (((n) + 7)/8)
#define NumberDoubleWords(numBytes)
static void usage(void);
main(int argc, char **argv)
{
int i, c;
VerifyInfo *vp;
unsigned long long *llp;
unsigned char *cp;
unsigned char *mainAddress, *hiddenAddress;
long mainSize, hiddenSize;
int hiddenFlag = RDRAM_NOHIDDEN;
int frameBufferFlag = 0;
int zBufferFlag = 0;
while ((c = getopt(argc, argv, "fhz")) != EOF) {
switch (c) {
case 'f':
frameBufferFlag = 1;
break;
case 'h':
hiddenFlag = RDRAM_NEEDHIDDEN;
break;
case 'z':
zBufferFlag = 1;
break;
case '?':
usage();
exit(1);
}
}
if ((argc - optind) != 1) {
usage();
exit(1);
}
if (rdraminit(argv[optind], RDRAM_RDONLY, hiddenFlag, 0,
&mainAddress, &mainSize, &hiddenAddress, &hiddenSize) == 0) {
exit(1);
}
vp = (VerifyInfo *)(mainAddress + VERIFY_INFO_PHYSADDR);
/* Dump VerifyInfo struct */
printf("// VerifyInfo structure\n");
printf("@%x\n", BYTE_TO_DOUBLE(VERIFY_INFO_PHYSADDR));
llp = (unsigned long long *)(mainAddress + VERIFY_INFO_PHYSADDR);
for (i = 0; i < BYTE_TO_DOUBLE(sizeof(VerifyInfo)); i++)
printf("%016llx\n", *llp++);
/* Dump application data */
printf("// Application data\n");
printf("@%x\n", BYTE_TO_DOUBLE(APP_START_ADDR));
llp = (unsigned long long *)(mainAddress + APP_START_ADDR);
for (i = 0; i < BYTE_TO_DOUBLE(APP_END_ADDR - APP_START_ADDR); i++)
printf("%016llx\n", *llp++);
/* Dump Frame buffer if desired */
if (frameBufferFlag) {
printf("// Frame buffer data\n");
printf("@%x\n", BYTE_TO_DOUBLE(FB_START_ADDR));
llp = (unsigned long long *)(mainAddress + FB_START_ADDR);
for (i = 0; i < BYTE_TO_DOUBLE(ZB_START_ADDR - FB_START_ADDR); i++)
printf("%016llx\n", *llp++);
if (hiddenFlag) {
printf("%%%x\n", BYTE_TO_DOUBLE(FB_START_ADDR));
cp = (unsigned char *)
(hiddenAddress + BYTE_TO_DOUBLE(FB_START_ADDR));
for (i = 0; i < BYTE_TO_DOUBLE(ZB_START_ADDR - FB_START_ADDR); i++)
printf("%02x\n", *cp++);
}
}
/* Dump Z-buffer if desired */
if (zBufferFlag) {
printf("// Z-buffer data\n");
printf("@%x\n", BYTE_TO_DOUBLE(ZB_START_ADDR));
llp = (unsigned long long *)(mainAddress + ZB_START_ADDR);
for (i = 0; i < BYTE_TO_DOUBLE(ZB_END_ADDR - ZB_START_ADDR); i++)
printf("%016llx\n", *llp++);
}
}
static void
usage(void)
{
fprintf(stderr, "usage: rdram2data [-h] [-z] <.rdram file>\n");
exit(1);
}