1*58a2b000SEvgeniy Ivanov /* $NetBSD: printmemlist.c,v 1.2 2008/12/14 17:03:43 christos Exp $ */
2*58a2b000SEvgeniy Ivanov /*
3*58a2b000SEvgeniy Ivanov * Copyright (c) 1999
4*58a2b000SEvgeniy Ivanov * Matthias Drochner. All rights reserved.
5*58a2b000SEvgeniy Ivanov *
6*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without
7*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions
8*58a2b000SEvgeniy Ivanov * are met:
9*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright
10*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer.
11*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright
12*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the
13*58a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution.
14*58a2b000SEvgeniy Ivanov *
15*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*58a2b000SEvgeniy Ivanov * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*58a2b000SEvgeniy Ivanov * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*58a2b000SEvgeniy Ivanov * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*58a2b000SEvgeniy Ivanov * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*58a2b000SEvgeniy Ivanov * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*58a2b000SEvgeniy Ivanov * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*58a2b000SEvgeniy Ivanov * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*58a2b000SEvgeniy Ivanov * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*58a2b000SEvgeniy Ivanov * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*58a2b000SEvgeniy Ivanov *
26*58a2b000SEvgeniy Ivanov */
27*58a2b000SEvgeniy Ivanov
28*58a2b000SEvgeniy Ivanov #include <lib/libsa/stand.h>
29*58a2b000SEvgeniy Ivanov #include "libi386.h"
30*58a2b000SEvgeniy Ivanov
31*58a2b000SEvgeniy Ivanov extern int getmementry(int *, int *);
32*58a2b000SEvgeniy Ivanov
33*58a2b000SEvgeniy Ivanov static char *memtypes[] = {
34*58a2b000SEvgeniy Ivanov "available",
35*58a2b000SEvgeniy Ivanov "reserved",
36*58a2b000SEvgeniy Ivanov "ACPI reclaimable",
37*58a2b000SEvgeniy Ivanov "ACPI NVS"
38*58a2b000SEvgeniy Ivanov };
39*58a2b000SEvgeniy Ivanov
40*58a2b000SEvgeniy Ivanov void
printmemlist(void)41*58a2b000SEvgeniy Ivanov printmemlist(void)
42*58a2b000SEvgeniy Ivanov {
43*58a2b000SEvgeniy Ivanov int buf[5], i;
44*58a2b000SEvgeniy Ivanov char *type;
45*58a2b000SEvgeniy Ivanov
46*58a2b000SEvgeniy Ivanov i = 0;
47*58a2b000SEvgeniy Ivanov do {
48*58a2b000SEvgeniy Ivanov if (getmementry(&i, buf))
49*58a2b000SEvgeniy Ivanov break;
50*58a2b000SEvgeniy Ivanov if (buf[4] < 1 || buf[4] > 4)
51*58a2b000SEvgeniy Ivanov type = "invalid entry";
52*58a2b000SEvgeniy Ivanov else
53*58a2b000SEvgeniy Ivanov type = memtypes[buf[4] - 1];
54*58a2b000SEvgeniy Ivanov printf("%x:%x/%x:%x: %s\n", buf[1], buf[0], buf[3], buf[2],
55*58a2b000SEvgeniy Ivanov type);
56*58a2b000SEvgeniy Ivanov } while (i);
57*58a2b000SEvgeniy Ivanov }
58