home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / Other / V6on286 / README next >
Encoding:
Internet Message Format  |  2002-07-08  |  5.6 KB

  1. From: "Szigeti Szabolcs" <szigi@ik.bme.hu>
  2. Subject: [TUHS] Re: Porting Unix v6 to i386
  3. Date: Tue, 4 Jun 2002 13:53:50 +0200
  4.  
  5. I've just joined your mailing list, and while looking at the archives, i saw
  6. this discussion on porting V6 to Intel.
  7. Well, back in '92, in a university scinence students' competition, I ported
  8. v6 to intel286 in protected mode. (I got second place, the winner was a 3D
  9. animation prog, which is more spectacular, than a # prompt :-)
  10.  
  11. I used Borland C to compile, with some extra mungling the assembly code ( i
  12. can't remember why).
  13.  
  14. The hard part was to understand the protected mode, and to write the low
  15. level stuff. Other things, like filesystem, etc. compiled with hardly any
  16. modification. (Had to change =+ to =+, introduce long insted of int[2],
  17. etc.). It has floppy, ide, kbd, parallel, serial and vga drivers.
  18.  
  19. It got to full multiuser operation, but there are bugs and stupid codings
  20. certainly. The C compiler, nroff, and some other parts were not ported.
  21. (Yes, I used Borland C to compile the programs, and a tool to convert it to
  22. a.out :-)
  23.  
  24. If anyone wants to experiment with it (some parts are pretty ugly, because i
  25. intedned to rewrite it, but never did, and the parts of the comments are in
  26. Hungarian), drop me an email (though i'm now doing my MBA thesis, so might
  27. not answer immediatey). If there is interest, I can summarize my
  28. experiences.
  29.  
  30. I've not looked it since several years, so i might not remember every
  31. detail, but there are some interesting point, and it was great fun to do.
  32.  
  33. Some notes:
  34.  
  35. The CONF, DMR, KEN and H directory contains the kernel sources, while
  36. INCLUDE and SRC the rest of the system.
  37. Tools in UTIL is used to compile these. c2a processes the kernel assembly,
  38. to change the segment names produced by the c compiler because of the
  39. protected mode (I used the command line version of Borland C++ 3.0, the
  40. makefiles are for this comiler).
  41. exe2v6 converts MSDOS exe to a.out (not all exe, it has to be compiled
  42. specially, see the makefile in SRC/UTIL). exetr is a horrible kludge to
  43. transfer files to v6, via a floppy disk, and mkfs is mkfs under Dos.
  44.  
  45. The kernel compiles in a funny way, you get a unix.exe, which can be run
  46. from dos, and if all is well, it can retorn to dos, with a magic key
  47. sequence (shift-esc ???). It speeds up development, cause you don't have to
  48. reboot.
  49.  
  50. The code is really ugly at some places, because i started experimenting with
  51. protected mode first, and never cleanly rewrote what worked. Once I startded
  52. to tidy up the code (move to ANSI C, etc), but never finished. Morover, in
  53. the process, I broke something in the fs code, so right now it won't mount
  54. root. Plus, much of the comments are still in Hungarian :-)
  55.  
  56. The kernel makes heavy use of the special 286 protected mode features
  57. (Tasks, etc.)
  58.  
  59. More notes:
  60.  
  61. First of all, the code is currently broken. Something is wrong, and it will
  62. not be able to mount the root fs or something, but shouldn't be hard to fix,
  63. because it used to work, and i did something wrong when playing with the
  64. code some years ago, with no backup to revert to.
  65.  
  66. Originally, I used the commnad line tools of Borland C++ 3.0 to compile. You
  67. need Turbo Assembler, so the Borland C++ 1.0, which is freely available from
  68. Borland as "antique software" is not enough, you'll need the professional
  69. version at least, because it has the command line assembler.
  70.  
  71. There is a top level makefile, which will create UN.EXE, this is the unix
  72. kernel. You run it under plain MSDOS, it will switch to protected mode, and
  73. with shift-esc it will return to DOS (do a sync before !). Probably it
  74. wouldn't be hard to make it work without DOS as a boot loader :-), but i
  75. never did it.
  76.  
  77. If compiled with -DSTANDSH, the kernel will be built with a built-in shell
  78. (see KEN/UPROC.C for the command), that can be used to do some basic setup.
  79. It will for example create the /dev/tty entries on a blank root disk. (You
  80. still need the mkfs utility under dos to make a blank disk). I suggest to
  81. use a floppy as a root disk for initial trials.
  82. If you omit STANDSH, it will look for /etc/init to run.
  83.  
  84. On the directory layout:
  85. CONF contains c.c, the device switch table
  86. DMR contains most of the device drivers
  87. H contains the kernel header files
  88. INCLUDE - the user header files
  89. KEN - rest of the kernel
  90.  
  91. The low level kernel code is very ugly, as it evolved from experimenting
  92. with protected mode. There are lots of things, that i'm not proud of :-)
  93.  
  94. SRC/CLIB0 - the C library
  95. SRC/SYSC - the syscall user side interface
  96. SRC/UTIL - the utilities and such, most should work
  97. UTIL - MSDOS utils to compile
  98.  
  99. In the UTIL directory, there are the following utlities:
  100.  
  101. c2a - used to compile the kernel, it search-and-replaces some stuff in the
  102. assemlby code, i don_t exactly remember why, but it has to do something with
  103. the segmenent names.
  104.  
  105. exe2v6 - utility to convert MSDOS exe program to a.out. See
  106. SRC/UTIL/Makefile for how to make such an exe. The programs have a built in,
  107. fixed size stack, because Borland C had problems separating code and stack
  108. segment. It could brobably be fixed, but i didn't do it, instead opted for
  109. fixed size stack, adjustable at compile time.
  110.  
  111. exetr - it can transfer a file to unix via a floppy drive, i don_t remember
  112. how it works, i think you put one file to a floppy, and use the kernel-shell
  113. to write it to a file-system. It is a really ugly idea :-)
  114.  
  115. dumpfs - it is broken, it was intended to back-up a filesystem
  116.  
  117. mkfs - MSDOS mode mkfs, answer the questions, you'll get the filesystem.
  118. There is no sanity check whatsoever, so be careful, it can screw your
  119. harddrive, if given wrong sector numbers.
  120.  
  121. So that's it, if someone wants to experiment with it, i can probably answer
  122. questions, but, i have to do some reverse engineering too!
  123.  
  124.     Szabolcs Szigeti
  125.