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>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
KASSERT(va &lt;=20
(PDSLOT_KERN &lt;&lt; PDSHIFT));</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
(PTE_BASE +=20
i386_btop(va));<BR>}<BR>&nbsp;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;this inline funtion returns PTE_BASE&nbsp;+=20
i386_btop(va) , where PTE_BASE =3D 0xbfc00000 and</FONT></DIV>
<DIV><FONT size=3D2>&nbsp; i386_btop(va) is defined as ((unsigned)(x) =
&gt;&gt;=20
PGSHIFT). That is to say it gets the VA of PTE </FONT></DIV>
<DIV><FONT size=3D2>&nbsp; corresponding to a VA. </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;But in pmap.h , the comments say</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>/* </FONT></DIV>
<DIV><FONT size=3D2>&nbsp;....</FONT></DIV>
<DIV><FONT size=3D2>&nbsp; when the pmap code wants to find =
the<BR>&nbsp;* PTE for=20
a virtual address, all it has to do is the =
following:<BR>&nbsp;*<BR>&nbsp;*=20
address of PTE =3D (767 * 4MB) + (VA / NBPG) *=20
sizeof(pt_entry_t)<BR>&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D 0xbfc00000 + (VA / 4096) * 4<BR>&nbsp;....</FONT></DIV>
<DIV><FONT size=3D2>*/</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>So , should vtopte() return PTE_BASE + =
i386_btop(va)*4?=20
</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Regards,</FONT></DIV>
<DIV><FONT size=3D2>&nbs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