iommu_rscs.c revision a77271f8607dbace3fbc9a3cda0fd24d6e7ccd68
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/autoconf.h>
#include <sys/sysmacros.h>
#include <sys/ddidmareq.h>
#include <vm/seg_kmem.h>
#include <sys/ddi_impldefs.h>
#include <sys/mach_intr.h>
#include <sys/machsystm.h>
#include <sys/iommu_rscs.h>
#include <sys/intel_iommu.h>
0U,
0xffffffffU,
0xffffffffU,
MMU_PAGESIZE, /* page aligned */
0x1,
0x1,
0xffffffffU,
0xffffffffU,
1,
4,
0
};
};
typedef struct iommu_rscs_s {
/*
* Bounds of resource allocation. We will start allocating at rs_min
* and rollover at rs_max+1 (rs_max is included). e.g. for rs_min=0
* and rs_max=7, we will have 8 total resources which can be alloced.
*/
/*
* rs_free points to an array of 64-bit values used to track resource
* allocation. rs_free_size is the free buffer size in bytes.
*/
/*
* last tracks the last alloc'd resource. This allows us to do a round
* robin allocation.
*/
static uint_t
{
return (paddr % IOMMU_PGHDL_HASH_SIZE);
}
/*
* iommu_page_alloc()
*
*/
{
size_t actual_size = 0;
return (0);
}
return (0);
}
return (0);
}
if (actual_size != PAGESIZE) {
return (0);
}
return (pghdl);
}
/*
* iommu_page_free()
*/
void
{
continue;
"Freeing a free IOMMU page: paddr=0x%" PRIx64,
paddr);
/*NOTREACHED*/
}
else
}
/*
* iommu_get_vaddr()
*/
{
continue;
return (0);
}
}
/*
* iommu_rscs_init()
* Initialize the resource structure. init() returns a handle to be
* used for the rest of the resource functions. This code is written assuming
* that min_val will be close to 0. Therefore, we will allocate the free
* buffer only taking max_val into account.
*/
void
{
/* alloc space for resource structure */
/*
* Test to see if the max value is 64-bit aligned. If so, we don't need
* to allocate an extra 64-bit word. alloc space for free buffer
* (8 bytes per uint64_t).
*/
if ((max_val & 0x3F) == 0) {
} else {
}
/* Initialize resource structure */
/* Mark all resources as free */
}
/* setup handle which is returned from this function */
}
/*
* iommu_rscs_fini()
* Frees up the space allocated in init(). Notice that a pointer to the
* handle is used for the parameter. fini() will set the handle to NULL
* before returning.
*/
void
{
/* set handle to null. This helps catch bugs. */
}
/*
* iommu_rscs_alloc()
* alloc a resource. If alloc fails, we are out of resources.
*/
int
{
/*
* Find a free resource. This will return out of the loop once it finds
* a free resource. There are a total of 'max'-'min'+1 resources.
* Performs a round robin allocation.
*/
/* if the next resource to check is free */
/* we are using this resource */
/* take it out of the free list */
/*
* increment the last count so we start checking the
* next resource on the next alloc(). Note the rollover
* at 'max'+1.
*/
}
/* unlock the resource structure */
return (DDI_SUCCESS);
}
/*
* This resource is not free, lets go to the next one. Note the
* rollover at 'max'.
*/
}
}
return (DDI_FAILURE);
}
/*
* iommu_rscs_free()
* Free the previously alloc'd resource. Once a resource has been free'd,
* it can be used again when alloc is called.
*/
void
{
/* Put the resource back in the free list */
}