memlist_new.c revision 903a11ebdc8df157c4700150f41f1f262f4a8ae8
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/memlist_impl.h>
static struct memlist *memlist_freelist;
static uint_t memlist_freelist_count;
static kmutex_t memlist_freelist_mutex;
/*
* Caller must test for NULL return.
*/
struct memlist *
memlist_get_one(void)
{
}
return (mlp);
}
void
{
}
void
{
return;
}
count = 1;
count++;
}
void
{
if (count == 0)
return;
}
/*
* Insert into a sorted memory list.
* new = new element to insert
* curmemlistp = memory list to which to add segment.
*/
void
struct memlist **curmemlistp)
{
if (cur == *curmemlistp)
*curmemlistp = new;
else
return;
}
panic("munged memory list = 0x%p\n",
(void *)curmemlistp);
}
}
void
struct memlist **curmemlistp)
{
#ifdef DEBUG
/*
* Check that the memlist is on the list.
*/
break;
#endif /* DEBUG */
if (*curmemlistp == memlistp) {
}
}
}
}
struct memlist *
{
break;
return (mlp);
}
/*
* Add a span to a memlist.
* Return:
* MEML_SPANOP_OK if OK.
* MEML_SPANOP_ESPAN if part or all of span already exists
* MEML_SPANOP_EALLOC for allocation failure
*/
int
struct memlist **curmemlistp)
{
/*
* allocate a new struct memlist
*/
dst = memlist_get_one();
return (MEML_SPANOP_EALLOC);
}
/*
* First insert.
*/
if (*curmemlistp == NULL) {
*curmemlistp = dst;
return (MEML_SPANOP_OK);
}
/*
* Insert into sorted list.
*/
continue;
/*
* Else insert here.
*/
/*
* Prepend to next.
*/
return (MEML_SPANOP_OK);
}
/*
* Append to next.
*/
/*
* don't overlap with next->next
*/
return (MEML_SPANOP_ESPAN);
}
/*
* Concatenate next and next->next
*/
if (next == *curmemlistp)
return (MEML_SPANOP_OK);
}
}
return (MEML_SPANOP_OK);
}
/* don't overlap with next */
return (MEML_SPANOP_ESPAN);
}
/*
* Insert before next.
*/
*curmemlistp = dst;
} else {
}
return (MEML_SPANOP_OK);
}
/*
* End of list, prev is valid and next is NULL.
*/
return (MEML_SPANOP_OK);
}
/*
* Delete a span from a memlist.
* Return:
* MEML_SPANOP_OK if OK.
* MEML_SPANOP_ESPAN if part or all of span does not exist
* MEML_SPANOP_EALLOC for allocation failure
*/
int
struct memlist **curmemlistp)
{
/*
* Find element containing address.
*/
break;
}
/*
* If start address not in list.
*/
return (MEML_SPANOP_ESPAN);
}
/*
* Error if size goes off end of this struct memlist.
*/
return (MEML_SPANOP_ESPAN);
}
/*
* Span at beginning of struct memlist.
*/
/*
* If start & size match, delete from list.
*/
if (next == *curmemlistp)
} else {
/*
* Increment start address by bytes.
*/
}
return (MEML_SPANOP_OK);
}
/*
* Span at end of struct memlist.
*/
/*
* decrement size by bytes
*/
return (MEML_SPANOP_OK);
}
/*
* Delete a span in the middle of the struct memlist.
*/
{
/*
* create a new struct memlist
*/
dst = memlist_get_one();
return (MEML_SPANOP_EALLOC);
}
/*
* Existing struct memlist gets address
* and size up to start of span.
*/
/*
* New struct memlist gets address starting
* after span, until end.
*/
/*
* link in new memlist after old
*/
}
return (MEML_SPANOP_OK);
}