[comp.os.minix] Protected mode MINIX for 80286 Part 4 - By Bruce Evans

worsley@ditmela.oz (Andrew Worsley) (05/18/89)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 10)."
# Contents:  kerneldif/dmp.c.cdif kerneldif/exception.c.cd
#   kerneldif/floppy.c.cdif kerneldif/glo.h.cdif
#   kerneldif/i8259.c.cdif kerneldif/klib286.x.cdif
#   kerneldif/main.c.cdif mmdif/signal.c.cdif
# Wrapped by sys@besplex on Sun Mar 26 06:34:03 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'kerneldif/dmp.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/dmp.c.cdif'\"
else
echo shar: Extracting \"'kerneldif/dmp.c.cdif'\" \(4759 characters\)
sed "s/^X//" >'kerneldif/dmp.c.cdif' <<'END_OF_FILE'
X*** kernel-1.3/dmp.c	Wed Aug  3 21:18:41 1988
X--- kernel/dmp.c	Sun Mar 12 16:15:21 1989
X***************
X*** 22,24 ****
X   *===========================================================================*/
X! p_dmp()
X  {
X--- 22,24 ----
X   *===========================================================================*/
X! PUBLIC p_dmp()
X  {
X***************
X*** 28,31 ****
X    char *np;
X!   vir_bytes base, limit, first, last;
X!   phys_bytes ltmp, dst;
X    int index;
X--- 28,31 ----
X    char *np;
X!   phys_clicks base, size;
X!   phys_bytes dst;
X    int index;
X***************
X*** 34,52 ****
X    printf(
X!  "\nproc  -pid- -pc-  -sp-  flag  user  -sys-  base limit recv   command\r\n");
X  
X!   dst = umap(proc_addr(SYSTASK), D, (vir_bytes)nbuff, NSIZE);
X  
X!   for (rp = &proc[0]; rp < &proc[NR_PROCS+NR_TASKS]; rp++)  {
X  	if (rp->p_flags & P_SLOT_FREE) continue;
X! 	first = rp->p_map[T].mem_phys;
X! 	last = rp->p_map[S].mem_phys + rp->p_map[S].mem_len;
X! 	ltmp = ((long) first << 4) + 512L;
X! 	base = (vir_bytes) (ltmp/1024L);
X! 	ltmp = (((long) last << 4) + 512L);
X! 	limit = (vir_bytes) (ltmp/1024L);
X! 	prname(rp - proc);
X! 	printf(" %4d %4x %4x %4x %6D %7D  %3dK %3dK  ",
X! 		rp->p_pid, rp->p_pcpsw.pc, rp->p_sp, rp->p_flags,
X  		rp->user_time, rp->sys_time,
X! 		base, limit);
X  		if (rp->p_flags == 0)
X--- 34,51 ----
X    printf(
X!   "\r\nproc  --pid -pc- -sp flag -user- --sys-- -base- -size-  recv- command\r\n");
X  
X!   dst = umap(cproc_addr(SYSTASK), D, (vir_bytes)nbuff, NSIZE);
X  
X!   for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++)  {
X  	if (rp->p_flags & P_SLOT_FREE) continue;
X! 	base = rp->p_map[T].mem_phys;
X! 	size = rp->p_map[S].mem_phys + rp->p_map[S].mem_len - base;
X! 	prname(proc_number(rp));
X! 	printf("%5u %4lx %4lx %2x %7U %7U %5uK %5uK  ",
X! 		rp->p_pid,
X! 		(unsigned long) rp->p_reg.r16.pc,
X! 		(unsigned long) rp->p_reg.r16.sp,
X! 		rp->p_flags,
X  		rp->user_time, rp->sys_time,
X! 		click_to_round_k(base), click_to_round_k(size));
X  		if (rp->p_flags == 0)
X***************
X*** 54,62 ****
X  		else
X! 			prname(NR_TASKS + rp->p_getfrom);
X  
X  	/* Fetch the command string from the user process. */
X! 	index = rp - proc - NR_TASKS;
X  	if (index > LOW_USER && aout[index] != 0) {
X  		phys_copy(aout[index], dst, (long) NSIZE);
X- 		aout[NSIZE] = 0;
X  		for (np = &nbuff[0]; np < &nbuff[NSIZE]; np++)
X--- 53,60 ----
X  		else
X! 			prname(rp->p_getfrom);
X  
X  	/* Fetch the command string from the user process. */
X! 	index = proc_number(rp);
X  	if (index > LOW_USER && aout[index] != 0) {
X  		phys_copy(aout[index], dst, (long) NSIZE);
X  		for (np = &nbuff[0]; np < &nbuff[NSIZE]; np++)
X***************
X*** 75,93 ****
X  
X! map_dmp()
X  {
X    register struct proc *rp;
X!   vir_bytes base, limit, first, last;
X!   phys_bytes ltmp;
X  
X!   printf("\nPROC   -----TEXT-----  -----DATA-----  ----STACK-----  BASE SIZE\r\n");
X!   for (rp = &proc[NR_TASKS]; rp < &proc[NR_TASKS+NR_PROCS]; rp++)  {
X  	if (rp->p_flags & P_SLOT_FREE) continue;
X! 	first = rp->p_map[T].mem_phys;
X! 	last = rp->p_map[S].mem_phys + rp->p_map[S].mem_len;
X! 	ltmp = ((long) first << 4) + 512L;
X! 	base = (vir_bytes) (ltmp/1024L);
X! 	ltmp = (((long) (last-first) << 4) + 512L);
X! 	limit = (vir_bytes) (ltmp/1024L);
X! 	prname(rp-proc);
X! 	printf(" %4x %4x %4x  %4x %4x %4x  %4x %4x %4x  %3dK %3dK\r\n", 
X  	    rp->p_map[T].mem_vir, rp->p_map[T].mem_phys, rp->p_map[T].mem_len,
X--- 73,86 ----
X  
X! PUBLIC map_dmp()
X  {
X    register struct proc *rp;
X!   phys_clicks base, size;
X  
X!   printf("\r\nPROC   -----TEXT-----  -----DATA-----  ----STACK-----  -BASE- -SIZE-\r\n");
X!   for (rp = BEG_SERV_ADDR; rp < END_PROC_ADDR; rp++)  {
X  	if (rp->p_flags & P_SLOT_FREE) continue;
X! 	base = rp->p_map[T].mem_phys;
X! 	size = rp->p_map[S].mem_phys + rp->p_map[S].mem_len - base;
X! 	prname(proc_number(rp));
X! 	printf(" %4x %4x %4x  %4x %4x %4x  %4x %4x %4x  %5uK %5uK\r\n", 
X  	    rp->p_map[T].mem_vir, rp->p_map[T].mem_phys, rp->p_map[T].mem_len,
X***************
X*** 95,97 ****
X  	    rp->p_map[S].mem_vir, rp->p_map[S].mem_phys, rp->p_map[S].mem_len,
X! 	    base, limit);
X    }
X--- 88,90 ----
X  	    rp->p_map[S].mem_vir, rp->p_map[S].mem_phys, rp->p_map[S].mem_len,
X! 	    click_to_round_k(base), click_to_round_k(size));
X    }
X***************
X*** 100,113 ****
X  
X! prname(i)
X  int i;
X  {
X!   if (i == ANY+NR_TASKS)
X  	printf("ANY   ");
X!   else if (i >= 0 && i <= NR_TASKS+2)
X! 	printf("%s", tasktab[i].name);
X    else
X! 	printf("%4d  ", i-NR_TASKS);
X  }
X  
X! set_name(proc_nr, ptr)
X  int proc_nr;
X--- 93,106 ----
X  
X! PRIVATE prname(i)
X  int i;
X  {
X!   if (i == ANY)
X  	printf("ANY   ");
X!   else if ( (unsigned) (i + NR_TASKS) <= LOW_USER + NR_TASKS)
X! 	printf("%s", tasktab[i + NR_TASKS].name);
X    else
X! 	printf("%4d  ", i);
X  }
X  
X! PUBLIC set_name(proc_nr, ptr)
X  int proc_nr;
END_OF_FILE
if test 4759 -ne `wc -c <'kerneldif/dmp.c.cdif'`; then
    echo shar: \"'kerneldif/dmp.c.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/dmp.c.cdif'
fi
if test -f 'kerneldif/exception.c.cd' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/exception.c.cd'\"
else
echo shar: Extracting \"'kerneldif/exception.c.cd'\" \(2371 characters\)
sed "s/^X//" >'kerneldif/exception.c.cd' <<'END_OF_FILE'
X*** /dev/null	Thu Oct 13 22:40:42 1988
X--- kernel/exception.c	Thu Mar 23 01:26:57 1989
X***************
X*** 0 ****
X--- 1,67 ----
X+ /* This file contains a simple exception handler.  Exceptions in user
X+  * processes are converted to signals.  Exceptions in the kernel, MM and
X+  * FS cause a panic.
X+  */
X+ 
X+ #include "../h/const.h"
X+ #include "../h/type.h"
X+ #include "../h/signal.h"
X+ #include "const.h"
X+ #include "type.h"
X+ #include "glo.h"
X+ #include "proc.h"
X+ 
X+ /*==========================================================================*
X+  *				exception				    *
X+  *==========================================================================*/
X+ PUBLIC exception(vec_nr)
X+ unsigned vec_nr;
X+ {
X+ /* An exception or unexpected interrupt has occurred. */
X+ 
X+   struct ex_s {
X+ 	char *msg;
X+ 	int signum;
X+ 	int minprocessor;
X+   };
X+   static struct ex_s ex_data[] = {
X+ 	"Divide error", SIGFPE, 86,
X+ 	"Debug exception", SIGTRAP, 86,		/* overidden by debugger */
X+ 	"Nonmaskable interrupt", SIGBUS, 86,	/* needs separate handler */
X+ 	"Breakpoint", SIGTRAP, 86,		/* overidden by debugger */
X+ 	"Overflow", SIGFPE, 86,
X+ 	"Bounds check", SIGFPE, 186,
X+ 	"Invalid opcode", SIGILL, 186,
X+ 	"Coprocessor not available", SIGFPE, 186,
X+ 	"Double fault", SIGBUS, 286,
X+ 	"Copressor segment overrun", SIGSEGV, 286,
X+ 	"Invalid TSS", SIGSEGV, 286,
X+ 	"Segment not present", SIGSEGV, 286,
X+ 	"Stack exception", SIGSEGV, 286,	/* STACK_FAULT already used */
X+ 	"General protection", SIGSEGV, 286,
X+ 	"Page fault", SIGSEGV, 386,		/* not close */
X+ 	NIL_PTR, SIGILL, 0,			/* probably software trap */
X+ 	"Coprocessor error", SIGFPE, 386,
X+ 	"Unexpected interrupt along vector >= 17", SIGILL, 0,
X+   };
X+   register struct ex_s *ep;
X+ 
X+   ep = &ex_data[vec_nr];
X+ 
X+   if (k_reenter == 0 && isuserp(proc_ptr)) {
X+ 	unlock();		/* this is protected like sys_call() */
X+ 	cause_sig(proc_number(proc_ptr), ep->signum);
X+ 	return;
X+   }
X+ 
X+   /* This is not supposed to happen. */
X+   if (ep->msg == NIL_PTR || get_processor() < ep->minprocessor)
X+ 	printf("\r\nIntel-reserved exception %d\r\n", vec_nr);
X+   else
X+ 	printf("\r\n%s\r\n", ep->msg);
X+   printf("process number %d, pc = 0x%04x:0x%04lx\r\n",
X+ 	 proc_number(proc_ptr),
X+ 	 (unsigned long) proc_ptr->p_reg.r16.cs,
X+ 	 (unsigned long) proc_ptr->p_reg.r16.pc);
X+   panic("exception in kernel, mm or fs", NO_NUM);
X+ }
END_OF_FILE
if test 2371 -ne `wc -c <'kerneldif/exception.c.cd'`; then
    echo shar: \"'kerneldif/exception.c.cd'\" unpacked with wrong size!
fi
# end of 'kerneldif/exception.c.cd'
fi
if test -f 'kerneldif/floppy.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/floppy.c.cdif'\"
else
echo shar: Extracting \"'kerneldif/floppy.c.cdif'\" \(3990 characters\)
sed "s/^X//" >'kerneldif/floppy.c.cdif' <<'END_OF_FILE'
X*** kernel-1.3/floppy.c	Thu Jan 26 04:51:41 1989
X--- kernel/floppy.c	Fri Mar 10 00:03:28 1989
X***************
X*** 344,346 ****
X  
X!   int mode, low_addr, high_addr, top_addr, low_ct, high_ct, top_end, s;
X    vir_bytes vir, ct;
X--- 344,346 ----
X  
X!   int mode, low_addr, high_addr, top_addr, low_ct, high_ct, top_end;
X    vir_bytes vir, ct;
X***************
X*** 370,372 ****
X    port_out(DMA_INIT, DMA_RESET_VAL);        /* reset the dma controller */
X-   s = lock();
X    port_out(DMA_M2, mode);	/* set the DMA mode */
X--- 370,371 ----
X***************
X*** 378,380 ****
X    port_out(DMA_COUNT, high_ct);	/* output high 8 bits of count - 1 */
X-   restore(s);
X    port_out(DMA_INIT, 2);	/* initialize DMA */
X--- 377,378 ----
X***************
X*** 399,405 ****
X   * turning off motors while we are testing the bits.
X   */
X  
X!   int motor_bit, running, send_mess(), old_state;
X  
X-   old_state = lock();		/* no interrupts while checking out motor */
X    motor_bit = 1 << (fp->fl_drive + 4);	/* bit mask for this drive */
X--- 397,403 ----
X   * turning off motors while we are testing the bits.
X+  * NO NEED, the clock task cannot run while another (FLOPPY) task is active.
X   */
X  
X!   int motor_bit, running, send_mess();
X  
X    motor_bit = 1 << (fp->fl_drive + 4);	/* bit mask for this drive */
X***************
X*** 411,413 ****
X    prev_motor = motor_bit;	/* record motor started for next time */
X-   restore(old_state);
X  
X--- 409,410 ----
X***************
X*** 486,488 ****
X    int r, s, op;
X-   extern int olivetti;
X  
X--- 483,484 ----
X***************
X*** 533,537 ****
X  /*===========================================================================*
X!  *				fdc_results				     * 
X   *===========================================================================*/
X! PRIVATE int fdc_results(fp)
X  register struct floppy *fp;	/* pointer to the drive struct */
X--- 529,533 ----
X  /*===========================================================================*
X!  *				old_fdc_results				     * 
X   *===========================================================================*/
X! PRIVATE int old_fdc_results(fp)
X  register struct floppy *fp;	/* pointer to the drive struct */
X***************
X*** 651,658 ****
X  
X!   int i, r, status, old_state;
X    register struct floppy *fp;
X  
X!   /* Disable interrupts and strobe reset bit low. */
X    need_reset = FALSE;
X!   old_state = lock();
X    motor_status = 0;
X--- 647,656 ----
X  
X!   int i, r, status;
X    register struct floppy *fp;
X  
X!   /* Disable interrupts and strobe reset bit low.  *This* lock is essential
X!    * because the controller may interrupt twice, once for each port_out().
X!    */
X    need_reset = FALSE;
X!   lock();
X    motor_status = 0;
X***************
X*** 661,663 ****
X    port_out(DOR, ENABLE_INT);	/* strobe it high again */
X!   restore(old_state);		/* interrupts allowed again */
X    receive(HARDWARE, &mess);	/* collect the RESET interrupt */
X--- 659,661 ----
X    port_out(DOR, ENABLE_INT);	/* strobe it high again */
X!   unlock();			/* interrupts allowed again */
X    receive(HARDWARE, &mess);	/* collect the RESET interrupt */
X***************
X*** 668,669 ****
X--- 666,671 ----
X  	fdc_results(&floppy[i]);/* get results (using each floppy[i]) */
X+ 				/* it looks wrong to have the sense command
X+ 				 * and the enable in fdc_results()
X+ 				 * inside this loop
X+ 				 */
X  	floppy[i].fl_calibration = UNCALIBRATED;
X***************
X*** 703,704 ****
X--- 705,724 ----
X    send(FLOPPY, &mess);
X+ }
X+ 
X+ 
X+ /*==========================================================================*
X+  *				fdc_results				    *
X+  *==========================================================================*/
X+ PRIVATE int fdc_results(fp)
X+ register struct floppy *fp;	/* pointer to the drive struct */
X+ {
X+ /* Extract results from the controller after an operation, then reenable the
X+  * interrupt controller.  The sense command should be done here too.
X+  */
X+ 
X+   int r;
X+ 
X+   r = old_fdc_results(fp);
X+   cim_floppy();
X+   return(r);
X  }
END_OF_FILE
if test 3990 -ne `wc -c <'kerneldif/floppy.c.cdif'`; then
    echo shar: \"'kerneldif/floppy.c.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/floppy.c.cdif'
fi
if test -f 'kerneldif/glo.h.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/glo.h.cdif'\"
else
echo shar: Extracting \"'kerneldif/glo.h.cdif'\" \(2154 characters\)
sed "s/^X//" >'kerneldif/glo.h.cdif' <<'END_OF_FILE'
X*** kernel-1.3/glo.h	Thu Oct 20 13:15:23 1988
X--- kernel/glo.h	Sun Mar 12 22:03:33 1989
X***************
X*** 2,12 ****
X  
X! /* Clocks and timers */
X! EXTERN real_time realtime;	/* real time clock */
X! EXTERN int lost_ticks;		/* incremented when clock int can't send mess*/
X! 
X! /* Processes, signals, and messages. */
X! EXTERN int cur_proc;		/* current process */
X! EXTERN int prev_proc;		/* previous process */
X  EXTERN int sig_procs;		/* number of procs with p_pending != 0 */
X- EXTERN message int_mess;	/* interrupt routines build message here */
X  
X--- 2,5 ----
X  
X! /* Signals. */
X  EXTERN int sig_procs;		/* number of procs with p_pending != 0 */
X  
X***************
X*** 16,17 ****
X--- 9,11 ----
X  EXTERN int port_65;		/* saved contents of Planar Control Register */
X+ EXTERN unsigned processor;	/* 86, 186, 286, 386, ... */
X  
X***************
X*** 21 ****
X--- 15,41 ----
X  EXTERN int scan_code;		/* scan code of key pressed to start minix */
X+ EXTERN int snow;		/* 1 if screen needs snow removal, 0 if not */
X+ 
X+ /* Low level interrupt communications. */
X+ EXTERN struct proc *held_head;	/* head of queue of held-up interrupts */
X+ EXTERN struct proc *held_tail;	/* tail of queue of held-up interrupts */
X+ EXTERN unsigned char k_reenter;	/* kernel reentry count (entry count less 1)*/
X+ 
X+ /* Memory sizes. */
X+ #ifdef i8088
X+ EXTERN phys_clicks membase[NR_MEMS];	/* bases of chunks of memory */
X+ EXTERN phys_clicks memsize[NR_MEMS];	/* sizes of chunks of memory */
X+ EXTERN unsigned char memtype[NR_MEMS];	/* types of chunks of memory */
X+ #endif
X+ 
X+ /* Miscellaneous (still all over the place in non-header files). */
X+ extern unsigned sizes[8];		/* table filled in by build */
X+ extern struct tasktab tasktab[];	/* see table.c */
X+ extern char t_stack[];			/* see table.c */
X+ extern int vec_table[VECTOR_BYTES/ sizeof (int)];  /* copy of BIOS vectors */
X+ 
X+ /* Non-integer functions (still all over the place in non-header files). */
X+ extern phys_bytes umap();	/* map user address to physical address */
X+ #ifdef i8088
X+ extern unsigned codeseg();	/* current code segment */
X+ extern unsigned dataseg();	/* current data segment */
X+ #endif
END_OF_FILE
if test 2154 -ne `wc -c <'kerneldif/glo.h.cdif'`; then
    echo shar: \"'kerneldif/glo.h.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/glo.h.cdif'
fi
if test -f 'kerneldif/i8259.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/i8259.c.cdif'\"
else
echo shar: Extracting \"'kerneldif/i8259.c.cdif'\" \(2394 characters\)
sed "s/^X//" >'kerneldif/i8259.c.cdif' <<'END_OF_FILE'
X*** /dev/null	Thu Oct 13 22:40:42 1988
X--- kernel/i8259.c	Sun Mar 12 22:59:02 1989
X***************
X*** 0 ****
X--- 1,66 ----
X+ /* This file contains routines for initializing the 8259 interrupt controller:
X+  *	enable_irq:	enable an interrupt line.  The cim...() functions in
X+  *			klib88 are specialized versions of this
X+  *	init_8259:	initialize the 8259(s), since the BIOS does it wrong
X+  */
X+ 
X+ #include "../h/const.h"
X+ #include "../h/type.h"
X+ #include "../h/com.h"
X+ #include "const.h"
X+ #include "type.h"
X+ #include "glo.h"
X+ 
X+ #define ICW1_AT         0x11	/* edge triggered, cascade, need ICW4 */
X+ #define ICW1_PC         0x13	/* edge triggered, no cascade, need ICW4 */
X+ #define ICW3_M          0x04	/* bit 2 for slave on channel 2 */
X+ #define ICW3_S          0x02	/* slave identity is 2 */
X+ #define ICW4_AT         0x01	/* not SFNM, not buffered, normal EOI, 8086 */
X+ #define ICW4_PC         0x09	/* not SFNM, buffered, normal EOI, 8086 */
X+ 
X+ 
X+ /*==========================================================================*
X+  *				enable_irq				    *
X+  *==========================================================================*/
X+ PUBLIC enable_irq(irq_nr)
X+ unsigned irq_nr;
X+ {
X+ /* Clear the corresponding 8259 register bit. */
X+ 
X+   int old_state;
X+ 
X+   old_state = lock();
X+   if (irq_nr < 8)
X+ 	port_out(INT_CTLMASK, inportb(INT_CTLMASK) & ~(1 << irq_nr));
X+   else 
X+ 	port_out(INT2_MASK, inportb(INT2_MASK) & ~(1 << (irq_nr - 8)));
X+   restore(old_state);
X+ }
X+ 
X+ 
X+ /*==========================================================================*
X+  *				init_8259				    *
X+  *==========================================================================*/
X+ PUBLIC init_8259(master_base, slave_base)
X+ unsigned master_base;
X+ unsigned slave_base;
X+ {
X+ /* Initialize the 8259(s), finishing with all interrupts disabled. */
X+ 
X+   if (pc_at) {
X+ 	port_out(INT_CTL, ICW1_AT);
X+ 	port_out(INT_CTLMASK, master_base);	/* ICW2 for master */
X+ 	port_out(INT_CTLMASK, ICW3_M);
X+ 	port_out(INT_CTLMASK, ICW4_AT);
X+ 	port_out(INT2_CTL, ICW1_AT);
X+ 	port_out(INT2_MASK, slave_base);	/* ICW2 for slave */
X+ 	port_out(INT2_MASK, ICW3_S);
X+ 	port_out(INT2_MASK, ICW4_AT);
X+ 	port_out(INT2_MASK, ~0);
X+   } else {
X+ 	port_out(INT_CTL, ICW1_PC);
X+ 	port_out(INT_CTLMASK, master_base);	/* no slave */
X+ 	port_out(INT_CTLMASK, ICW4_PC);
X+   }
X+   port_out(INT_CTLMASK, ~0);
X+ }
END_OF_FILE
if test 2394 -ne `wc -c <'kerneldif/i8259.c.cdif'`; then
    echo shar: \"'kerneldif/i8259.c.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/i8259.c.cdif'
fi
if test -f 'kerneldif/klib286.x.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/klib286.x.cdif'\"
else
echo shar: Extracting \"'kerneldif/klib286.x.cdif'\" \(8420 characters\)
sed "s/^X//" >'kerneldif/klib286.x.cdif' <<'END_OF_FILE'
X*** /dev/null	Thu Oct 13 22:40:42 1988
X--- kernel/klib286.x	Mon Mar 13 04:51:55 1989
X***************
X*** 0 ****
X--- 1,301 ----
X+ |*===========================================================================*
X+ |*			klib support for 286 protected mode		     *
X+ |*===========================================================================*
X+ 
X+ #include "../h/const.h"
X+ #include "const.h"
X+ #include "protect.h"
X+ #include "sconst.h"
X+ #define KLIB286 .define
X+ #include "sglo.h"
X+ 
X+ 	.text
X+ |*===========================================================================*
X+ |*				klib286_init				     *
X+ |*===========================================================================*
X+ 
X+ | Patch the code segment for returning to real mode.
X+ | Patch various functions in klib88 to jump to corresponding functions here.
X+ 
X+ _klib286_init:
X+ 	mov	si,#patch_table
X+ 	lodw			| original function
X+ patch1:
X+ 	mov	bx,ax
X+ 	lodw			| new function - target of call or jump
X+ 	sub	ax,bx		| relative jump
X+ 	sub	ax,#3		| adjust by length of jump instruction
X+ 	seg	cs
X+ 	mov	1(bx),ax
X+ 	lodb			| opcode
X+ 	seg	cs
X+ 	movb	(bx),al
X+ 	lodw			| next original function
X+ 	test	ax,ax
X+ 	jnz	patch1
X+ 	ret
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_check_mem				     *
X+ |*===========================================================================*
X+ 
X+ PCM_DENSITY	=	256	| others are not supported
X+ 
X+ p_check_mem:
X+ 	pop	bx
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop base into base of source descriptor
X+ 	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	pop	cx		| byte count in dx:cx
X+ 	pop	dx
X+ 	sub	sp,#4+4
X+ 	push	bx
X+ 	push	ds
X+ 
X+ 	sub	ax,ax		| prepare for early exit
X+ 	test	dx,#0xFF00
X+ 	jnz	pcm_1exit	| can't handle bases above 16M
X+ 	movb	cl,ch		| divide size by 256 and discard high byte
X+ 	movb	ch,dl
X+ 	push	cx		| save divided size
X+ 	sub	bx,bx		| test bytes at bases of segments
X+ pcm_loop:
X+ 	mov	ax,#DS_286_SELECTOR
X+ 	mov	ds,ax
X+ 	movb	dl,#TEST1PATTERN
X+ 	xchgb	dl,(bx)		| write test pattern, remember original value
X+ 	xchgb	dl,(bx)		| restore original value, read test pattern
X+ 	cmpb	dl,#TEST1PATTERN	| must agree if good real memory
X+ 	jnz	pcm_exit	| if different, memory is unusable
X+ 	movb	dl,#TEST2PATTERN
X+ 	xchgb	dl,(bx)
X+ 	xchgb	dl,(bx)
X+ 	cmpb	dl,#TEST2PATTERN
X+ 	jnz	pcm_exit
X+ 	seg	es		| next segement, test for wraparound at 16M
X+ 	add	_gdt+DS_286_OFFSET+DESC_BASE,#PCM_DENSITY
X+ 	seg	es		| assuming es == old ds
X+ 	adcb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,#0
X+ 	loopnz	pcm_loop
X+ 
X+ pcm_exit:
X+ 	pop	ax
X+ 	sub	ax,cx		| verified size in multiples of PCM_DENSITY
X+ pcm_1exit:
X+ 	movb	dl,ah		| convert to phys_bytes in dx:ax
X+ 	subb	dh,dh
X+ 	movb	ah,al
X+ 	movb	al,dh
X+ 	pop	ds
X+ 	ret
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_cp_mess				     *
X+ |*===========================================================================*
X+ 
X+ | The 16 bit cp_mess() attempts to be efficient by passing raw segments but
X+ | that just gets in the way here.
X+ 
X+ p_cp_mess:
X+ 	pop	dx
X+ 	pop	bx		| proc
X+ 	pop	cx		| source clicks
X+ 	pop	ax		| source offset
X+ #if CLICK_SHIFT != HCLICK_SHIFT + 4
X+ #error /* the only click size supported is 256, to avoid slow shifts here */
X+ #endif
X+ 	addb	ah,cl		| calculate source offset
X+ 	adcb	ch,#0 		| and put in base of source descriptor
X+ 	mov	_gdt+DS_286_OFFSET+DESC_BASE,ax
X+ 	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,ch
X+ 	pop	cx		| destination clicks
X+ 	pop	ax		| destination offset
X+ 	addb	ah,cl		| calculate destination offset
X+ 	adcb	ch,#0 		| and put in base of destination descriptor
X+ 	mov	_gdt+ES_286_OFFSET+DESC_BASE,ax
X+ 	movb	_gdt+ES_286_OFFSET+DESC_BASE_MIDDLE,ch
X+ 	sub	sp,#2+2+2+2+2
X+ 
X+ 	push	ds
X+ 	push	es
X+ 	mov	ax,#DS_286_SELECTOR
X+ 	mov	ds,ax
X+ 	mov	ax,#ES_286_SELECTOR
X+ 	mov	es,ax
X+ 
X+ 	seg	es
X+ 	mov	0,bx		| sender's proc no. from arg, not msg
X+ 	mov	ax,si
X+ 	mov	bx,di
X+ 	mov	si,#2		| src offset is now 2 relative to start of seg
X+ 	mov	di,si		| and destination offset
X+ 	mov	cx,#Msize-1	| word count
X+ 	rep
X+ 	movw
X+ 	mov	di,bx
X+ 	mov	si,ax
X+ 	pop	es
X+ 	pop	ds
X+ 	jmpreg	(dx)
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_get_phys_byte				     *
X+ |*===========================================================================*
X+ 
X+ p_get_phys_byte:
X+ 	pop	dx
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop source into base of source descriptor
X+ 	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	sub	sp,#4
X+ 	mov	cx,ds
X+ 	mov	ax,#DS_286_SELECTOR
X+ 	pushf			| lock may be necessary since this is (only)
X+ 	cli			| called by the badly behaved printer task
X+ 	mov	ds,ax
X+ 	movb	al,0		| get the byte from the start of the segment
X+ 	mov	ds,cx
X+ 	popf
X+ 	subb	ah,ah
X+ 	jmpreg	(dx)
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_phys_copy				     *
X+ |*===========================================================================*
X+ 
X+ p_phys_copy:
X+ 	pop	dx
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop source into base of source descriptor
X+ 	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	pop	_gdt+ES_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop destination into base of dst descriptor
X+ 	movb	_gdt+ES_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	pop	cx		| byte count in bx:cx
X+ 	pop	bx
X+ 	sub	sp,#4+4+4
X+ 
X+ 	push	di
X+ 	push	si
X+ 	push	es
X+ 	push	ds
X+ 	sub	si,si		| src offset is now 0 relative to start of seg
X+ 	mov	di,si		| and destination offset
X+ 	j	ppc_next
X+ 
X+ | It is too much trouble to align the segment bases so word alignment is hard.
X+ | Avoiding the book-keeping for alignment may be good anyway.
X+ 
X+ ppc_large:
X+ 	push	cx
X+ 	mov	cx,#0x8000	| copy a large chunk of this many words
X+ 	rep
X+ 	movw
X+ 	pop	cx
X+ 	dec	bx
X+ 	pop	ds		| update the descriptors
X+ 	incb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE
X+ 	incb	_gdt+ES_286_OFFSET+DESC_BASE_MIDDLE
X+ 	push	ds
X+ ppc_next:
X+ 	mov	ax,#DS_286_SELECTOR	| (re)load the selectors
X+ 	mov	ds,ax
X+ 	mov	ax,#ES_286_SELECTOR
X+ 	mov	es,ax
X+ 	test	bx,bx
X+ 	jnz	ppc_large
X+ 
X+ 	shr	cx,#1		| word count
X+ 	rep
X+ 	movw			| move any leftover words
X+ 	rcl	cx,#1		| restore old bit 0
X+ 	rep
X+ 	movb			| move any leftover byte
X+ 	pop	ds
X+ 	pop	es
X+ 	pop	si
X+ 	pop	di
X+ 	jmpreg	(dx)
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_port_read				     *
X+ |*===========================================================================*
X+ 
X+ | This is not reentrant, but only the WINCHESTER task is allowed to call it.
X+ 
X+ p_port_read:
X+ 	pop	bx
X+ 	pop	dx		| port
X+ 	pop	_gdt+ES_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop destination into base of dst descriptor
X+ 	movb	_gdt+ES_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	pop	cx		| byte count
X+ 	sub	sp,#2+4+2
X+ 	push	es
X+ 	mov	ax,#ES_286_SELECTOR
X+ 	mov	es,ax
X+ 	mov	ax,di
X+ 	sub	di,di		| dst offset is now 0 relative to start of seg
X+ 	shr	cx,#1		| word count
X+ 	rep
X+ 	insw			| read everything
X+ 	mov	di,ax
X+ 	pop	es
X+ 	jmpreg	(bx)
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				p_port_write				     *
X+ |*===========================================================================*
X+ 
X+ p_port_write:
X+ 	pop	bx
X+ 	pop	dx		| port
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X+ 	pop	ax		| pop offset into base of source descriptor
X+ 	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X+ 	pop	cx		| byte count, discard high word
X+ 	sub	sp,#2+4+2
X+ 	push	ds
X+ 	mov	ax,#DS_286_SELECTOR
X+ 	mov	ds,ax
X+ 	mov	ax,si
X+ 	sub	si,si		| src offset is now 0 relative to start of seg
X+ 	shr	cx,#1		| word count
X+ 	rep
X+ 	outsw			| write everything
X+ 	mov	si,ax
X+ 	pop	ds
X+ 	jmpreg	(bx)
X+ 
X+ 
X+ |*===========================================================================*
X+ |*				data					     *
X+ |*===========================================================================*
X+ 
X+ 	.data
X+ 
X+ patch_table:			| triples (old function, new function, opcode)
X+ 	.word	_check_mem, p_check_mem
X+ 	.byte	JMP_OPCODE
X+ 	.word	_cp_mess, p_cp_mess
X+ 	.byte	JMP_OPCODE
X+ 	.word	_get_phys_byte, p_get_phys_byte
X+ 	.byte	JMP_OPCODE
X+ 	.word	_phys_copy, p_phys_copy
X+ 	.byte	JMP_OPCODE
X+ 	.word	_port_read, p_port_read
X+ 	.byte	JMP_OPCODE
X+ 	.word	_port_write, p_port_write
X+ 	.byte	JMP_OPCODE
X+ 	.word	_restart, p_restart
X+ 	.byte	JMP_OPCODE
X+ 	.word	save, p2_save
X+ 	.byte	JMP_OPCODE
X+ 	.word	0		| end of table
X+ 
END_OF_FILE
if test 8420 -ne `wc -c <'kerneldif/klib286.x.cdif'`; then
    echo shar: \"'kerneldif/klib286.x.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/klib286.x.cdif'
fi
if test -f 'kerneldif/main.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kerneldif/main.c.cdif'\"
else
echo shar: Extracting \"'kerneldif/main.c.cdif'\" \(13597 characters\)
sed "s/^X//" >'kerneldif/main.c.cdif' <<'END_OF_FILE'
X*** kernel-1.3/main.c	Thu Oct  6 21:07:39 1988
X--- kernel/main.c	Thu Mar 23 04:06:52 1989
X***************
X*** 7,10 ****
X   *   main:		MINIX main program
X-  *   unexpected_int:	called on an interrupt to an unused vector < 16 occurs
X-  *   trap:		called on an unexpected trap to a vector >= 16 occurs
X   *   panic:		abort MINIX due to a fatal error
X--- 7,8 ----
X***************
X*** 14,15 ****
X--- 12,14 ----
X  #include "../h/type.h"
X+ #include "../h/boot.h"
X  #include "../h/callnr.h"
X***************
X*** 23,26 ****
X  
X! #define SAFETY             8	/* margin of safety for stack overflow (ints)*/
X! #define VERY_BIG       39328	/* must be bigger than kernel size (clicks) */
X  #define BASE            1536	/* address where MINIX starts in memory */
X--- 22,31 ----
X  
X! #define CLOCK_MASK	(1 << (CLOCK_IRQ & 0x07))
X! #define CASCADE_MASK	(1 << (CASCADE_IRQ & 0x07))
X! #define XT_WINI_MASK	(1 << (XT_WINI_IRQ & 0x07))
X! #define FLOPPY_MASK	(1 << (FLOPPY_IRQ & 0x07))
X! #define PRINTER_MASK	(1 << (PRINTER_IRQ & 0x07))
X! #define AT_WINI_MASK	(1 << (AT_WINI_IRQ & 0x07))
X! 
X! #define SAFETY            32	/* safety margin for stack overflow (bytes) */
X  #define BASE            1536	/* address where MINIX starts in memory */
X***************
X*** 31,38 ****
X  #define PS              0xFA	/* IBM code for PS/2  (in BIOS at 0xFFFFE) */
X- #define EM_VEC          0x15	/* vector for extended memory BIOS calls */
X- #define CMASK1          0x00	/* interrupt mask: ptr, dsk, keybd, clk, PIC */
X- #define CMASK2          0xBF	/* interrupt mask for secondary PIC */
X- #define CMASK3          0x3C	/* interrupt mask for PS/2 */
X  #define CMASK4          0x9E	/* Planar Control Register */
X! #define HIGH_INT          16	/* limit of the interrupt vectors */
X  
X--- 36,39 ----
X  #define PS              0xFA	/* IBM code for PS/2  (in BIOS at 0xFFFFE) */
X  #define CMASK4          0x9E	/* Planar Control Register */
X! #define HIGH_INT          17	/* limit of the interrupt vectors */
X  
X***************
X*** 40,44 ****
X             int07(), int08(), int09(), int10(), int11(), int12(), int13(), 
X!            int14(), int15();
X  int (*int_vec[HIGH_INT])() = {int00, int01, int02, int03, int04, int05, int06,
X!     int07, int08, int09, int10, int11, int12, int13, int14, int15};     
X  
X--- 41,45 ----
X             int07(), int08(), int09(), int10(), int11(), int12(), int13(), 
X!            int14(), int15(), int16();
X  int (*int_vec[HIGH_INT])() = {int00, int01, int02, int03, int04, int05, int06,
X!     int07, int08, int09, int10, int11, int12, int13, int14, int15, int16};
X  
X***************
X*** 54,56 ****
X    register int t;
X-   int i, old_state;
X    vir_clicks size;
X--- 55,56 ----
X***************
X*** 59,61 ****
X    int	stack_size;
X!   int * ktsb;			/* kernel task stack base */
X    extern unsigned sizes[8];	/* table filled in by build */
X--- 59,61 ----
X    int	stack_size;
X!   offset_t ktsb;		/* kernel task stack base */
X    extern unsigned sizes[8];	/* table filled in by build */
X***************
X*** 65,70 ****
X    extern phys_bytes umap();
X-   extern char get_byte();
X    extern struct tasktab tasktab[];	/* see table.c */
X!   extern int t_stack[];			/* see table.c */
X!   extern int k_stack[];			/* see table.c */
X  
X--- 65,68 ----
X    extern phys_bytes umap();
X    extern struct tasktab tasktab[];	/* see table.c */
X!   extern char t_stack[];		/* see table.c */
X  
X***************
X*** 79,85 ****
X     * pc, cs, and psw onto the USER's stack when starting the user the first
X!    * time.  This means that with initial sp = 0x10, user programs must leave 
X!    * the words at 0x000A, 0x000C, and 0x000E free.
X     */
X  
X!   old_state = lock();			/* we can't handle interrupts yet */
X    base_click = BASE >> CLICK_SHIFT;
X--- 77,112 ----
X     * pc, cs, and psw onto the USER's stack when starting the user the first
X!    * time.  And if an interrupt happens before the user loads a better stack
X!    * pointer, these 3 words will be used to save the state, and the interrupt
X!    * handler will use another 3, and a debugger trap may use another 3. This
X!    * means that with INIT_SP == 0x1C, user programs must leave the memory
X!    * between 0x000A and 0x001B free.
X     */
X  
X!   /* Interrupts are disabled here (by fsck.s and then redundantly by mpx88.x),
X!    * so it is unnecessary to call lock().  They are reenabled when INIT_PSW is
X!    * loaded by the first restart().
X!    */
X! 
X! #ifdef DEBUGGER
X! #ifdef DEBUG_EARLY
X!   db();
X! #endif
X! #endif
X! 
X!   /* Mask all interrupts.  BIOS calls will reenable interrupts, which hurts
X!    * if someone has hooked the vectors and Minix is copied over the handlers.
X!    */
X!   port_out(INT_CTLMASK, ~0);
X! 
X!   proc_init(); 
X!   processor = get_processor();
X!   if (processor > boot_parameters.bp_processor)
X! 	processor = boot_parameters.bp_processor;
X! #ifdef i80286
X!   prot_init();
X! #endif
X! 
X!   /* Align stack base suitably. */
X!   ktsb = ((offset_t) t_stack + (ALIGNMENT - 1)) & ~((offset_t) ALIGNMENT - 1);
X! 
X    base_click = BASE >> CLICK_SHIFT;
X***************
X*** 88,106 ****
X  
X!   for (ktsb = t_stack, t = -NR_TASKS, rp = &proc[0];
X! 		rp <= &proc[NR_TASKS+LOW_USER];  rp++, t++) {
X! 	for (i = 0; i < NR_REGS; i++) rp->p_reg[i] = 0100 * i;	/* debugging */
X  	if (t < 0) {
X  		stack_size = tasktab[t+NR_TASKS].stksize;
X! 		ktsb += stack_size / sizeof (int);
X! 		rp->p_sp = ktsb;
X! 		rp->p_splimit = ktsb - (stack_size - SAFETY) / sizeof(int);
X  	} else {
X! 		rp->p_sp = INIT_SP;
X! 		rp->p_splimit = rp->p_sp;
X  	}
X- 	rp->p_pcpsw.pc = tasktab[t + NR_TASKS].initial_pc;
X- 	if (rp->p_pcpsw.pc != 0 || t >= 0) ready(rp);
X- 	rp->p_pcpsw.psw = INIT_PSW;
X- 	rp->p_flags = 0;
X  
X  	/* Set up memory map for tasks and MM, FS, INIT. */
X--- 115,135 ----
X  
X!   for (rp = BEG_PROC_ADDR; rp <= BEG_USER_ADDR; ++rp, ++t)
X!   {
X! 	t = proc_number(rp);
X! 
X  	if (t < 0) {
X  		stack_size = tasktab[t+NR_TASKS].stksize;
X! 		rp->p_splimit = ktsb + SAFETY;
X! 		ktsb += stack_size;
X! 		rp->p_reg.r16.sp = ktsb;
X  	} else {
X! 		rp->p_reg.r16.sp = INIT_SP;
X! 		rp->p_splimit = rp->p_reg.r16.sp;
X  	}
X  
X+ 	rp->p_reg.r16.pc = (u16_t) tasktab[t + NR_TASKS].initial_pc;
X+ 	if (!isidlehardware(t)) lockready(rp);	/* IDLE, HARDWARE neveready */
X+ 	rp->p_reg.r16.psw = istaskp(rp) ? INIT_TASK_PSW : INIT_PSW;
X+ 	rp->p_flags = 0;
X+ 
X  	/* Set up memory map for tasks and MM, FS, INIT. */
X***************
X*** 108,119 ****
X  		/* I/O tasks. */
X! 		rp->p_map[T].mem_len  = VERY_BIG; 
X  		rp->p_map[T].mem_phys = base_click;
X! 		rp->p_map[D].mem_len  = VERY_BIG; 
X  		rp->p_map[D].mem_phys = base_click + sizes[0];
X- 		rp->p_map[S].mem_len  = VERY_BIG; 
X  		rp->p_map[S].mem_phys = base_click + sizes[0] + sizes[1];
X! 		rp->p_map[S].mem_vir = sizes[0] + sizes[1];
X  	} else {
X  		/* MM, FS, and INIT. */
X! 		previous_base = proc[NR_TASKS + t - 1].p_map[S].mem_phys;
X  		rp->p_map[T].mem_len  = sizes[2*t + 2];
X--- 137,147 ----
X  		/* I/O tasks. */
X! 		rp->p_map[T].mem_len  = sizes[0];
X  		rp->p_map[T].mem_phys = base_click;
X! 		rp->p_map[D].mem_len  = sizes[1];
X  		rp->p_map[D].mem_phys = base_click + sizes[0];
X  		rp->p_map[S].mem_phys = base_click + sizes[0] + sizes[1];
X! 		rp->p_map[S].mem_vir = sizes[1];
X  	} else {
X  		/* MM, FS, and INIT. */
X! 		previous_base = proc_addr(t - 1)->p_map[S].mem_phys;
X  		rp->p_map[T].mem_len  = sizes[2*t + 2];
X***************
X*** 128,133 ****
X  #ifdef i8088
X! 	rp->p_reg[CS_REG] = rp->p_map[T].mem_phys;
X! 	rp->p_reg[DS_REG] = rp->p_map[D].mem_phys;
X! 	rp->p_reg[SS_REG] = rp->p_map[D].mem_phys;
X! 	rp->p_reg[ES_REG] = rp->p_map[D].mem_phys;
X  #endif
X--- 156,158 ----
X  #ifdef i8088
X! 	alloc_segments(rp);
X  #endif
X***************
X*** 135,144 ****
X  
X-   proc[NR_TASKS+(HARDWARE)].p_sp = k_stack;
X-   proc[NR_TASKS+(HARDWARE)].p_sp += K_STACK_BYTES/sizeof (int);
X-   proc[NR_TASKS+(HARDWARE)].p_splimit = k_stack;
X-   proc[NR_TASKS+(HARDWARE)].p_splimit += SAFETY/sizeof (int);
X- 
X-   for (rp = proc_addr(LOW_USER+1); rp < proc_addr(NR_PROCS); rp++)
X- 	rp->p_flags = P_SLOT_FREE;
X- 
X    /* Determine if display is color or monochrome and CPU type (from BIOS). */
X--- 160,161 ----
X***************
X*** 146,148 ****
X    ega = get_ega();
X!   t = (int)get_byte(CPU_TY1, CPU_TY2) & 0xFF;	/* is this PC, XT, AT ... ? */
X    if (t == PC_AT) pc_at = TRUE;
X--- 163,165 ----
X    ega = get_ega();
X!   t = get_phys_byte(((phys_bytes) CPU_TY1 << HCLICK_SHIFT) + CPU_TY2);
X    if (t == PC_AT) pc_at = TRUE;
X***************
X*** 150,153 ****
X  
X    /* Save the old interrupt vectors. */
X!   phys_b = umap(proc_addr(HARDWARE), D, (vir_bytes) vec_table, VECTOR_BYTES);
X    phys_copy(0L, phys_b, (long) VECTOR_BYTES);	/* save all the vectors */
X--- 167,173 ----
X  
X+   /* Get memory sizes from the BIOS. */
X+   mem_init();
X+ 
X    /* Save the old interrupt vectors. */
X!   phys_b = umap(proc_addr(SYSTASK), D, (vir_bytes) vec_table, VECTOR_BYTES);
X    phys_copy(0L, phys_b, (long) VECTOR_BYTES);	/* save all the vectors */
X***************
X*** 173,175 ****
X  	set_vec(AT_WINI_VECTOR, wini_int, base_click);
X- 	phys_copy(phys_b + 4L*EM_VEC, 4L*EM_VEC, 4L);	/* extended mem vec */
X    } else
X--- 193,194 ----
X***************
X*** 182,188 ****
X    set_vec( (BASE - 4)/4, proc, (phys_clicks) 0);
X  
X!   bill_ptr = proc_addr(HARDWARE);	/* it has to point somewhere */
X!   pick_proc();
X  
X!   /* Mask out interupts except ptr, disk, clock, keyboard, PIC */
X    if (ps) {
X--- 201,224 ----
X    set_vec( (BASE - 4)/4, proc, (phys_clicks) 0);
X+   
X+   bill_ptr = cproc_addr(IDLE);  /* it has to point somewhere */
X+   lockpick_proc();
X  
X! #ifdef DEBUGGER
X!   dbinit();
X! #endif
X  
X!   /* Patch assembler modules. */
X! #ifdef i80286
X!   if (processor >= 286)
X! 	klib286_init();
X! #endif
X! 
X!   /* Finish initializing 8259 (needs pc_at). */
X!   init_8259(IRQ0_VECTOR, IRQ8_VECTOR);
X! 
X!   /* Unmask interrupts for clock, floppy, printer, hard disk.  The other
X!    * devices are (correctly) unmasked _after_ they initialize themselves.
X!    * The ethernet driver will need to unmask itself when it is fixed to
X!    * work with this kernel.
X!    */
X    if (ps) {
X***************
X*** 190,196 ****
X  	port_out(0x65, CMASK4);		/* set Planar Control Register */
X! 	port_out(INT_CTLMASK, CMASK3);
X!   } else {
X! 	port_out(INT_CTLMASK, CMASK1);	/* mask out unwanted 8259 interrupts */
X! 	port_out(INT2_MASK, CMASK2);	/* same for second intr controller */
X!   }
X  
X--- 226,236 ----
X  	port_out(0x65, CMASK4);		/* set Planar Control Register */
X! 	port_out(INT_CTLMASK,
X! 		 ~(CLOCK_MASK | XT_WINI_MASK | FLOPPY_MASK | PRINTER_MASK));
X!   } else if (pc_at) {
X! 	port_out(INT_CTLMASK,
X! 		 ~(CLOCK_MASK | CASCADE_MASK | FLOPPY_MASK | PRINTER_MASK));
X! 	port_out(INT2_MASK, ~AT_WINI_MASK);
X!   } else
X! 	port_out(INT_CTLMASK,
X! 		 ~(CLOCK_MASK | XT_WINI_MASK | FLOPPY_MASK | PRINTER_MASK));
X  
X***************
X*** 202,238 ****
X  /*===========================================================================*
X-  *                                   unexpected_int                          * 
X-  *===========================================================================*/
X- PUBLIC unexpected_int(vecnr)
X- int vecnr;				/* vector number, 0 to 15 */
X- {
X- /* A trap or interrupt has occurred that was not expected. */
X- 
X-   if (vecnr == DIVIDE_VECTOR) {
X- 	printf("Division overflow trap.  SIGILL will be sent to process.\n");
X- 	cause_sig(cur_proc, SIGILL);	/* send signal to current process */
X- 	unready(proc_addr(cur_proc));	/* deschedule current process */
X-   } else {
X- 	printf("Unexpected interrupt or trap: vector = %d.  ", vecnr);
X-   }
X-   printf("pc = 0x%x   text+data+bss = 0x%x\n",proc_ptr->p_pcpsw.pc,
X- 					proc_ptr->p_map[D].mem_len<<4);
X- }
X- 
X- 
X- /*===========================================================================*
X-  *                                   trap                                    * 
X-  *===========================================================================*/
X- PUBLIC trap()
X- {
X- /* A trap (vector >= 16) has occurred.  It was not expected. */
X- 
X-   printf("\nUnexpected trap: vector >= 16.  ");
X-   printf("pc = 0x%x    text+data+bss = 0x%x\n",proc_ptr->p_pcpsw.pc,
X- 					proc_ptr->p_map[D].mem_len<<4);
X-   printf("This may be due to accidentally including a non-MINIX\n");
X-   printf("library routine that is trying to make a system call.\n");
X- }
X- 
X- 
X- /*===========================================================================*
X   *                                   panic                                   * 
X--- 242,243 ----
X***************
X*** 250,258 ****
X    if (*s != 0) {
X! 	printf("\nKernel panic: %s",s); 
X  	if (n != NO_NUM) printf(" %d", n);
X! 	printf("\n");
X    }
X!   printf("\nType space to reboot\n");
X    wreboot();
X- 
X  }
X--- 255,265 ----
X    if (*s != 0) {
X! 	printf("\r\nKernel panic: %s",s); 
X  	if (n != NO_NUM) printf(" %d", n);
X! 	printf("\r\n");
X    }
X!   printf("Type any key to reboot\r\n");
X! #ifdef DEBUGGER
X!   db();
X! #endif
X    wreboot();
X  }
X***************
X*** 271,275 ****
X    unsigned vec[2];
X-   unsigned u;
X    phys_bytes phys_b;
X-   extern unsigned sizes[8];
X  
X--- 278,280 ----
X***************
X*** 277,284 ****
X    vec[0] = (unsigned) addr;
X!   vec[1] = (unsigned) base_click;
X!   u = (unsigned) vec;
X  
X    /* Copy the vector into place. */
X!   phys_b = ( (phys_bytes) base_click + (phys_bytes) sizes[0]) << CLICK_SHIFT;
X!   phys_b += u;
X    phys_copy(phys_b, (phys_bytes) vec_nr*4, (phys_bytes) 4);
X--- 282,287 ----
X    vec[0] = (unsigned) addr;
X!   vec[1] = (unsigned) click_to_hclick(base_click);
X  
X    /* Copy the vector into place. */
X!   phys_b = umap(cproc_addr(SYSTASK), D, (vir_bytes) vec, 4);
X    phys_copy(phys_b, (phys_bytes) vec_nr*4, (phys_bytes) 4);
END_OF_FILE
if test 13597 -ne `wc -c <'kerneldif/main.c.cdif'`; then
    echo shar: \"'kerneldif/main.c.cdif'\" unpacked with wrong size!
fi
# end of 'kerneldif/main.c.cdif'
fi
if test -f 'mmdif/signal.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mmdif/signal.c.cdif'\"
else
echo shar: Extracting \"'mmdif/signal.c.cdif'\" \(448 characters\)
sed "s/^X//" >'mmdif/signal.c.cdif' <<'END_OF_FILE'
X*** mm-1.3/signal.c	Wed Aug  3 21:18:04 1988
X--- mm/signal.c	Wed Mar 22 00:53:28 1989
X***************
X*** 125,127 ****
X  	if (j == SIGKILL) id = -1;	/* simulate kill -1 9 */
X! 	if ( (sig_map >> i) & 1) check_sig(id, j, SUPER_USER);
X    }
X--- 125,130 ----
X  	if (j == SIGKILL) id = -1;	/* simulate kill -1 9 */
X! 	if ( (sig_map >> i) & 1) {
X! 		check_sig(id, j, SUPER_USER);
X! 		sys_sig(proc_nr, -1, SIG_DFL);	/* tell kernel it's done */
X! 	}
X    }
END_OF_FILE
if test 448 -ne `wc -c <'mmdif/signal.c.cdif'`; then
    echo shar: \"'mmdif/signal.c.cdif'\" unpacked with wrong size!
fi
# end of 'mmdif/signal.c.cdif'
fi
echo shar: End of archive 4 \(of 10\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 10 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Division of Information Technology (Melbourne), Phone +61 3 347 8644
C.S.I.R.O.                                      Fax  +61 3 347 8987
55 Barry St.                                    Telex AA 152914
Carlton, Vic, 3053, Australia                   E-mail: worsley@ditmela.oz.au