Rev 3107 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3107 | Rev 3403 | ||
---|---|---|---|
Line 46... | Line 46... | ||
46 | 46 | ||
47 | static parea_t rd_parea; /**< Physical memory area for rd. */ |
47 | static parea_t rd_parea; /**< Physical memory area for rd. */ |
48 | 48 | ||
49 | /** |
49 | /** |
50 | * RAM disk initialization routine. At this point, the RAM disk memory is shared |
50 | * RAM disk initialization routine. At this point, the RAM disk memory is shared |
51 | * and information about the share is provided as sysinfo values to the userspace |
51 | * and information about the share is provided as sysinfo values to the |
52 | * tasks. |
52 | * userspace tasks. |
53 | */ |
53 | */ |
54 | int init_rd(rd_header_t *header, size_t size) |
54 | int init_rd(rd_header_t *header, size_t size) |
55 | { |
55 | { |
56 | /* Identify RAM disk */ |
56 | /* Identify RAM disk */ |
57 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || |
57 | if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || |
58 | (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
58 | (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) |
59 | return RE_INVALID; |
59 | return RE_INVALID; |
60 | 60 | ||
61 | /* Identify version */ |
61 | /* Identify version */ |
62 | if (header->version != RD_VERSION) |
62 | if (header->version != RD_VERSION) |
63 | return RE_UNSUPPORTED; |
63 | return RE_UNSUPPORTED; |
Line 84... | Line 84... | ||
84 | return RE_INVALID; |
84 | return RE_INVALID; |
85 | 85 | ||
86 | if ((uint64_t) hsize + dsize > size) |
86 | if ((uint64_t) hsize + dsize > size) |
87 | dsize = size - hsize; |
87 | dsize = size - hsize; |
88 | 88 | ||
89 | rd_parea.pbase = ALIGN_DOWN((uintptr_t) KA2PA((void *) header + hsize), FRAME_SIZE); |
89 | rd_parea.pbase = ALIGN_DOWN((uintptr_t) KA2PA((void *) header + hsize), |
- | 90 | FRAME_SIZE); |
|
90 | rd_parea.vbase = (uintptr_t) ((void *) header + hsize); |
91 | rd_parea.vbase = (uintptr_t) ((void *) header + hsize); |
91 | rd_parea.frames = SIZE2FRAMES(dsize); |
92 | rd_parea.frames = SIZE2FRAMES(dsize); |
92 | rd_parea.cacheable = true; |
93 | rd_parea.cacheable = true; |
93 | ddi_parea_register(&rd_parea); |
94 | ddi_parea_register(&rd_parea); |
94 | 95 | ||
95 | sysinfo_set_item_val("rd", NULL, true); |
96 | sysinfo_set_item_val("rd", NULL, true); |
96 | sysinfo_set_item_val("rd.header_size", NULL, hsize); |
97 | sysinfo_set_item_val("rd.header_size", NULL, hsize); |
97 | sysinfo_set_item_val("rd.size", NULL, dsize); |
98 | sysinfo_set_item_val("rd.size", NULL, dsize); |
98 | sysinfo_set_item_val("rd.address.physical", NULL, (unative_t) |
99 | sysinfo_set_item_val("rd.address.physical", NULL, |
99 | KA2PA((void *) header + hsize)); |
100 | (unative_t) KA2PA((void *) header + hsize)); |
100 | 101 | ||
101 | return RE_OK; |
102 | return RE_OK; |
102 | } |
103 | } |
103 | 104 | ||
104 | /** @} |
105 | /** @} |