/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 2000-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This plugin creates memory configuration nodes and properties in the
*
* Subtree of memory-controller in the physical aspect.
* memory-controller --- memory-module
* However, there is no memory controller node on Grover. Thus we need to
* create it under platform.
*
* Subtree of memory in the logical aspect.
* memory --- memory-segment
* Add property _memory-module_ at memory-segment referring to the
* memory-module since memory-segment equals to memory-module on Grover.
*
* Undo strategy:
* Create all nodes and properties, or none if it fails in physical and
* logical memory tree respectively. It keeps on creating logical
* memory tree although it falis on physical logical tree, but no link to
* memory module.
*
* NOTE:
* It depends on PICL devtree plugin.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alloca.h>
#include <syslog.h>
#include <string.h>
#include <libintl.h>
#include <picl.h>
#include <picltree.h>
#include "piclmemcfg.h"
#include "memcfg_impl.h"
static void piclmemcfg_register(void);
static void piclmemcfg_init(void);
static void piclmemcfg_fini(void);
#pragma init(piclmemcfg_register)
"SUNW_piclmemcfg",
};
/*
* Create logical memory tree
* memory --- memory-segment
*/
static int
{
int i;
NULL)
return (PICL_FAILURE);
for (i = 0; i < TOTAL_MEM_SLOTS; i++) {
/*
* It means no segment for the slot if size is zero
*/
continue;
}
/*
* Create memory-segment node under memory
*/
if (err != PICL_SUCCESS)
break;
/*
* For undo easily later
*/
/*
* Add property, Size to memory-segment node
*/
if (err != PICL_SUCCESS)
break;
if (err != PICL_SUCCESS)
break;
/*
* Add property, BaseAddress to memory-segment node
*/
NULL);
if (err != PICL_SUCCESS)
break;
if (err != PICL_SUCCESS)
break;
/*
* Add property, InterleaveFactor to memory-segment node
*/
if (err != PICL_SUCCESS)
break;
NULL);
if (err != PICL_SUCCESS)
break;
/*
* Add reference property to the memory module if memory
* module node handle is not NULL.
*/
continue;
if (err != PICL_SUCCESS)
break;
if (err != PICL_SUCCESS)
break;
}
if (err != PICL_SUCCESS) {
/*
* Undo in the logical memory tree
*/
for (i = 0; i < TOTAL_MEM_SLOTS; i++) {
continue;
(void) ptree_delete_node(memsegh[i]);
(void) ptree_destroy_node(memsegh[i]);
}
}
return (err);
}
/*
* Create physical memory tree
* memory-controller --- memory-module
*/
static int
{
int i;
/*
* Create memory-controller node under platform
*/
if (err != PICL_SUCCESS)
return (err);
/*
* Create memory-module nodes and properties
* Get all memory modules with dimm
*/
for (i = 0; i < TOTAL_MEM_SLOTS; i++) {
/*
* It means no dimm on the slot if size is zero
*/
continue;
/* Create memory-module node under memory-controller */
if (err != PICL_SUCCESS)
break;
/*
* Update memory module node handle at mmodinfo
*/
/*
* Add property, Size to memory-module node
*/
if (err != PICL_SUCCESS)
break;
if (err != PICL_SUCCESS)
break;
/*
* Add property, ID to memory-module node
*/
if (err != PICL_SUCCESS)
break;
id = i;
if (err != PICL_SUCCESS)
break;
}
if (err != PICL_SUCCESS) {
/*
* Clear out the saved memory module node handle so that
* logical memory tree won't link to memory module.
*/
for (i = 0; i < TOTAL_MEM_SLOTS; i++)
/*
* Undo in the physical memory tree
*/
(void) ptree_delete_node(mch);
(void) ptree_destroy_node(mch);
}
return (err);
}
/*
* Get the memory module and memory segment information from
* property reg of memory node.
*
* mmodinfo will be updated. Also, the pointers to mseginfo and
* the number of segments will be passed to the caller.
*/
static int
{
int i, err;
int pval;
int nregspec;
/*
* Check if the #size-cells of the platform node is 2
*/
sizeof (pval));
if (err == PICL_PROPNOTFOUND)
else if (err != PICL_SUCCESS)
return (err);
/*
* don't know to handle other vals
*/
if (pval != SUPPORTED_NUM_CELL_SIZE)
return (PICL_FAILURE);
/*
* Get property reg of memory node
*/
if (err != PICL_SUCCESS)
return (err);
if (err != PICL_SUCCESS)
return (err);
return (PICL_FAILURE);
return (PICL_FAILURE);
if (err != PICL_SUCCESS)
return (err);
for (i = 0; i < nregspec; i++) {
}
return (PICL_SUCCESS);
}
/*
* executed as part of .init when the plugin is dlopen()ed
*/
static void
piclmemcfg_register(void)
{
(void) picld_plugin_register(&my_reg_info);
}
/*
* Init entry point of the plugin
* Creates the PICL nodes and properties in the physical and logical aspects.
*/
static void
piclmemcfg_init(void)
{
/*
* Get platform node
*/
return;
}
/*
* Find the memory node
*/
return;
}
/*
* Initialize the mmodinfo and get segment information from reg
*/
return;
}
/*
* Create subtree of memory-controller in the physical aspect.
* memory-controller --- memory-module
*/
/*
* Create subtree of memory in the logical aspect.
* memory --- memory-segment
*/
}
/*
* fini entry point of the plugin
*/
static void
piclmemcfg_fini(void)
{
}