hat_kdi.c revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* HAT interfaces used by the kernel debugger to interact with the VM system.
* These interfaces are invoked when the world is stopped. As such, no blocking
* operations may be performed.
*/
#include <sys/kdi_impl.h>
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
#include <vm/seg_kmem.h>
#include <sys/machsystm.h>
/*
* The debugger needs direct access to the PTE of one page table entry
*/
/*
* Allocate virtual page to use for kernel debugger accesses to physical memory.
* This is done very early in boot - before vmem allocator is available, so
* we use a special hand picked address. (blech) The address is one page
* above where the hat will put pages for pagetables -- see ptable_alloc() --
* and is outside of the kernel's address space.
*
* We'll pick a new VA after the kernel's hat has been initialized.
*/
void
hat_boot_kdi_init(void)
{
/*
* The 1st ptable_va page is for the HAT, we use the 2nd.
*/
#if defined(__amd64)
hat_kdi_use_pae = 1;
hat_kdi_use_pae = 0;
#endif
}
/*
* Switch to using a page in the kernel's va range for physical memory access.
* We need to allocate a virtual page, then permanently map in the page that
* contains the PTE to it.
*/
void
hat_kdi_init(void)
{
/*
* Get an kernel page VA to use for phys mem access. Then make sure
* the VA has a page table.
*/
/*
* Get an address at which to put the pagetable and devload it.
*/
}
/*ARGSUSED*/
int
{
int level;
int index;
/*
* if the mmu struct isn't relevant yet, we need to probe
* the boot loader's pagetables.
*/
if (!khat_running) {
return (ENOENT);
return (ENOENT);
return (0);
}
/*
* We can't go through normal hat routines, so we'll use
* kdi_pread() to walk the page tables
*/
pte = 0;
return (ENOENT);
if (pte == 0)
return (ENOENT);
(pte & PT_PAGESIZE)) {
break;
} else {
if (level == 0)
break;
}
}
return (0);
}
static int
{
/*
* if this is called before any initialization - fail
*/
if (hat_kdi_page == 0)
return (EAGAIN);
while (nbytes > 0) {
/*
* figure out the addresses and construct a minimal PTE
*/
if (doread) {
} else {
}
/*
* map the physical page
*/
if (hat_kdi_pte == NULL)
else if (hat_kdi_use_pae)
*hat_kdi_pte = pte;
else
/*
* erase the mapping
*/
if (hat_kdi_pte == NULL)
else if (hat_kdi_use_pae)
*hat_kdi_pte = 0;
else
*(x86pte32_t *)hat_kdi_pte = 0;
}
if (ncopied == 0)
return (ENOENT);
return (0);
}
int
{
}
int
{
}
/*
* Return the number of bytes, relative to the beginning of a given range, that
* are non-toxic (can be read from and written to with relative impunity).
*/
/*ARGSUSED*/
{
#ifdef __amd64
extern uintptr_t toxic_addr;
extern size_t toxic_size;
/*
* Check 64 bit toxic range.
*/
if (toxic_addr != 0 &&
/*
* avoid any Virtual Address hole
*/
return (sz);
#else
uintptr_t v;
if (v == 0)
return (sz);
else if (v <= va)
return (0);
else
return (v - va);
#endif
}
void
hat_kdi_fini(void)
{
}