-
Notifications
You must be signed in to change notification settings - Fork 21
/
atags.c
183 lines (163 loc) · 4.69 KB
/
atags.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "atags.h"
#include "framebuffer.h"
#include "memory.h"
#include "textutils.h"
static void print_atag_core(struct atag_core *data)
{
if(data->header.size == 5)
{
console_write(" Flags: 0x");
console_write(tohex(data->flags, 4));
console_write(", pagesize: 0x");
console_write(tohex(data->pagesize, 4));
console_write(", root device: 0x");
console_write(tohex(data->rootdevice, 4));
console_write("\n");
}
else
console_write(" No additional data\n");
}
static void print_atag_mem(struct atag_mem *data)
{
console_write(" Address: 0x");
console_write(tohex(data->address, 4));
console_write(" - 0x");
console_write(tohex(data->address+data->size-1, 4));
console_write(" (");
console_write(todec(data->size, 0));
console_write(" bytes)\n");
}
static void print_atag_ramdisk(struct atag_ramdisk *data)
{
console_write(" Flags: 0x");
console_write(tohex(data->flags, 4));
console_write(", size: 0x");
console_write(tohex(data->size, 4));
console_write(", start block: 0x");
console_write(tohex(data->start, 4));
console_write("\n");
}
static void print_atag_initrd2(struct atag_initrd2 *data)
{
console_write(" Address: 0x");
console_write(tohex(data->address, 4));
console_write(" - 0x");
console_write(tohex(data->address+data->size-1, 4));
console_write(" (");
console_write(todec(data->size, 0));
console_write(" bytes)\n");
}
static void print_atag_serial(struct atag_serial *data)
{
console_write(" Serial number: 0x");
console_write(tohex(data->high, 4));
console_write(tohex(data->low, 4));
console_write("\n");
}
static void print_atag_revision(struct atag_revision *data)
{
console_write(" Board revision: ");
console_write(todec(data->revision, 0));
console_write("\n");
}
static void print_atag_videolfb(struct atag_videolfb *data)
{
console_write(" Size: ");
console_write(todec(data->width, 0));
console_write("x");
console_write(todec(data->height, 0));
console_write(", depth: ");
console_write(todec(data->depth, 0));
console_write("bpp, linelength: ");
console_write(todec(data->linelength, 0));
console_write("\n Address: 0x");
console_write(tohex(data->address, 4));
console_write(" - 0x");
console_write(tohex(data->address+data->size-1, 4));
console_write(" (");
console_write(todec(data->size, 0));
console_write(" bytes)\n");
console_write(" Pos/size: R ");
console_write(todec(data->redpos, 0));
console_write("/");
console_write(todec(data->redsize, 0));
console_write(", G ");
console_write(todec(data->greenpos, 0));
console_write("/");
console_write(todec(data->greensize, 0));
console_write(", B ");
console_write(todec(data->bluepos, 0));
console_write("/");
console_write(todec(data->bluesize, 0));
console_write(", reserved ");
console_write(todec(data->reservedpos, 0));
console_write("/");
console_write(todec(data->reservedsize, 0));
console_write("\n");
}
static void print_atag_cmdline(struct atag_cmdline *data)
{
console_write(" \"");
console_write(&data->commandline);
console_write("\"\n");
}
void print_atags(unsigned int address)
{
/* Use virtual mapped physical memory to access the ATAGs */
struct atag_header *atags = (struct atag_header *) mem_p2v(address);
unsigned int tag;
console_write(COLOUR_PUSH BG_GREEN BG_HALF "Reading ATAGs\n\n" COLOUR_POP);
do
{
tag = atags->tag;
console_write("ATAG at address 0x");
console_write(tohex((unsigned int) atags, 4));
console_write(" is 0x");
console_write(tohex(tag, 4));
switch(tag)
{
case 0:
console_write(" (ATAG_NONE)\n\n");
break;
case ATAG_CORE:
console_write(" (ATAG_CORE)\n");
print_atag_core((struct atag_core *)atags);
break;
case ATAG_MEM:
console_write(" (ATAG_MEM)\n");
print_atag_mem((struct atag_mem *)atags);
break;
case ATAG_VIDEOTEXT:
console_write(" (ATAG_VIDEOTEXT)\n");
break;
case ATAG_RAMDISK:
console_write(" (ATAG_RAMDISK)\n");
print_atag_ramdisk((struct atag_ramdisk *)atags);
break;
case ATAG_INITRD2:
console_write(" (ATAG_INITRD2)\n");
print_atag_initrd2((struct atag_initrd2 *)atags);
break;
case ATAG_SERIAL:
console_write(" (ATAG_SERIAL)\n");
print_atag_serial((struct atag_serial *)atags);
break;
case ATAG_REVISION:
console_write(" (ATAG_REVISION)\n");
print_atag_revision((struct atag_revision *)atags);
break;
case ATAG_VIDEOLFB:
console_write(" (ATAG_VIDEOLFB)\n");
print_atag_videolfb((struct atag_videolfb *)atags);
break;
case ATAG_CMDLINE:
console_write(" (ATAG_CMDLINE)\n");
print_atag_cmdline((struct atag_cmdline *)atags);
break;
default:
console_write(" (UNKNOWN)\n");
return;
}
atags = (struct atag_header *)((unsigned int)atags + (atags->size * 4));
} while(tag);
}