mcookie.c revision 2
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcdriver/fcdriver.h>
#define MAX_MAPS 256
#define MAP_IS_VALID 0x01
struct map_table {
int map_flags;
/*
* Originally, this code translated kernel supplied virtual addresses into
* "memory cookies", which was a 32-bit number with ascii-M in the upper 8
* bits, a 4-bit index and a 20-bit offset. However, this caused two
* problems: 1) the 20-bit offset was too small for some devices, esp. some
* with frame-buffers; 2) if the fcode used the cookie to program the
* hardware, there was no easy way for the software to detect that a
* translation needed to be done.
*
* For that reason, "memory cookies" are now just the kernel-supplied
* virtual address, and we now check each memory access to see if it's
* attempting to access kernel-supplied memory. The only important thing
* now is that "is_mcookie" returns 1 (or true) if the tested mcookie
* is a kernel virtual address.
*
* There is a potential bug if the kernel virtual address happens to
* conflict with a user virtual address. However, the current implementation
* of Solaris avoids this conflict.
*/
{
int i;
break;
if (i == MAX_MAPS) {
return (0);
}
if (mp->adj_length != 0)
return (adj_virt);
else
return (req_add);
}
void
{
int i;
mp->adj_length = 0;
return;
}
}
}
int
{
int i;
return (1);
return (0);
}
{
return (mcookie);
}
{
int i;
}
}
return (0);
}
{
int i;
}
}
return (0);
}
static void
{
int i;
for (i = 0; i < MAX_MAPS; i++) {
}
}
static void
{
if (!is_mcookie(d))
else
mcookie_to_addr(d));
}
static void
{
}
static void
{
}
static void
_init(void)
{
}