cyliax@bank.ecn.purdue.edu (Ingo Cyliax) (03/21/90)
Hi there, I'm currently working on a Minix-ST port to 68020 and have some comments/ questions about the implementation of the context save. The way Minix-ST does it's context save is roughly like this: (after an excpetion) 1. get pointer to process save area in process table 2. save all registers including the stackpointer (usp or ksp) and pc 3. switch to hardware context kernel stack (which looses all the state information on the kernel stack if the process was a user process). the restore goes something like this: (if not idle) 1. get pointer to process save area 2. restore registeres d0-d7,a0-a6 3. restore usp or ksp to process/task stack 4. handcraft an exception stack on current kernel stack 5. rte (return from exception, which restores pc and save sr) This is fine for a 68000, but on a 68010 and the 68020 an exception may store some state information if the exception is something like a buserr or address error that has to stop in the middle of an instruction and may want to continue (after paging in a missing page or doing an sbrk or stack extention for examnple). It signals this by dumping a "exception format word" on the stack, the format word tells you what kind of and how long the state information is. Right know I do the same thing that Minix-ST does, except that I correct the stackpointer for the extra status information if a get an exception while running a task (i.e. running on a kernel stack). This is only needed for kernel tasks, since they will have all the state info. on their run-time stack, but then they should never get a fault other than an interrupt or syscall. The right way to do this would be to keep a small kernel stack for each process that all the exception state can be kept on and restored after an exception. This would make the save and restore alot smaller and maybe faster. Does anyone have any thoughts about this ? I would eventually like to use the MMU and at least have memory protection as well as getting rid of the shadow stuff. Of course this would be dynamic, the kernel figures out if we have a standard MMU (68851 or MMU in 68030) and set a flag, the rest of the code would then decide wether it needs to do shadowing/relocation or use the MMU. Right now I can still do this with the Minix-ST context save/restore semantics, but I would rather do it right now so I have less problems later when I need it. Implementing paging would be fun :-)..... Thanks, -ingo /* Ingo Cyliax ECN, Electrical Engineering Bldg. * * cyliax@ecn.purdue.edu Purdue University, W. Lafayette,IN 47907 * * ing@cc.purdue.edu Work: (317) 494-9523 * * cyliax@pur-ee.UUCP Home: (317) 474-0031 */