From owner-freebsd-chat Fri Jun 22 14:20: 9 2001 Delivered-To: freebsd-chat@freebsd.org Received: from probity.mcc.ac.uk (probity.mcc.ac.uk [130.88.200.94]) by hub.freebsd.org (Postfix) with ESMTP id B2CF137B401 for ; Fri, 22 Jun 2001 14:20:03 -0700 (PDT) (envelope-from jcm@freebsd-uk.eu.org) Received: from dogma.freebsd-uk.eu.org ([130.88.200.97] ident=root) by probity.mcc.ac.uk with esmtp (Exim 2.05 #7) id 15DYLS-000KU4-00; Fri, 22 Jun 2001 22:20:02 +0100 Received: (from jcm@localhost) by dogma.freebsd-uk.eu.org (8.11.3/8.11.1) id f5MLK1V64905; Fri, 22 Jun 2001 22:20:01 +0100 (BST) (envelope-from jcm) Date: Fri, 22 Jun 2001 22:20:01 +0100 From: j mckitrick To: Terry Lambert Cc: Michael Lucas , Dag-Erling Smorgrav , freebsd-chat@FreeBSD.ORG Subject: Re: most complex code in BSD? Message-ID: <20010622222000.C64495@dogma.freebsd-uk.eu.org> References: <20010622062238.A45123@blackhelicopters.org> <200106222114.OAA28441@usr06.primenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <200106222114.OAA28441@usr06.primenet.com>; from tlambert@primenet.com on Fri, Jun 22, 2001 at 09:14:56PM +0000 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org I found this in a link given to me by mike meyer. It's from Ritchie's webpage: retu(rp->p_addr); sureg(); /* * If the new process paused because it was * swapped out, set the stack level to the last call * to savu(u_ssav). This means that the return * which is executed immediately after the call to aretu * actually returns from the last routine which did * the savu. * * You are not expected to understand this. */ if(rp->p_flag&SSWAP) { rp->p_flag =& ~SSWAP; aretu(u.u_ssav); } /* * The value returned here has many subtle implications. * See the newproc comments. */ return(1); So we tried to explain what was going on. "You are not expected to understand this" was intended as a remark in the spirit of "This won't be on the exam," rather than as an impudent challenge. | That's the startup code following relocation, where they push | a return address value on the stack, and then return to start | running on a different stack. | | In FreeBSD, this is in /sys/i386/i386/locore.s: | | ------------------------------------------------------------------------- | /* Now enable paging */ | movl R(_IdlePTD), %eax | movl %eax,%cr3 /* load ptd addr into mmu */ | movl %cr0,%eax /* get control word */ | orl $CR0_PE|CR0_PG,%eax /* enable paging */ | movl %eax,%cr0 /* and let's page NOW! */ | | #ifdef BDE_DEBUGGER | /* | * Complete the adjustments for paging so that we can keep tracing through | * initi386() after the low (physical) addresses for the gdt and idt become | * invalid. | */ | call bdb_commit_paging | #endif | | pushl $begin /* jump to high virtualized address */ | ret | | ------------------------------------------------------------------------- | | It's not that hard to understand, since it's in assembly language; | the original stack-SPAM from C was much, much dirtier, and ended up | being non-portable. | | -- Terry Jonathon -- Microsoft complaining about the source license used by Linux is like the event horizon calling the kettle black. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message