[comp.os.minix] Cross compiling under Turbo C

young@cxsea.UUCP (Gary Young) (03/24/89)

I am posting this to the net, as it may be of interest to others like
myself, who are casual readers of the news group.

In reply to your email:

>> Subject: Re: Cross Compiling under TurboC
>> 
>> Gary, I am attacking MINIX with Turbo C as several others are judging
>> by recent comp.minix articles.  My goal is to get minix up on my COMPAQ
>> SLT-286.  Right now I'm sitting with just the nine 5 1/4" floppies that
>> came with the MINIX book and a 3 1/2" drive in my COMPAQ.
>> 
>> How did you get the sources into DOS format?
>> 
>> - Roger Frank
>>   Sun Microsystems, Inc.
>> 

To get the sources to DOS you need to be able to run minix from the boot
disk.  Therefore, you should find someone with a MSDOS machine with 5 1/4"
floppies.  In minix, per the book, you can then use the 'doswrite' command
to transfer files to MSDOS disks.  It is fastest if you use 'tar' to combine
lots of files into one, as the 'doswrite' is very slow at creating files.
That means that you need a version of tar for the MSDOS.  There are a number
of public domain ones.  I use one I got off the net.

Next you have to transport the 5 1/4" MSDOS files to 3 1/2" disks.  Some
machines have both and you just copy.  I use 'mskermit', from the net, to
transfer using the serial ports between a machine with 5 1/4" disks and
one with 3 1/2" disks.

Now you have the source on MSDOS with 3 1/2" disks.  The next part, I must
admit, I have not yet done.  That is to build a minix system on the Turbo
C system.  I have built commands and used the minix 'dosread' to transport
them, and they have run.  The part that I haven't done is to create the
boot module and get it on a bootable disk.  I am sure that you could do it
with the Norton utilities to write absolute sectors, or you could write
a program to do it.  I don't remember if there is a MSDOS tool with the minix
stuff to do it.

Sorry that this is such a RueGoldburg, but it is the method that I intend to
use.  I have a pc clone with 5 1/4" disks, and hard drive, and a Toshiba 1000
lap top with 3 1/5" drives.  I intend to get minix working on the Toshiba
from the 5 1/4" distribution minix disks, as you want to do.

I will not be at this address much longer, but you can call or write me at
home:
	Gary H. Young
	21225 N.E. 12th Street
	Redmond, Wa. 98053
	206-868-1458 voice
	206-868-0671 bulletin board (sometimes, still experimental)

If I get the boot module built, I could post it to the download area
of the bulletin board.  The source is copyright by P.H., so I could
not make that available.


     /*	    Programming is a series
	of discoveries leading you from
	 one plateau of understanding
	to another ... the trick is not		   Gary H. Young
	 to step in the stuff between		   cxsea!young (cXnet)
	         the plateaus		*/	   (206) 251-6804 voice

/* "The nice thing about standards is that there are so many to choose from."
	Andrew S. Tanenbaum. */
-- 
Gary H. Young    young@cxsea.UUCP   ...{mnetor,uw-beaver!ssc-vax}!cxsea!young
+1 206 251 6098  Motorola Computer X Inc. - a Motorola New Enterprise company

dono@killer.Dallas.TX.US (Don OConnell) (03/25/89)

This describes the general changes needed to compile MINIX under the Turbo C
1.5 compiler, with the Microsoft assembler. I have used TC15 and Masm to go
from v1.1 to 1.4+, and haven't had many problems in compiling. An added
advantage is 1/2 to 3/4 savings in compilation time.  The executables tend
to be smaller, also.

1.  Make a complete copy of your current Minix system.

2.  Create subdirectory's like these (dos side):

        turboc                      ----    Main TURBO C directory
            minix                   ----    Sources Main directory
                commands            ----    Source directories
                commands\mined      ----
                commands\sh         ----
                fs                  ----
                kernel              ----
                lib                 ----
                mlib                ----
                mm                  ----
                tools               ----

3.  Boot Minix and use the doswrite program to copy the sources to
    DOS-formatted disks (NOTE * below). The compiler-specific modules
    are stored in subdirectories like MINIX, PCIX and C86; use the ones
    for the C86 compiler and modify them appropriately.  After this,
    reboot under DOS and copy the files to your Minix-directory.

    * If you have cpio or a compatible tar and compress/uncompress/zcat
      that runs under Minix and Dos use it, it takes less disks to
      transfer files. *

4.  You're now ready to build the Minix library; when Turbo C does long
    arithmetic, it uses a number of library routines that are unique to
    Turbo C and therefore not included in the Minix library. These
    modules will have to be retrieved from the CS.LIB that came with
    your Turbo C compiler.

    Using a librarian, extract the following modules from CS.LIB;

      ldiv.obj   lrsh.obj   lxmul.obj   spush.obj   scopy.obj

    Next step is compiling the files in the LIB-directory.

    * Use these files:
        prologue.h              --  needed by .asm files
        getutil.asm, catchsig.asm, portio.asm, sendrec.asm, setjmp.asm
      These are executable headers:
        crtso.asm, head.asm     --  See * below
      You won't need these files under TC:
        brksize.asm, end.asm    --  incorporated into crtso/head
        csv.asm                 --  not used
        diskio.asm              --  Turbo has functions to do this

    Using a librarian make the library. The order that I use for my
    v14a lib, along with most of the assembler needed files, have been
    previously posted

    * Head.obj and crtso.obj do not go in the lib. They are linked in
      from the command line. The head/crtso module, that I use are
      modified from the turbo c file - c0.asm. As a result of this, I
      compile in tiny model, but head/crtso are written in such a way,
      that split I/D programs are created automatically. *

5.  Having created the library, you can proceed and compile FS, MM and
    the KERNEL by going to their respective directories and compiling
    the sources. The klib88.s and mpx88.s will have to be converted to
    masm syntax.


6.  Next items are the files in the TOOLS directory; to write a
    boot-disk you'll need to compile DOS2OUT, BUILD, INIT and FSCK.

        FSCK1.s will have to be converted to masm syntax.

        Bootblok.s will also have to be converted to masm syntax. I use
        an ega monitor, and added code to mine to set the pallette
        colors(yellow on blue), and put the monitor in 43 line mode).

    * Dos2out and build are files that have to be compiled with the
      standard turbo c libraries and run as .exe files on the dos
      side.  *

    ** To create a boot disk use a freshly formatted disk

    To create file-systems for Minix from DOS, you'll need MKFS; it's in
    the COMMANDS directory. Just copy it to the TOOLS dir and compile it.

**  BEWARE:  Any program containing setjmp() and longjmp() *MUST* be
    compiled with the -r- option (note: that's "-r-" !) as Turbo C
    doesn't store it's register variables into memory before a
    setjmp()/longjmp(). This is a documented "feature" of the standard
    Turbo C library version of setjmp() so you can use it to implement a
    kind of task-switches (co-routines).

    In the part of the book concerned with using DOS as a development
    system for Minix, AST mentions the routines csv and cret. So far, I
    have used Turbo C with stack-overflow testing OFF so I haven't
    needed them. In case you would like to do this sort of checking, all
    you have to do is write a replacement for the OVERFLOW@ routine that
    is called just after the routine is entered. You cannot use the
    Turbo C version since it does a direct DOS call if my information
    correct. You can however use that version as a basis for further
    development; best thing to do is to compile a short program with
    Stack Overflow Test ON and Map File ON and then use SYMDEB or
    something like that to peek at the code generated.


Don O'Connell       Mar. 23, 1988               killer!dono