Subject: vtopte() problems
To: None <tech-kern@netbsd.org>
From: ycchang <ycchang@cirx.org>
List: tech-kern
Date: 05/21/2003 01:47:40
This is a multi-part message in MIME format.
------=_NextPart_000_003F_01C31F3A.F69EC3B0
Content-Type: text/plain;
charset="big5"
Content-Transfer-Encoding: quoted-printable
Hi all,
I am a kernel newbie of NetBSD.When I am trying to trace the kernel code =
of NetBSD, I have some problems about the definition of vtopte()
/* /usr/include/machine/pmap.h */
line 462:
static __inline pt_entry_t * __attribute__((__unused__))
vtopte(vaddr_t va)
{
KASSERT(va < (PDSLOT_KERN << PDSHIFT));
return (PTE_BASE + i386_btop(va));
}
=20
this inline funtion returns PTE_BASE + i386_btop(va) , where PTE_BASE =
=3D 0xbfc00000 and
i386_btop(va) is defined as ((unsigned)(x) >> PGSHIFT). That is to say =
it gets the VA of PTE=20
corresponding to a VA.=20
But in pmap.h , the comments say
/*=20
....
when the pmap code wants to find the
* PTE for a virtual address, all it has to do is the following:
*
* address of PTE =3D (767 * 4MB) + (VA / NBPG) * sizeof(pt_entry_t)
* =3D 0xbfc00000 + (VA / 4096) * 4
....
*/
So , should vtopte() return PTE_BASE + i386_btop(va)*4?=20
=20
=
Regards,
=
ycchang
------=_NextPart_000_003F_01C31F3A.F69EC3B0
Content-Type: text/html;
charset="big5"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi all,</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I am a kernel newbie of NetBSD.When I am trying to =
trace the=20
kernel code of NetBSD, I have some problems about the definition of=20
vtopte()</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>/* /usr/include/machine/pmap.h */</FONT></DIV>
<DIV><FONT size=3D2>line 462:</FONT></DIV>
<DIV><FONT size=3D2>static __inline pt_entry_t *=20
__attribute__((__unused__))<BR>vtopte(vaddr_t va)<BR>{</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2> =
KASSERT(va <=20
(PDSLOT_KERN << PDSHIFT));</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2> return =
(PTE_BASE +=20
i386_btop(va));<BR>}<BR> </FONT></DIV>
<DIV><FONT size=3D2> this inline funtion returns PTE_BASE +=20
i386_btop(va) , where PTE_BASE =3D 0xbfc00000 and</FONT></DIV>
<DIV><FONT size=3D2> i386_btop(va) is defined as ((unsigned)(x) =
>>=20
PGSHIFT). That is to say it gets the VA of PTE </FONT></DIV>
<DIV><FONT size=3D2> corresponding to a VA. </FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2> But in pmap.h , the comments say</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>/* </FONT></DIV>
<DIV><FONT size=3D2> ....</FONT></DIV>
<DIV><FONT size=3D2> when the pmap code wants to find =
the<BR> * PTE for=20
a virtual address, all it has to do is the =
following:<BR> *<BR> *=20
address of PTE =3D (767 * 4MB) + (VA / NBPG) *=20
sizeof(pt_entry_t)<BR> * &n=
bsp; =20
=3D 0xbfc00000 + (VA / 4096) * 4<BR> ....</FONT></DIV>
<DIV><FONT size=3D2>*/</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>So , should vtopte() return PTE_BASE + =
i386_btop(va)*4?=20
</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2> </FONT></DIV>
<DIV><FONT=20
size=3D2> &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p;  =
; =20
Regards,</FONT></DIV>
<DIV><FONT size=3D2> =
=20
=
=20
=
=20
=
=20
=
=20
=
=20
=
=20
=
ycchang</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_003F_01C31F3A.F69EC3B0--