Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2205 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | #include <lib/rd.h> |
40 | #include <lib/rd.h> |
41 | #include <arch/byteorder.h> |
41 | #include <arch/byteorder.h> |
42 | #include <mm/frame.h> |
42 | #include <mm/frame.h> |
43 | #include <sysinfo/sysinfo.h> |
43 | #include <sysinfo/sysinfo.h> |
44 | #include <ddi/ddi.h> |
44 | #include <ddi/ddi.h> |
- | 45 | #include <print.h> |
|
45 | 46 | ||
46 | static parea_t rd_parea; /**< Physical memory area for rd. */ |
47 | static parea_t rd_parea; /**< Physical memory area for rd. */ |
47 | 48 | ||
48 | int init_rd(rd_header * header, size_t size) |
49 | int init_rd(rd_header * header, size_t size) |
49 | { |
50 | { |
- | 51 | printf("Header magic %c%c%c%c\n",header->magic[0],header->magic[1],header->magic[2],header->magic[3]); |
|
- | 52 | ||
50 | /* Identify RAM disk */ |
53 | /* Identify RAM disk */ |
51 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || |
54 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || |
52 | (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
55 | (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
53 | return RE_INVALID; |
56 | return RE_INVALID; |
- | 57 | ||
- | 58 | printf("Header version %d\n",header->version); |
|
- | 59 | printf("Expected version %d\n",RD_VERSION); |
|
54 | 60 | ||
55 | /* Identify version */ |
61 | /* Identify version */ |
56 | if (header->version != RD_VERSION) |
62 | if (header->version != RD_VERSION) |
57 | return RE_UNSUPPORTED; |
63 | return RE_UNSUPPORTED; |
- | 64 | ||
- | 65 | printf("Header type %d\n",header->data_type); |
|
58 | 66 | ||
59 | uint32_t hsize; |
67 | uint32_t hsize; |
60 | uint64_t dsize; |
68 | uint64_t dsize; |
61 | switch (header->data_type) { |
69 | switch (header->data_type) { |
62 | case RD_DATA_LSB: |
70 | case RD_DATA_LSB: |
Line 67... | Line 75... | ||
67 | hsize = uint32_t_be2host(header->header_size); |
75 | hsize = uint32_t_be2host(header->header_size); |
68 | dsize = uint64_t_be2host(header->data_size); |
76 | dsize = uint64_t_be2host(header->data_size); |
69 | break; |
77 | break; |
70 | default: |
78 | default: |
71 | return RE_UNSUPPORTED; |
79 | return RE_UNSUPPORTED; |
72 | } |
80 | } |
- | 81 | ||
- | 82 | printf("Header size %d\n",header->header_size); |
|
- | 83 | printf("Data size %d\n",header->data_size); |
|
- | 84 | printf("Size %d\n",size); |
|
73 | 85 | ||
- | 86 | //jelen: does this make any sense? (we don't even care about the header size, do we?) |
|
74 | if ((hsize % FRAME_SIZE) || (dsize % FRAME_SIZE)) |
87 | /*if ((hsize % FRAME_SIZE) || (dsize % FRAME_SIZE)) |
75 | return RE_UNSUPPORTED; |
88 | return RE_UNSUPPORTED; |
76 | 89 | */ |
|
77 | if (hsize > size) |
90 | if (hsize > size) |
78 | return RE_INVALID; |
91 | return RE_INVALID; |
79 | 92 | ||
80 | if ((uint64_t) hsize + dsize > size) |
93 | if ((uint64_t) hsize + dsize > size) |
81 | dsize = size - hsize; |
94 | dsize = size - hsize; |