Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Dec 1998 12:09:58 -0500 (EST)
From:      zhihuizhang <bf20761@binghamton.edu>
To:        hackers <freebsd-hackers@FreeBSD.ORG>
Cc:        dfr@nlsystems.com
Subject:   Definition of kstack and PTDpde in locore.s
Message-ID:  <Pine.SOL.L3.93.981205235032.29498A-100000@bingsun1>

next in thread | raw e-mail | index | archive | help

Hi, Back in August, I posted a question about whether .set _xx, 30 in
assembly defines the value of xx or the address of xx (xx is the
counterpart of _xx in C). The response I got is that the address of xx is
30. (note that xx without preceding "_" is used in C). 

So the address of PTDpde is PTD + (PTDI * PAGE_SIZE) (see locore.s).  This
explains why the statement (unsigned)PTDpde & PG_FRAME gives the
"physical" address of the page directory page of the current address
space.  We often use the following condition in pmap.c to see if the given
pmap uses the same page directory page as the curent address space. 

  if ((((unsigned)pmap->pm_pdir[PTDPTDI]) & PG_FRAME) ==
                        (((unsigned) PTDpde) & PG_FRAME)) { ... }    

So far, it is fine for me.  Yesterday, I came across the symbol kstack
which is defined similary via the .set directive in locore.s.  However, in
pmap.c, I find the following usage:

 m = pmap_allocpte(pmap, (vm_offset_t) kstack);   

So kstack must be a virtual address (I means its value).  However,
according to my undestanding derived from PTDpde, the kstack should be
stored at the fixed virtual address (VADDR(KSTKPTDI, KSTKPTE)), its value
is another thing (should be initialized some where).  But the
pmap_allocpte() statement clearly requires kstack's value and, I guess the
kernel stack for each process should be at the same VA.  So, what does the
following statement do (in locore.s): 

   .set    _kstack,USRSTACK (note: USRSTACK = VADDR(KSTKPTDI, KSTKPTEOFF))

Does it give the address of kstack or value of kstack?  The GAS only says
it gives the value of the symbol.

I really have problem with mixed assembly and C programming when they
reference the same symbols (one with the preceding "_" and one without
"_").  I hope some one can clarify these stuff for me.

Thanks a lot.

-------------------------------------------------- 
| Zhihui Zhang, http://cs.binghamton.edu/~zzhang |
| Dept. of Computer Science,  SUNY at Binghamton |
--------------------------------------------------








To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.L3.93.981205235032.29498A-100000>