1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Pierre-Alexandre Meyer - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
32 #include "hdt-common.h"
34 static void show_memory_e820(int argc __unused
, char **argv __unused
,
35 struct s_hardware
*hardware __unused
)
37 struct e820entry map
[E820MAX
];
38 unsigned long memsize
= 0;
42 detect_memory_e820(map
, E820MAX
, &count
);
43 memsize
= memsize_e820(map
, count
);
45 more_printf("Detected RAM : %lu MiB (%lu KiB)\n",
46 (memsize
+ (1 << 9)) >> 10, memsize
);
47 more_printf("BIOS-provided physical RAM e820 map:\n");
48 for (int i
= 0; i
< count
; i
++) {
49 get_type(map
[i
].type
, type
, 14);
50 more_printf("%016llx - %016llx %016llx (%s)\n",
51 map
[i
].addr
, map
[i
].size
, map
[i
].addr
+ map
[i
].size
,
54 struct e820entry nm
[E820MAX
];
56 /* Clean up, adjust and copy the BIOS-supplied E820-map. */
57 int nr
= sanitize_e820_map(map
, nm
, count
);
60 more_printf("Sanitized e820 map:\n");
61 for (int i
= 0; i
< nr
; i
++) {
62 get_type(nm
[i
].type
, type
, 14);
63 more_printf("%016llx - %016llx %016llx (%s)\n",
64 nm
[i
].addr
, nm
[i
].size
, nm
[i
].addr
+ nm
[i
].size
,
69 static void show_memory_e801(int argc __unused
, char **argv __unused
,
70 struct s_hardware
*hardware __unused
)
72 int mem_low
, mem_high
= 0;
75 if (detect_memory_e801(&mem_low
, &mem_high
)) {
76 more_printf("e801 bogus!\n");
78 more_printf("Detected RAM : %d MiB(%d KiB)\n",
79 (mem_low
>> 10) + (mem_high
>> 4),
80 mem_low
+ (mem_high
<< 6));
81 more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n", mem_low
,
82 mem_low
>> 10, mem_high
<< 6, mem_high
>> 4);
86 static void show_memory_88(int argc __unused
, char **argv __unused
,
87 struct s_hardware
*hardware __unused
)
92 if (detect_memory_88(&mem_size
)) {
93 more_printf("8800h bogus!\n");
95 more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size
,
100 struct cli_callback_descr list_memory_show_modules
[] = {
103 .exec
= show_memory_e820
,
108 .exec
= show_memory_e801
,
113 .exec
= show_memory_88
,
117 .name
= CLI_DMI_MEMORY_BANK
,
118 .exec
= show_dmi_memory_bank
,
128 struct cli_module_descr memory_show_modules
= {
129 .modules
= list_memory_show_modules
,
130 .default_callback
= show_dmi_memory_modules
,
133 struct cli_mode_descr memory_mode
= {
136 .default_modules
= NULL
,
137 .show_modules
= &memory_show_modules
,