File: sys_info.c

package info (click to toggle)
openbios-sparc 1.0%2Bsvn640-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,412 kB
  • ctags: 12,091
  • sloc: ansic: 57,249; asm: 2,680; xml: 1,335; cpp: 414; makefile: 224; sh: 190
file content (56 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
#include "openbios/config.h"
#include "openbios/kernel.h"
#include "sys_info.h"
#include "context.h"

#ifdef CONFIG_DEBUG_BOOT
#define debug printk
#else
#define debug(x...)
#endif

void collect_multiboot_info(struct sys_info *);

void collect_sys_info(struct sys_info *info)
{
    int i;
    unsigned long long total = 0;
    struct memrange *mmap;

    /* Pick up paramters given by bootloader to us */
    info->boot_type = boot_ctx->eax;
    info->boot_data = boot_ctx->ebx;
    info->boot_arg = boot_ctx->param[0];
    debug("boot eax = %#lx\n", info->boot_type);
    debug("boot ebx = %#lx\n", info->boot_data);
    debug("boot arg = %#lx\n", info->boot_arg);

    collect_elfboot_info(info);
#ifdef CONFIG_LINUXBIOS
    collect_linuxbios_info(info);
#endif
#ifdef CONFIG_IMAGE_ELF_MULTIBOOT
    collect_multiboot_info(info);
#endif

    if (!info->memrange) {
	printk("Can't get memory map from firmware. "
		"Using hardcoded default.\n");
	info->n_memranges = 2;
	info->memrange = malloc(2 * sizeof(struct memrange));
	info->memrange[0].base = 0;
	info->memrange[0].size = 640*1024;
	info->memrange[1].base = 1024*1024;
	info->memrange[1].size = 32*1024*1024
	    - info->memrange[1].base;
    }

    debug("\n");
    mmap=info->memrange;
    for (i = 0; i < info->n_memranges; i++) {
	debug("%016Lx-", mmap[i].base);
	debug("%016Lx\n", mmap[i].base+mmap[i].size);
	total += mmap[i].size;
    }
    debug("RAM %Ld MB\n", (total + 512*1024) >> 20);
}