cavender@drivax.UUCP (04/28/87)
I've had good success with bringing MINIX 1.1 up on my Compaq portable. It's running a V20 (4.77MHz). My hard disk is a CompuAdd 20Mb (3.5") drive, which uses one of the WD 100x controllers, so Gary Oliver's 'wini.c' diff got that up and running. I've partitioned it as (1) 15Mb DOS bootable and (2) 5Mb for MINIX /usr. I have a change in the printer driver that makes printer determination more reliable (at least on BIOS compatible clones). In 'printer.c', the routine 'print_init()' checks to see whether the display is monochrome or color. If mono, then the printer port base is set to the adapter on the monochrome card, otherwise it is set to the alternate adapter address. However, for those of us with compatible clones, this is often not a valid assumption. At 'print_init()' time, the BIOS variables are still valid, however, and location 0000:0408 is defined to contain the base address of the primary printer, so make the following change to 'printer.c': /*===========================================================================* * print_init * *===========================================================================*/ PRIVATE print_init() { int i; port_base = get_word(0,0x408); /* Get port base address from BIOS */ pr_busy = FALSE; port_out(port_base + 2, INIT_PRINTER); for (i = 0; i < DELAY_COUNT; i++) ; /* delay loop */ port_out(port_base + 2, SELECT); } and then add the following lines to 'klib88.s': ... (at the front) .globl _get_word ... (and down after 'get_byte') |*======================================================================* |* get_word * |*======================================================================* | This routine is used to fetch word from anywhere in memory. | The call is: | i = get_word(seg, off) | where | 'seg' is the value to put in es | 'off' is the offset from the es value _get_word: push bp | save bp mov bp,sp | we need to access parameters push es | save es mov es,4(bp) | load es with segment value mov bx,6(bp) | load bx with offset from segment seg es | go get the word mov ax,(bx) | ax = word pop es | restore es pop bp | restore bp ret | return to caller ============================================================================== Last, but not least, some DOS utilities. If you don't have COPYIIPC or some other disk image copier for making backups before you begin modifying sources, AND your system only has one floppy drive, you need help (so do I, that sentence was too long). Here is a matching set of utilities for making those backups. FREAD and FWRITE are included here as as source. They were written for MSC 4.0. FREAD copies the entire floppy image (360Kb) to a file on the hard disk; FWRITE puts the image back out to a floppy. They are very simple-minded, but they're all I needed to get my backup copies made, and they run surprisingly fast. They are probably extremely innovative routines, but as it only took a few minutes to write them, I saw no need to copyright them. Use them but don't abuse them. If you don't have any tools available to compile these, let me know, and I can either mail or post the binaries (of FREAD and FWRITE, not the compiler). I haven't included them in this posting, because in uuencoded, 'arc'ed form they run about 19Kb, and I wasn't sure that such volume was called for. /* fread.c "Share and Enjoy" */ #include <ctype.h> #include <dos.h> #include <stdio.h> union REGS reg; char buffer[4608]; track_io( io, disk, track, head ) int io, disk, track, head; { reg.h.ah = (io == 0) ? 2 : 3; reg.h.al = 9; reg.h.ch = track; reg.h.cl = 1; reg.h.dh = head; reg.h.dl = disk; reg.x.bx = (int)buffer; int86( 0x13, ®, ® ); return( (reg.x.cflag & 1) ? reg.h.ah : 0 ); } main( argc, argv ) int argc; char *argv[]; { int disk, track, head; FILE *fimage; if ( argc != 3 ) { printf( "Usage is: fread d: filename" ); exit( 1 ); } disk = toupper( *argv[1] ) - 'A'; if ( (fimage = fopen( argv[2], "wb" )) == NULL ) { printf( "Unable to open %s", argv[2] ); exit( 1 ); } for ( track = 0; track < 40; track++ ) { for ( head = 0; head < 2; head++ ) { if ( track_io( 0, disk, track, head ) ) { printf( "Error on floppy read" ); exit( 1 ); } fwrite( buffer, 1, 4608, fimage ); } } fclose( fimage ); } /* fwrite.c "Share and Enjoy" */ #include <ctype.h> #include <dos.h> #include <stdio.h> union REGS reg; char buffer[4608]; track_io( io, disk, track, head ) int io, disk, track, head; { reg.h.ah = (io == 0) ? 2 : 3; reg.h.al = 9; reg.h.ch = track; reg.h.cl = 1; reg.h.dh = head; reg.h.dl = disk; reg.x.bx = (int)buffer; int86( 0x13, ®, ® ); return( (reg.x.cflag & 1) ? reg.h.ah : 0 ); } main( argc, argv ) int argc; char *argv[]; { int disk, track, head; FILE *fimage; if ( argc != 3 ) { printf( "Usage is: fwrite filename d:" ); exit( 1 ); } if ( (fimage = fopen( argv[1], "rb" )) == NULL ) { printf( "Unable to open %s", argv[1] ); exit( 1 ); } disk = toupper( *argv[2] ) - 'A'; for ( track = 0; track < 40; track++ ) { for ( head = 0; head < 2; head++ ) { fread( buffer, 1, 4608, fimage ); if ( track_io( 1, disk, track, head ) ) { printf( "Error on floppy write" ); exit( 1 ); } } } fclose( fimage ); } -- Steve Cavender Digital Research, Inc.|(My opinions. You can't have them.) USENET: cavender@drivax.UUCP |"The size of the FAT for a 128 giga- Telex: 9102406616 TAG SEMI SEA UQ |byte disk is unpleasant to contem- EasyLink: 62211010 |plate." -- Andrew S. Tanenbaum
rcodi@yabbie.oz (Ian Donaldson) (05/01/87)
In article <1416@drivax.UUCP>, cavender@drivax.UUCP (Steve Cavender) writes: > FREAD and FWRITE are included here as as source. They were written > for MSC 4.0. FREAD copies the entire floppy image (360Kb) to a file on the hard > disk; FWRITE puts the image back out to a floppy. They are very simple-minded, > but they're all I needed to get my backup copies made, and they run > surprisingly fast. <code supplied here> A question: why do you need a special program to do this? Surely the "cp" or "dd" commands can do this by something like: cp /dev/rflp file or: dd if=/dev/rflp of=file "rflp" might be the name of the RAW floppy device (I don't know exactly what its called on MINIX since I don't have the source yet) If MINIX is reasonably V7 compatable, both these commands should be equivalent to the FREAD program supplied. Similarly for FWRITE. And they -don't- depend on any hardware or interrupt vectors like the given programs. If you want it to go faster you can put a "bs=64k" on the "dd" command, if 64k dma is possible (or simulated). You should be able to achieve the same sort of speed that the given programs would have achieved this way. If the kernel doesn't support the raw floppy device, then code should be added to the kernel. I just dislike programs that go straight to the hardware if there is a portable way to do it and utilities already exist. Ian D
rmtodd@uokmax.UUCP (Richard Michael Todd) (05/02/87)
In article <450@yabbie.oz>, rcodi@yabbie.oz (Ian Donaldson) writes: > A question: why do you need a special program to do this? > Surely the "cp" or "dd" commands can do this by something like: > cp /dev/rflp file > or: > dd if=/dev/rflp of=file > "rflp" might be the name of the RAW floppy device (I don't know > exactly what its called on MINIX since I don't have the source yet It's /dev/fd0 (drive 0, drive 1 is /dev/fd1) > If MINIX is reasonably V7 compatable, both these commands should > be equivalent to the FREAD program supplied. Similarly for FWRITE. > And they -don't- depend on any hardware or interrupt vectors like the > given programs. The cp and dd commands will work on MINIX just fine -- IF you have someplace to write the output file. If you're like me, with only one floppy drive and a hard-disk that MINIX won't write to, there's no place to put a 360K image of the disk. In that case you have to do your copies under Mushdos, using either a program like COPYIIPC or a poor man's substitute like the fread or fwrite commands. If you have two floppy drives, you can just use cp /dev/fd0 /dev/fd1 to do the copies. > If you want it to go faster you can put a "bs=64k" on the "dd" command, > if 64k dma is possible (or simulated). You should be able to achieve > the same sort of speed that the given programs would have achieved this way. Even if you put a "bs=64k" parameter on the dd command, the floppy task will still read the disk in two-sector (1K) chunks. > If the kernel doesn't support the raw floppy device, then > code should be added to the kernel. I just dislike programs that > go straight to the hardware if there is a portable way to do it > and utilities already exist. So do I, but there are some conditions where you can't use the supplied utilities, for the reasons described above. Incidentally, the FREAD and FWRITE programs the poster is referring to seem to do their I/O with BIOS calls, which isn't quite at the hardware level. (If your floppy disk harrdware isn't "truly compatible" you won't be running MINIX anyway). -------------------------------------------------------------------------- Richard Todd USSnail:820 Annie Court,Norman OK 73069 UUCP: {allegra!cbosgd|ihnp4}!okstate!uokmax!rmtodd