[comp.os.minix] National Computers Limited

karl@sugar.UUCP (Karl Lehenbauer) (07/09/87)

In article <304@louie.udel.EDU>, Alun Saunder's writes about problems
running Minix from his hard disk:

> I realise that I don't have a 'standard' disk controller (this one appears
> to be Japanese, made by a company called NCL)...

I used to have a hard disk controller made by NCL also.  It would not work
with Microport Unix System V when I tried to use it.  I replaced it with a
different clone controller (one based on the Western Digital chips) and my
system worked fine.  

If any of you have hard disk problems and use NCL controllers, I suggest you
try a different controller.

news@santra.UUCP (news) (07/23/87)

[ This is my first posting to net, _I_ am not supriced if
  I mess everything up.					  ]

>If any of you have hard disk problems and use NCL controllers, I suggest you
>try a different controller.
 
I finally succeeded in getting minix winchester driver to work
with my NCL (NDC 5127-50) hard disk controller.  Desription of
problems and needed patches are at the end of article.  (Sorry,
no fix, I have had some problems with minix 1.2 diff.  It seems
to give wrong line numbers, have I missed something ? )
 
Otherwise I have had very little problems with minix in my
no-name Taiwan-XT.  Floppy task gives a lot of 'uncoverable disk
error's with 8 MHz, has anyone had same problems ? I'll probably
look in kernel/floppy.c next. 
 
I have changed my system to load root file system from hard disk
by modifying the method suggested by Don Dugger.  I also re-made
cc to look for cpp and cem from hard disk to make more room for
/tmp.  (Actually I compiled cc as if I had 512K memory.)
 
To get my hard disk working I first changed bootblock.s as
suggested by Ed Subelman (and a few others, moved stack from top
of DOS pointers). 
 
NCL controlles DIP switches are used differently (it supports 16
different drives).  First problem was that minix got wrong drive
parameters (number of cylinders etc.).  Needed changes are in
init_params().
 
After I installed Don Duggers patches for read-only disk I was
able to read few first cylinders.  With some wait-loops I got
first half of disk readable, but still got a lot of strange
'winchester task got message from -1' notices.  I finally found
that the controller was trying to send 'completition status word'
in com_out() even before it had recieved the command.  I moved
port_out(WIN_DMA, mode); at the end of com_out().  The command
forced the controller to ask for interrupt.  If someone would try
this com_out() with different controllers please mail me the
results. 
 
To change xt_wini.c to work with NCL controller replace com_out()
and start of init_params() with the code below.  If you want just
to try com_out with different controller forget the init_params.
(In addition I think that the '10000' in win_reset should be
changed to MAX_WIN_RETRY, but that's not important). 
 
--- everything between this line and signature is C-code, not plain Inglish ---
 
PRIVATE com_out(mode)
int mode;
{
/* Output the command block to the winchester controller and return status */
 
	register int i = 0;
	int r;
	register struct wini *wn;
 
	port_out(WIN_SELECT, mode);
 
	for (i=0; i<300; i++) {
		port_in(WIN_STATUS, &r);
		if (r & 8)
			break;
	}
	if (i == 300) {
		w_need_reset = TRUE;
		return(ERR);
	}
	lock();
	for (i=0; i<6; i++) {
		for (;;) {
			port_in(WIN_STATUS, &r);
			if (r & 1)
				break;
			if ((r & 8) == 0) {
				w_need_reset = TRUE;
				unlock();
				return(ERR);
			}
		}
 
		if ((r & 0xe) != 0xc) {
			w_need_reset = TRUE;
			unlock();
			return(ERR);
 
		}
		port_out(WIN_DATA, command[i]);
	}
	unlock();
	port_out(WIN_DMA, mode);
	return(OK);
}
 
/*============================================================================*
 *				init_params				      *
 *============================================================================*/
PRIVATE init_params()
{
/* This routine is called at startup to initialize the partition table,
 * the number of drives and the controller
*/
  unsigned int i, segment, offset;
  int type_0, type_1;
  phys_bytes address;
  extern phys_bytes umap();
  extern int vec_table[];
 
  /* Read the switches from the controller */
  port_in(WIN_SELECT, &i);
 
  /* Calculate the drive types */
  type_0 = i & 7;
  type_1 = (i >> 4) & 7;
 
  if ((i & 8) == 0) {
	type_0 += 8;
	type_1 += 8;
	}
 
  /* Copy the parameter vector from the saved vector table */
  offset = vec_table[2 * 0x41];
  segment = vec_table[2 * 0x41 + 1];
 
  /* Calculate the address off the parameters and copy them to buf */
  address = ((long)segment << 4) + offset;
  phys_copy(address, umap(proc_addr(WINCHESTER), D, buf, 256), 256L);