Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!daver!bungi.com!news From: kls@ditka.UUCP (Karl Swartz) Newsgroups: comp.sys.nsc.32k Subject: ten days with Minix Message-ID: <9009100320.AA22237@ditka.UUCP> Date: 10 Sep 90 10:20:08 GMT Sender: news@daver.bungi.com Lines: 374 Approved: news@daver.bungi.com In the past ten days I've spent a lot of time working on and with Minix, and I'm still as impressed as last time I wrote. But the road is far from smooth. Here is a condensation of my notes which hopefully will help guide others along the path. disk partitions I've kept the partitions as Bruce built them, using hd3 as my / (root) filesystem (you'll need to patch the kernel to make this the default) and hd4 for /u (home directories for users). I kept the initial mini-system in hd2, safe in case I need it to save my butt, and hd5 is a scratch area. (I've configured in additional partitions beyond hd5 for more scratch space.) One gotcha is that the ROM monitor talks about physical blocks on the drive, which are 512 bytes long, while the numbers in the partition table are in 1024 byte logical blocks. Some day I'll learn but I still end up being very puzzled every time I look at this until I again learn this. For reference, here is a list of partitions and where the ROM monitor thinks they live: /dev start size (hex/dec) phys block hd0 0 9d40 / 40256 0 hd1 0 100 / 256 0 hd2 100 2710 / 10000 200 hd3 2810 2710 / 10000 5020 hd4 4f20 2710 / 10000 9e40 hd5 7630 2710 / 10000 ec60 multiple kernel images You've got room for several kernels in the hd1 partition so it's a nice idea to make a duplicate in case you screw something up. Use the ROM monitor to do this: Command (? for help): read 0 2000 80 Command (? for help): write 100 2000 80 To run one of the kernels enter Command (? for help): read X 2000 80 Command (? for help): run 2000 where X is either 0 or 100 depending on where you want the main or the backup kernel image. loading the rest of the files I did this step from Bruce's "install" notes two pieces at a time, saving one piece to hd4 (write to 9e40) and the other to hd5 (write to ec60) in each pass. It still is tedious, but with half as many reboots it's gotta be better. include files Like any sane individual I immediately started tinkering with my new system, bypassing the documentation and most of the README files. (Documentation?! We don't need no steenking documentation!) Unfortunately, this means you'll probably miss a critical step -- some important include files. Go read the README in /usr/src, or wherever your sources ended up, and make the appropriate links. important utilities Take a look in /usr/src/commands for several utilities you will want to compile and install in /etc. Amongst these, bpt and fsck will be particularly desireable. You'll also want to recompile postmort and replace the version that's already in /usr/bin as it has a bad path wired into it. increase size of disk cache Dave Rand suggested increasing the size of the disk cache from 128 KB to 1 MB. Assuming your Minix kernel source lives in /usr/src/minix like mine does, look in fs/const.h for a line like #define NR_BUFS 128 and change 128 to 1024. Make sure that you do this in the else part of the conditional. Rebuilding this kernel from scratch took about ten and a half minutes, 10:29 to be precise. After booting this new kernel (see next two sections) I cleaned the slate and built the same kernel again. This time the time was 2:10! This is a big win, folks! building a kernel Before typing make, you need to make a few chanes to the Makefile in /usr/src/minix. First, unless you have an OMTI controller like Bruce, you'll want to comment out the rule for "all" and the next couple of lines. Add a new line that says simply "all: dist" and life will be much easier. Also, the four lines that tell make where to find various tools (as, cc, ld, nm) have a comment saying to comment them out on the pc532. Unfortunately make doesn't know about at least one of them (probably nm but I've forgotten) so just change the path on each one to /usr/bin. installing your new kernel If you followed the hints I offered above, it's easy. Just follow these steps: $ su Password: # cat image >/dev/hd1 # sync; bpt ... hardware reset Command (? for help): read 0 2000 80 Command (? for help): run 2000 If something went awry, just go back and read the backup kernel from block 100. (You did make one didn't you?) setting the real-time clock Bruce's instructions for setting the clock use his floppy drive. If you don't have a floppy (like me), just use a scratch partition on your hard disk. Assuming hd5 is free for this use, do this after editing rtc.s: $ as rtc.s $ su Password: # cat image >/dev/hd5 # sync; bpt ... hardware reset Command (? for help): read ec60 2000-30 2 Then continue with Bruce's directions. tailoring boot options once and for all If you have a clock chip and normally boot from hd3 as I do, you'll want to change several lines in kernel/mpx32k.s: _have_rtc:: double 1 ROOT_MINOR: .equ 3 tty driver drops NUL characters The tty driver throws away incoming NULs even in raw mode, which is hell on communications protocols like uucp. To correct this, look in file kernel/tty.c near the top of the in_char() routine. Find the line if (ch == 0) return; and delete it. multiple tty lines The distributed tty driver appears to have a bug that hangs the system if both ports on the same DUART are active at the same time. With 4 DUARTs available just use a different one. You'll have to make some device files though since only the first two ports are in the distributed system: # su Password: # for i in 2 3 4 5 6 7; do ? mknod /dev/tty$i c 3 $i ? done # Set the protection and ownership of the new files to match /dev/tty1. increasing number of processes With the disk cache increased it's almost reasonable to try doing other work while make is running in the background. But the stock kernel is only built for 16 processes, which can quickly be used up. Edit h/const.h; change the define for NR_PROCS as desired. (I set mine to 32.) large partitions I have one of the Miniscribe 9380S drives (after plunking down a check for 50 of them you better believe I got one for myself!) and of course wanted to use big partitions. A 30,000 block partition worked fine, but 60,000 resulted in a panic as soon as I tried to mount it. The "obvious" solution was to increase ZMAP_SLOTS (in fs/const.h) but this resulted in a kernel that wouldn't boot -- somewhere near when I'd expect the disk mounts to be done it simply did a breakpoint trap back to the ROM monitor. Until somebody works on this, don't expect big partitions to work. startup and shutdown There's some cleanup you should probably do on startup and shutdown of the system. The shell archive at the end of this message includes an /etc/shutdown and a new /etc/rc script that do a few more desireable things. Note that rc says "Invalid errno" when it clears /etc/wtmp but it still works. more include files Several include files that one would expect to find with GCC are missing. I've included two in the attached shell archive that came from the 3B1 GCC but appear to be proper for a pc532. We still need float.h. floating point library routines Neither printf() nor scanf() seem to work correctly. I'll take a look at these as soon as I get the sources. The libm.a library should have a fabs() routine but does not. I wrote the obvious C routine but didn't like the code generated by GCC so wrote it myself; this is in the attached archive. Other routines probably are missing ... uucp I've gotten the uucp from the NLMUG working and added many enhancements, though it still doesn't know how to dial out. A fully functional version is waiting on some fixes to the tty driver which Dave is working on. If anybody wants what I have now let me know and I'll send cdiffs for the affected files, or post them to the mailing list if there's enough interest. mail, smail2.5 I've also gotten both of these running. I'll include notes with the uucp stuff. Well, that's probably enough for one night. I hope this helps a few of you out there. (Appended to this message is the shell archive of files mentioned above.) -- Karl Swartz |UUCP uunet!apple!zygot!ditka!kls 1-408/223-1308 |INet zygot!ditka!kls@apple.com "I never let my schooling get in |BIX kswartz the way of my education."(Twain) |Snail 1738 Deer Creek Ct., San Jose CA 95148 --- cut here --- #!/bin/sh # # This is a shell archive. Feed it to /bin/sh to unpack these files: # # ./etc/rc # ./etc/shutdown # ./usr/include/stdarg.h # ./usr/include/stddef.h # ./usr/src/libm/fabs.s # echo "creating ./etc/rc" sed -e 's/^@//' <./etc/rc @#!/bin/sh @ @# @# Disk management @# @#substitute your root device for "/dev/fd0" in the next line @echo "/dev/hd3 is mounted on /" >/etc/mtab @mount /dev/hd4 /u @rm -f /tmp/* @ @# @# Set date, clear wtmp, and display boot message @# @#/bin/date -q /usr/adm/wtmp @cat /etc/message @ @# @# Start daemons @# @/etc/update & EOF echo "creating ./etc/shutdown" sed -e 's/^@//' <./etc/shutdown @#!/bin/sh @ @PATH=/bin @ @# @# Dismount all filesystems. @# @cd / @cat /etc/mtab \ @| while read dev x1 x2 x3 dir; do @ case "$dir" in @ /) @ ;; @ /*) @ echo "/etc/umount $dev ($dir)" @ #/etc/umount $dev @ ;; @ *) @ echo "shutdown: bad mtab entry: $dev $x1 $x2 $x3 $dir" @ ;; @ esac @done @ @# @# Flush remaining disk buffers and get out. @# @sync @sync @sync @/etc/bpt EOF echo "creating ./usr/include/stdarg.h" sed -e 's/^@//' <./usr/include/stdarg.h @#ifndef _STDARG_H @#define _STDARG_H @ @typedef char *va_list; @ @/* Amount of space required in an argument list for an arg of type TYPE. @ TYPE may alternatively be an expression whose type is used. */ @ @#define __va_rounded_size(TYPE) \ @ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) @ @#ifndef __sparc__ @#define va_start(AP, LASTARG) \ @ (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) @#else @#define va_start(AP, LASTARG) \ @ (__builtin_saveregs (), \ @ AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) @#endif @ @void va_end (va_list); /* Defined in gnulib */ @#define va_end(AP) @ @#define va_arg(AP, TYPE) \ @ (AP += __va_rounded_size (TYPE), \ @ *((TYPE *) (AP - __va_rounded_size (TYPE)))) @ @#endif /* _STDARG_H */ EOF echo "creating ./usr/include/stddef.h" sed -e 's/^@//' <./usr/include/stddef.h @#ifndef _STDDEF_H @#define _STDDEF_H @ @/* Signed type of difference of two pointers. */ @ @typedef long ptrdiff_t; @ @/* Unsigned type of `sizeof' something. */ @ @#ifndef _SIZE_T /* in case has defined it. */ @#define _SIZE_T @typedef unsigned long size_t; @#endif /* _SIZE_T */ @ @/* A null pointer constant. */ @ @#undef NULL /* in case has defined it. */ @#define NULL ((void *)0) @ @/* Offset of member MEMBER in a struct of type TYPE. */ @ @#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) @ @#endif /* _STDDEF_H */ EOF echo "creating ./usr/src/libm/fabs.s" sed -e 's/^@//' <./usr/src/libm/fabs.s @.text @ .align 2 @.globl _fabs @_fabs: @ absl 4(sp),f0 @ ret 0 EOF