From owner-freebsd-hackers Sun Dec 6 09:11:25 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA15980 for freebsd-hackers-outgoing; Sun, 6 Dec 1998 09:11:25 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from bingsun2.cc.binghamton.edu (bingsun2.cc.binghamton.edu [128.226.1.6]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA15939 for ; Sun, 6 Dec 1998 09:10:59 -0800 (PST) (envelope-from bf20761@binghamton.edu) Received: from localhost (bf20761@localhost) by bingsun2.cc.binghamton.edu (8.8.7/8.6.9) with SMTP id MAA03252; Sun, 6 Dec 1998 12:09:59 -0500 (EST) Date: Sun, 6 Dec 1998 12:09:58 -0500 (EST) From: zhihuizhang X-Sender: bf20761@bingsun2 Reply-To: zhihuizhang To: hackers cc: dfr@nlsystems.com Subject: Definition of kstack and PTDpde in locore.s Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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