[Prev][Next][Index][Thread]

Re: switching to real mode



On Wed, Dec 22, 1999 at 09:55:41AM -0700, Kevin Van Maren wrote:

> I am afraid that much of that code may have atrophied lately.  I did look
> at getting the DOS stuff working again last summer, but there aren't
> a lot of developers using 16-bit code for more than getting into 32-bit
> mode (and that is usually all in assembly language).
 
  I could stay in 32bit mode for loading Linux, but not DOS/Win*. I'm
writing a network boot loader. NILO works similar to netboot, but among
other things, as a Intel PXE compliant boot ROM, as well as support for
loading various kernels. Suggestions appreciated... but right now I only
want to switch to real mode to launch the 16bit startup code netboot's
(the other one) mknbi-* prepends to the kernel. (I use a Tagged Image
format, which for netbooting, is better than multiboot) I'm consider rewriting
mknbi-* to use 32bit mode for FreeBSD and Linux, but have special 16bit
support for DOS/Win*, but that would be a big project. I never thought
switching to real mode would be such a complex mess.

> A big part of the problem is the lack of better support from the
> compiler/assembler.  The gcc/gas people don't care about compiling C
> for a 16-bit enviroment.

  For sure... I have some autoconf support for testing GAS to see which form
of addr32, etc... it uses, if at all. 

> Real mode uses segmented addresses, and can address only the first 1 MB of
> memory: (segment << 4) + offset
> You can address this entire amount, but you have to do it manually --
> which confuses gcc/gas to no end.
 
  That's what I've been doing. I've had to hack all the addresses to work
when relocated to 0x7c00. A definete pain in the ass...

> You can use any 64k segment, as long as you set up the segment registers
> and use the offsets within the segment -- since only the offsets matter
> with 16-bit addressing the segment can be anywhere in the low 1MB.
> So it may look like it was linked at 0:1000, but it can be at 8000:1000,
> as long as you set up the segment registers.  But like he mentioned,
> that is not done automatically by the assembler & the macros.
 
  I think a large part of my problem is understanding segment registers. I've
always been a 32bit embedded RISC programmer, and the x86 is a weird
architecture after you've been on sparcs, pa-risc, or mips...

> The OSKit's support came from a DOS Extender called MOSS (another project
> at the University of Utah, by Bryan Ford).  You may want to look at that
> for parts as well.  See http://www.cs.utah.edu/flux/moss/
> It has probably bit-rotted, but the 16-bit code should be more intact
> than it is in the OSKit.

  Cool, I'll check it out.
	
	- rob -

References: