sun4u_memlist.c revision 56f33205c9ed776c3c909e07d52e94610a675740
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/bootconf.h>
/*
* This file defines the interface from the prom and platform-dependent
* form of the memory lists, to boot's more generic form of the memory
* list. For sun4u, the memory list properties are {hi, lo, size_hi, size_lo},
* which is similar to boot's format, except boot's format is a linked
* list, and the prom's is an array of these structures. Note that the
* native property on sparc machines is identical to the property encoded
* format, so no property decoding is required.
*
* Note that the format of the memory lists is really 4 encoded integers,
* but the encoding is the same as that given in the following structure
* on SPARC systems ...
*/
struct sun4u_prom_memlist {
};
extern void kmem_init(void);
void
init_memlists(void)
{
/* this list is a map of pmem actually installed */
kmem_init();
}
struct memlist *
{
/*
* Figure out the interesting phandles, one time
* only.
*/
prom_panic("Can't get mmu ihandle");
prom_panic("Can't get memory ihandle");
}
else
/*
* Read memory node and calculate the number of entries
*/
prom_panic("Cannot get list.\n");
if (links > sizeof (scratch_memlist)) {
prom_printf("%s list <%s> exceeds boot capabilities\n",
prom_panic("fill_memlists - memlist size");
}
return (al);
}
/*
* Simple selection sort routine.
* Sorts platform dependent memory lists into ascending order
*/
static void
{
int i, j, min;
struct sun4u_prom_memlist temp;
for (i = 0; i < n; i++) {
min = i;
for (j = i+1; j < n; j++) {
min = j;
}
if (i != min) {
/* Swap ar[i] and ar[min] */
}
}
}
/*
* This routine will convert our platform dependent memory list into
* struct memlists's. And it will also coalesce adjacent nodes if
* possible.
*/
static struct memlist *
{
int i;
u_longlong_t size = 0;
u_longlong_t addr = 0;
int flag = 0;
if (n == 0)
return ((struct memlist *)0);
/*
* if there was a memory list allocated before, free it first.
*/
if (old)
(void) add_to_freelist(old);
for (i = 0; i < n; i++) {
if (!flag) {
flag++;
}
continue;
} else if (flag) {
/*
* catch the last one on the way out of
* this iteration
*/
}
if (!head)
if (last)
size = 0;
flag = 0;
addr = 0;
}
return (head);
}