Rev 2005 | Rev 2063 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2005 | Rev 2015 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | 39 | ||
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> |
|
- | 45 | ||
- | 46 | static parea_t rd_parea; /**< Physical memory area for rd. */ |
|
44 | 47 | ||
45 | int init_rd(rd_header * header, size_t size) |
48 | int init_rd(rd_header * header, size_t size) |
46 | { |
49 | { |
47 | /* Identify RAM disk */ |
50 | /* Identify RAM disk */ |
48 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
51 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || |
- | 52 | (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
|
49 | return RE_INVALID; |
53 | return RE_INVALID; |
50 | 54 | ||
51 | /* Identify version */ |
55 | /* Identify version */ |
52 | if (header->version != RD_VERSION) |
56 | if (header->version != RD_VERSION) |
53 | return RE_UNSUPPORTED; |
57 | return RE_UNSUPPORTED; |
Line 74... | Line 78... | ||
74 | return RE_INVALID; |
78 | return RE_INVALID; |
75 | 79 | ||
76 | if ((uint64_t) hsize + dsize > size) |
80 | if ((uint64_t) hsize + dsize > size) |
77 | dsize = size - hsize; |
81 | dsize = size - hsize; |
78 | 82 | ||
- | 83 | rd_parea.pbase = KA2PA((void *) header + hsize); |
|
- | 84 | rd_parea.vbase = (uintptr_t) ((void *) header + hsize); |
|
- | 85 | rd_parea.frames = SIZE2FRAMES(dsize); |
|
- | 86 | rd_parea.cacheable = true; |
|
- | 87 | ddi_parea_register(&rd_parea); |
|
- | 88 | ||
79 | sysinfo_set_item_val("rd", NULL, true); |
89 | sysinfo_set_item_val("rd", NULL, true); |
80 | sysinfo_set_item_val("rd.size", NULL, dsize); |
90 | sysinfo_set_item_val("rd.size", NULL, dsize); |
81 | sysinfo_set_item_val("rd.address.physical", NULL, (unative_t) KA2PA((void *) header + hsize)); |
91 | sysinfo_set_item_val("rd.address.physical", NULL, (unative_t) |
- | 92 | KA2PA((void *) header + hsize)); |
|
- | 93 | sysinfo_set_item_val("rd.address.color", NULL, (unative_t) |
|
- | 94 | PAGE_COLOR((uintptr_t) header + hsize)); |
|
82 | 95 | ||
83 | return RE_OK; |
96 | return RE_OK; |
84 | } |
97 | } |
85 | 98 | ||
86 | /** @} |
99 | /** @} |