[comp.os.minix] 386 Minix - first steps

brucee@runx.ips.oz (Bruce Evans) (10/07/88)

I just got Minix converted to run user processes >= 2 in 386 protected
mode. They still only have 64K segments because of compiler limitations,
and have (kernel) privilege 0 so the protection is incomplete. Interrupts
switch to real mode so the old tasks < 2 run unchanged. There is lots of
fiddly mode switching code in assembler, but the C code is only a new 15K
file and maybe 5K kernel diffs, mainly in system.c. When real mode is
eliminated, the assembler code will become much simpler than for the 8088.

This has been 100% reliable over 2 days while unpacking and installing 1.3c.

The user tasks should really be running at (lowest) privilege 3. I actually
had this, and MM and FS in protected mode too for a while, and downloaded
1.3c with it. But some programs core dumped and the floppy gave DMA overrun
errors, so I stepped back a version and then got sidetracked by 1.3c. I had
forgotten about some of the asm code in getutil.s (stupidly hidden in
libc.a). Get_tot_mem() failed early, so I just said 640K, but get_base()
used by fs just returns DS (segment) which fs multiplies by CLICK_SIZE and
fails when DS is just an index. I must ask kernel to look it up and return
phys_bytes instead of clicks. (Can we fix the standard system?) This will
fix the DMA bug and I must look at the other CLICK kludges for the core
dumps.

This has been an "interesting" project. Switching to and from real mode
bought me a lot of insight and a bootstrap platform, but the scaffolding
will be removed before anyone else sees it. I did lots of trial and error,
getting core dumps but rarely crashing the real mode kernel or debugger
(except core dumps themselves tended to corrupt disks when no sync was
possible - I should have disabled it but went ahead fearlessly with 80M
at risk :-)). Most exceptions were in the mode switching code but somehow
the system avoided infinite recursion (reset?). 

I can see getting this as far as all protected mode, reasonable privileges,
and optional 32 bit user processes, but addresses limited to 1M, with a
16 bit kernel. Of course this only scratches the surface of the processor's
capabilities.

When the real mode is eliminated, it should almost run on 286's, and perhaps
I should post it before it grows unwieldy. I'm using a home-made compiler,
assembler and linker, but asld could handle the 16 bit version with a small
number of magic .byte's.

Bruce Evans
Internet: brucee@runx.ips.oz.au    UUCP: uunet!runx.ips.oz.au!brucee