source: mainline/kernel/genarch/src/multiboot/multiboot2.c@ 84239b1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 84239b1 was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * Copyright (c) 2011 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup genarch
30 * @{
31 */
32/** @file
33 */
34
35#include <typedefs.h>
36#include <genarch/multiboot/multiboot.h>
37#include <genarch/multiboot/multiboot2.h>
38#include <genarch/fb/bfb.h>
39#include <config.h>
40#include <align.h>
41
42#define MULTIBOOT2_TAG_ALIGN 8
43
44static void multiboot2_cmdline(const multiboot2_cmdline_t *module)
45{
46 multiboot_cmdline(module->string);
47}
48
49static void multiboot2_module(const multiboot2_module_t *module)
50{
51 if (init.cnt < CONFIG_INIT_TASKS) {
52 init.tasks[init.cnt].paddr = module->start;
53 init.tasks[init.cnt].size = module->end - module->start;
54 multiboot_extract_command(init.tasks[init.cnt].name,
55 CONFIG_TASK_NAME_BUFLEN, module->string);
56 multiboot_extract_argument(init.tasks[init.cnt].arguments,
57 CONFIG_TASK_ARGUMENTS_BUFLEN, module->string);
58
59 init.cnt++;
60 }
61}
62
63static void multiboot2_memmap(uint32_t length, const multiboot2_memmap_t *memmap)
64{
65 multiboot2_memmap_entry_t *entry = (multiboot2_memmap_entry_t *)
66 ((uintptr_t) memmap + sizeof(*memmap));
67 uint32_t pos = sizeof(*memmap);
68
69 while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) {
70 e820table[e820counter].base_address = entry->base_address;
71 e820table[e820counter].size = entry->size;
72 e820table[e820counter].type = entry->type;
73
74 /* Compute address of next entry. */
75 entry = (multiboot2_memmap_entry_t *)
76 ((uintptr_t) entry + memmap->entry_size);
77 pos += memmap->entry_size;
78
79 e820counter++;
80 }
81}
82
83static void multiboot2_fbinfo(const multiboot2_fbinfo_t *fbinfo)
84{
85#ifdef CONFIG_FB
86 if (fbinfo->visual == MULTIBOOT2_VISUAL_RGB) {
87 bfb_addr = fbinfo->addr;
88 bfb_width = fbinfo->width;
89 bfb_height = fbinfo->height;
90 bfb_bpp = fbinfo->bpp;
91 bfb_scanline = fbinfo->scanline;
92
93 bfb_red_pos = fbinfo->rgb.red_pos;
94 bfb_red_size = fbinfo->rgb.red_size;
95
96 bfb_green_pos = fbinfo->rgb.green_pos;
97 bfb_green_size = fbinfo->rgb.green_size;
98
99 bfb_blue_pos = fbinfo->rgb.blue_pos;
100 bfb_blue_size = fbinfo->rgb.blue_size;
101 }
102#endif
103}
104
105/** Parse multiboot2 information structure.
106 *
107 * If @a signature does not contain a valid multiboot2 signature,
108 * assumes no multiboot2 information is available.
109 *
110 * @param signature Should contain the multiboot2 signature.
111 * @param info Multiboot2 information structure.
112 *
113 */
114void multiboot2_info_parse(uint32_t signature, const multiboot2_info_t *info)
115{
116 if (signature != MULTIBOOT2_LOADER_MAGIC)
117 return;
118
119 const multiboot2_tag_t *tag = (const multiboot2_tag_t *)
120 ALIGN_UP((uintptr_t) info + sizeof(*info), MULTIBOOT2_TAG_ALIGN);
121
122 while (tag->type != MULTIBOOT2_TAG_TERMINATOR) {
123 switch (tag->type) {
124 case MULTIBOOT2_TAG_CMDLINE:
125 multiboot2_cmdline(&tag->cmdline);
126 break;
127 case MULTIBOOT2_TAG_MODULE:
128 multiboot2_module(&tag->module);
129 break;
130 case MULTIBOOT2_TAG_MEMMAP:
131 multiboot2_memmap(tag->size, &tag->memmap);
132 break;
133 case MULTIBOOT2_TAG_FBINFO:
134 multiboot2_fbinfo(&tag->fbinfo);
135 break;
136 }
137
138 tag = (const multiboot2_tag_t *)
139 ALIGN_UP((uintptr_t) tag + tag->size, MULTIBOOT2_TAG_ALIGN);
140 }
141}
142
143/** @}
144 */
Note: See TracBrowser for help on using the repository browser.