File: multiboot.c

package info (click to toggle)
memtest86+ 5.01-3
  • links: PTS
  • area: main
  • in suites: buster, sid, stretch
  • size: 1,336 kB
  • ctags: 2,585
  • sloc: ansic: 17,514; asm: 1,805; makefile: 239; sh: 127
file content (49 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* multiboot.c
 *
 * Copyright (C) 2008,2009 Robert Millan
 *
 * Loosely based on linuxbios.c, which is:
 *
 * Released under version 2 of the Gnu Public License.
 * By Eric Biederman
 */

#include "multiboot.h"
#include "test.h"

extern struct multiboot_info *mbiptr;

int query_multiboot(void)
{
	struct multiboot_mmap_entry *mem;
	int i;

	if (!mbiptr) {
		return 0;
	}
	if (!mbiptr->mmap_addr) {
		return 1;
	}
	if ((mbiptr->flags & MULTIBOOT_INFO_MEM_MAP) == 0) {
		return 1;
	}

	mem = (struct multiboot_mmap_entry *) mbiptr->mmap_addr;
	mem_info.e820_nr = 0;

	for (i = 0; i < E820MAX; i++) {
		if ((multiboot_uint32_t) mem >= (mbiptr->mmap_addr + mbiptr->mmap_length)) {
			break;
		}

		mem_info.e820[mem_info.e820_nr].addr = mem->addr;
		mem_info.e820[mem_info.e820_nr].size = mem->len;
		/* Multiboot spec defines available / reserved types to match with E820.  */
		mem_info.e820[mem_info.e820_nr].type = mem->type;
		mem_info.e820_nr++;

		mem = (struct multiboot_mmap_entry *) ((multiboot_uint32_t) mem + mem->size + sizeof (mem->size));
	}

	return 1;
}