Date: Fri, 22 Jun 2001 22:20:01 +0100 From: j mckitrick <jcm@FreeBSD-uk.eu.org> To: Terry Lambert <tlambert@primenet.com> Cc: Michael Lucas <mwlucas@blackhelicopters.org>, Dag-Erling Smorgrav <des@ofug.org>, freebsd-chat@FreeBSD.ORG Subject: Re: most complex code in BSD? Message-ID: <20010622222000.C64495@dogma.freebsd-uk.eu.org> In-Reply-To: <200106222114.OAA28441@usr06.primenet.com>; from tlambert@primenet.com on Fri, Jun 22, 2001 at 09:14:56PM %2B0000 References: <20010622062238.A45123@blackhelicopters.org> <200106222114.OAA28441@usr06.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010622222000.C64495>