*** /home/phil/min1.5ref/kernel-1.3/alloc_32k.c	Wed Nov 14 00:24:48 1990
--- kernel-1.3/alloc_32k.c	Thu Nov 15 00:41:06 1990
***************
*** 50,74 ****
   *	1 page table because one over-wrote the other.  Eventually panic'ed
   *	when a page got freed twice.  Want at least one PTE_INVALID entry
   *	between BSS and stack.
!  *
!  *  Bugs
!  *    alloc_ascending could free a level 2 page table entry which pointed
!  *    to some user stack pages which had not been freed.  Also, the outer
!  *    while needs to exit if an invalid user page is found.  Currently,
!  *    this is not a problem because num_free_pages is much smaller than
!  *    the number of virtual pages.  Hence, there is always a sizeable gap
!  *    between BSS and the stack.
!  */
! 
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/error.h"
! #include "../h/com.h"
! #include "proc.h"
! #include "const.h"
! #include "glo.h"
! #include "../h/32k.h"
! #include "../h/mmu.h"
  
  #define MAX_STACK_GROWTH_PGS	16
  
--- 50,65 ----
   *	1 page table because one over-wrote the other.  Eventually panic'ed
   *	when a page got freed twice.  Want at least one PTE_INVALID entry
   *	between BSS and stack.
!  *    WBC	Sun Nov 11 11:07:06 PST 1990
!  *	Previous collision check prevented collisions but also refused
!  *	allocate more pages on alloc_break and alloc_stack even when
!  *	there was memory available.
!  */
! 
! #include "kernel.h"
! #include <minix/com.h>
! #include "proc.h"
! #include <minix/mmu.h>
  
  #define MAX_STACK_GROWTH_PGS	16
  
***************
*** 241,247 ****
    tbl[S_STACK].pg_cnt = RNDUPPAGE(stack)/PAGESZ;
  
    init_alloc_tbl (tbl);
!   /* this prevents heap/stack collision */
    if (tpgs + dpgs + bpgs + tbl[S_STACK].pg_cnt >= num_free_pages) return OK+4;
    /* alloc level 1 table */
    if (NULL == (ptb = get_zero_page())) {
--- 232,238 ----
    tbl[S_STACK].pg_cnt = RNDUPPAGE(stack)/PAGESZ;
  
    init_alloc_tbl (tbl);
!   /* avoid a lot of work if alloc is going to fail anyway */
    if (tpgs + dpgs + bpgs + tbl[S_STACK].pg_cnt >= num_free_pages) return OK+4;
    /* alloc level 1 table */
    if (NULL == (ptb = get_zero_page())) {
***************
*** 355,362 ****
    int			ret = OK;
  
    new_top_pg = PAGENUM (vaddr);		/* (vaddr & PAGEMASK) / PAGESZ; */
-   if (new_top_pg + procp->p_map.slen + 1 >= num_free_pages)
-     return NOT_OK;			/* insure BSS/stack gap */
    new_bot_pg = procp->p_map.tlen + procp->p_map.dlen;
    tbl.pg_cnt = NEW_PG_CNT - OLD_PG_CNT;
    if (tbl.pg_cnt > 0) {
--- 346,351 ----
***************
*** 398,406 ****
    new_bot_pg = PAGENUM(vaddr);		/*(vaddr & PAGEMASK) / PAGESZ; */
    new_top_pg = NUM_UPAGES - 1 - procp->p_map.slen;
    tbl.pg_cnt = new_top_pg - new_bot_pg + 1;
-   if (tbl.pg_cnt +			/* insure BSS/stack gap */
-   procp->p_map.tlen + procp->p_map.dlen + procp->p_map.slen >= num_free_pages)
-     return NOT_OK;	
    if (tbl.pg_cnt > 0) {
      tbl.ix1 = PG_TO_IX1 (new_top_pg);
      tbl.ix2 = PG_TO_IX2 (new_top_pg);
--- 387,392 ----
***************
*** 488,499 ****
      (pagenum > TOP_PGNUM - procp->p_map.slen &&
       pagenum <= TOP_PGNUM))
    {
!     return alloc_copy_on_write (procp, vaddr) == OK? OK: E_NO_MEM;
    } else if (				/* check for stack growth */
      pagenum <= TOP_PGNUM - procp->p_map.slen &&
      pagenum > TOP_PGNUM - procp->p_map.slen - MAX_STACK_GROWTH_PGS)
    {
!     return alloc_stack (procp, vaddr) == OK? OK: E_NO_MEM;
    } else return E_BAD_ADDR;
  }
  
--- 474,485 ----
      (pagenum > TOP_PGNUM - procp->p_map.slen &&
       pagenum <= TOP_PGNUM))
    {
!     return alloc_copy_on_write (procp, vaddr) == OK? OK: ENOMEM;
    } else if (				/* check for stack growth */
      pagenum <= TOP_PGNUM - procp->p_map.slen &&
      pagenum > TOP_PGNUM - procp->p_map.slen - MAX_STACK_GROWTH_PGS)
    {
!     return alloc_stack (procp, vaddr) == OK? OK: ENOMEM;
    } else return E_BAD_ADDR;
  }
  
***************
*** 556,562 ****
      inc = -1;
    }
    for (; p >= lp && p <= hp; p += inc) {
!     if (NULL == (new_page = info->zero? get_zero_page(): get_dirty_page())) {
        ret = NOT_OK;		/* alloc failed, cleanup */
        break;
      } else {
--- 542,551 ----
      inc = -1;
    }
    for (; p >= lp && p <= hp; p += inc) {
!     if (*p != 0 ||		/* heap collided with stack */
!       NULL ==			/* no free pages */
! 	(new_page = info->zero? get_zero_page(): get_dirty_page()))
!     {
        ret = NOT_OK;		/* alloc failed, cleanup */
        break;
      } else {
*** /home/phil/min1.5ref/kernel-1.3/const.h	Wed Nov 14 00:24:48 1990
--- kernel-1.3/const.h	Sat Jan  5 21:35:48 1991
***************
*** 40,45 ****
--- 40,56 ----
  
  #ifdef NS32K
  #define RET_REG		7	/* system call return codes go in this reg */
+ #define INIT_NAME "/etc/init"	/* path for INIT */
+ #define INIT_PID  1
+ /* Device numbers of root (RAM) and boot (fd0) devices. */
+ #  define NQ		3
+ #  define NR_REGS	8
+ #  define NR_FREGS	8
+ 
+ #  define MEM_MAJOR	1
+ #  define SCSI_MAJOR	2
+ #  define TTY0_MAJOR	3	/* real serial devices */
+ #  define TTY_MAJOR	4	/* control terminal pseudo device */
  #endif
  
  #define K_STACK_BYTES    512	/* how many bytes for the kernel stack */
***************
*** 53,55 ****
--- 64,69 ----
  #define USER_Q             2	/* ready users are scheduled via queue 2 */
  
  #define printf        printk	/* the kernel really uses printk, not printf */
+ 
+ /*===============  for 1.5.10  =====================*/
+ #define SCATTERED_IO	6
*** /home/phil/min1.5ref/kernel-1.3/copy.c	Wed Nov 14 00:24:49 1990
--- kernel-1.3/copy.c	Fri Nov  9 16:03:48 1990
***************
*** 1,10 ****
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/error.h"
! #include "const.h"
! #include "proc.h"
! #include "../h/32k.h"
! #include "../h/mmu.h"
  
  /*===========================================================================*
   *				v_copy
--- 1,6 ----
! #include "kernel.h"
! #include "proc.h"
! #include <minix/mmu.h>
  
  /*===========================================================================*
   *				v_copy
*** /home/phil/min1.5ref/kernel-1.3/idle.c	Wed Nov 14 00:24:49 1990
--- kernel-1.3/idle.c	Fri Nov  9 16:03:48 1990
***************
*** 1,5 ****
! #include "../h/32k.h"
! #include "../h/mmu.h"
  
  /*===========================================================================*
   *				idle_task
--- 1,5 ----
! #include "32k.h"
! #include <minix/mmu.h>
  
  /*===========================================================================*
   *				idle_task
*** /home/phil/min1.5ref/kernel-1.3/init.c	Wed Nov 14 00:24:49 1990
--- kernel-1.3/init.c	Fri Nov  9 16:03:48 1990
***************
*** 1,9 ****
  /* Various 32k hardware routines including initialization.
   */
  
! #include "../h/32k.h"
! #include "../h/const.h"
! #include "const.h"
  
  #define CLK_HZ		3686400/4	/* raw ICU clock speed */
  #define CLK_DIV		(CLK_HZ / HZ)	/* ICU clock divisor */
--- 1,7 ----
  /* Various 32k hardware routines including initialization.
   */
  
! #include "kernel.h"
  
  #define CLK_HZ		3686400/4	/* raw ICU clock speed */
  #define CLK_DIV		(CLK_HZ / HZ)	/* ICU clock divisor */
***************
*** 206,215 ****
  unsigned int bit;
  {
    unsigned short i;
! 
    i = *((volatile unsigned short *)(ICU_ADR + IMSK));
    i &= ~bit;
    *((volatile unsigned short *)(ICU_ADR + IMSK)) = i;
  }
  
  /*===========================================================================*
--- 204,216 ----
  unsigned int bit;
  {
    unsigned short i;
!   int t;
! 
!   t = lock();
    i = *((volatile unsigned short *)(ICU_ADR + IMSK));
    i &= ~bit;
    *((volatile unsigned short *)(ICU_ADR + IMSK)) = i;
+   restore(t);
  }
  
  /*===========================================================================*
***************
*** 219,226 ****
  unsigned int bit;
  {
    unsigned short i;
! 
    i = *((volatile unsigned short *)(ICU_ADR + IMSK));
    i |= bit;
    *((volatile unsigned short *)(ICU_ADR + IMSK)) = i;
  }
--- 220,230 ----
  unsigned int bit;
  {
    unsigned short i;
!   int t;
! 
!   t = lock();
    i = *((volatile unsigned short *)(ICU_ADR + IMSK));
    i |= bit;
    *((volatile unsigned short *)(ICU_ADR + IMSK)) = i;
+   restore(t);
  }
*** /home/phil/min1.5ref/kernel-1.3/main.c	Wed Nov 14 00:24:49 1990
--- kernel-1.3/main.c	Fri Nov  9 16:03:48 1990
***************
*** 1,14 ****
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "../h/signal.h"
! #include "const.h"
! #include "type.h"
! #include "glo.h"
! #include "proc.h"
! #include "../h/32k.h"
  
  extern struct tasktab tasktab[];
  extern int t_stack[], nkt;
--- 1,8 ----
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include <signal.h>
! #include "proc.h"
  
  extern struct tasktab tasktab[];
  extern int t_stack[], nkt;
*** /home/phil/min1.5ref/kernel-1.3/memory.c	Wed Nov 14 00:24:49 1990
--- kernel-1.3/memory.c	Fri Nov  9 16:03:48 1990
***************
*** 3,8 ****
--- 3,10 ----
   *     /dev/mem		- absolute memory
   *     /dev/kmem	- kernel virtual memory
   *     /dev/ram		- RAM disk
+  *     /dev/port	- For the IBM PC
+  *     /dev/rtc         - Real Time Clock  (ifdef RTC for pc532)
   * It accepts three messages, for reading, for writing, and for
   * control. All use message format m2 and with these parameters:
   *
***************
*** 22,39 ****
   *
   */
  
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "const.h"
! #include "type.h"
! #include "proc.h"
! #include "../h/32k.h"
! #include "../h/mmu.h"
! 
! #define NR_RAMS            4		/* number of RAM-type devices */
  PRIVATE message mem_mess;		/* message buffer */
  unsigned long ram_origin[NR_RAMS];	/* origin of each RAM disk  */
  unsigned long ram_limit[NR_RAMS];	/* limit of RAM disk per minor dev. */
--- 24,36 ----
   *
   */
  
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include "proc.h"
! #include <minix/mmu.h>
! 
! #define NR_RAMS            5		/* number of RAM-type devices */
  PRIVATE message mem_mess;		/* message buffer */
  unsigned long ram_origin[NR_RAMS];	/* origin of each RAM disk  */
  unsigned long ram_limit[NR_RAMS];	/* limit of RAM disk per minor dev. */
***************
*** 67,72 ****
--- 64,70 ----
  	switch(mem_mess.m_type) {
  	    case DISK_READ:	r = do_mem(&mem_mess);	break;
  	    case DISK_WRITE:	r = do_mem(&mem_mess);	break;
+ 	    case SCATTERED_IO:	r = do_vrdwt(&mem_mess, do_mem); break;
  	    case DISK_IOCTL:	r = do_setup(&mem_mess);	break;
  	    default:		r = EINVAL;			break;
  	}
***************
*** 93,103 ****
    /* Get minor device number and check for /dev/null. */
    device = m_ptr->DEVICE;
    if (device < 0 || device >= NR_RAMS) return(ENXIO);	/* bad minor device */
!   if (device==NULL_DEV) return(m_ptr->m_type == DISK_READ ? EOF : m_ptr->COUNT);
  
    /* Set up 'mem_phys' for /dev/mem, /dev/kmem, or /dev/ram. */
    mem_phys = ram_origin[device] + m_ptr->POSITION;
!   if (mem_phys >= ram_limit[device]) return(EOF);
    count = m_ptr->COUNT;
    if(mem_phys + count > ram_limit[device]) count = ram_limit[device] - mem_phys;
  
--- 91,104 ----
    /* Get minor device number and check for /dev/null. */
    device = m_ptr->DEVICE;
    if (device < 0 || device >= NR_RAMS) return(ENXIO);	/* bad minor device */
!   if (device==NULL_DEV) return(m_ptr->m_type == DISK_READ ? 0 : m_ptr->COUNT);
! #if defined RTC
!   if (device==RTC_DEV)  return do_rtc(m_ptr);
! #endif
  
    /* Set up 'mem_phys' for /dev/mem, /dev/kmem, or /dev/ram. */
    mem_phys = ram_origin[device] + m_ptr->POSITION;
!   if (mem_phys >= ram_limit[device]) return(0);
    count = m_ptr->COUNT;
    if(mem_phys + count > ram_limit[device]) count = ram_limit[device] - mem_phys;
  
***************
*** 125,127 ****
--- 126,227 ----
      (long) m_ptr->COUNT * BLOCK_SIZE;
    return(OK);
  }
+ 
+ #if defined RTC
+ /*===========================================================================*
+  *                              do_rtc                                       *
+  *===========================================================================*/
+ PRIVATE int do_rtc(message *m_ptr)
+ {
+   /* Wrapper for do_rw_rtc. Disable the cache and restore it afterwards */
+   int cache_bit = disable_cache();
+   int return_value;
+   return_value = do_rw_rtc(m_ptr);
+   restore_cache(cache_bit);
+   return return_value;
+ }
+ 
+ /*===========================================================================*
+  *                              do_rw_rtc                                    *
+  *===========================================================================*/
+ PRIVATE int do_rw_rtc(message *m_ptr)
+ {
+   /* Read or write to the real time chip. Address line A0 functions as
+    * data input, A2 is used as the /write signal. Accesses to the RTC
+    * are always done to one of the addresses:
+    *
+    * 0x10000000  -  write a '0' bit
+    * 0x10000001  -  write a '1' bit
+    * 0x10000004  -  read a bit
+    *
+    * Data is output from the RTC using D0. To read or write time
+    * information, the chip has to be activated first, to distinguish
+    * clock accesses from normal ROM reads. This is done by writing,
+    * bit by bit, a magic pattern to the chip. Before that, a dummy read
+    * assures that the chip's pattern comparison register pointer is
+    * reset. The RTC register file is always read or written wholly,
+    * even if we are only interested in a part of it.
+    */
+ 
+   static unsigned char magic[8] =
+     {0xc5, 0x3a, 0xa3, 0x5c, 0xc5, 0x3a, 0xa3, 0x5c};
+   volatile unsigned char * const rom_p = (unsigned char *)ROM_ORIGIN;
+   unsigned char buffer[8];
+   unsigned char *bp;
+   long count;
+   unsigned char dummy;         /* To defeat optimization */
+ 
+   if (m_ptr->POSITION > 8) return(0);  /* EOF should be returned. */
+   count = m_ptr->COUNT;
+   if (m_ptr->POSITION + m_ptr->COUNT > 8) count = 8 - m_ptr->POSITION;
+ 
+   /* Activate the real time chip */
+   dummy = rom_p[4];            /* Synchronize the comparison reg. */
+ 
+   for (bp=magic; bp<magic+8; bp++) {
+     int i;
+     for (i=0; i<8; i++)
+       dummy = rom_p[ (*bp>>i) & 0x01 ];
+   }
+ 
+   /* Read the time from the RTC. Do this even if message type is DISK_WRITE,
+    * since the user might have only given partial data and the RTC must
+    * always be written completely.
+    */
+ 
+   for (bp=buffer; bp<buffer+8; bp++) {
+     int i;
+     for (i=0; i<8; i++) {
+       *bp >>= 1;
+       *bp |= ((rom_p[4] & 0x01) ? 0x80 : 0x00);
+     }
+   }
+ 
+   if (m_ptr->m_type == DISK_READ) {   /* return the time from buffer */
+     if (OK != rw_user (m_ptr->PROC_NR, (long)(m_ptr->ADDRESS),
+           buffer + m_ptr->POSITION, (long)count, TO_USER))
+       return E_BAD_ADDR;
+   } else {                            /* write to the RTC */
+     if (OK != rw_user (m_ptr->PROC_NR, (long)(m_ptr->ADDRESS),
+           buffer + m_ptr->POSITION, (long)count, FROM_USER))
+       return E_BAD_ADDR;
+ 
+     /* Reactivate the real time chip */
+     dummy = rom_p[4];
+ 
+     for (bp=magic; bp<magic+8; bp++) {
+       int i;
+       for (i=0; i<8; i++)
+         dummy = rom_p[ (*bp>>i) & 0x01 ];
+     }
+ 
+     /* Write to the RTC */
+     for (bp=buffer; bp<buffer+8; bp++) {
+       int i;
+       for (i=0; i<8; i++)
+         dummy = rom_p[ (*bp>>i) & 0x01 ];
+     }
+   }
+   return count;
+ }
+ #endif
*** /home/phil/min1.5ref/kernel-1.3/proc.c	Wed Nov 14 00:24:50 1990
--- kernel-1.3/proc.c	Fri Nov  9 16:03:49 1990
***************
*** 13,28 ****
   *   pick_proc:	pick a process to run (used by system initialization)
   */
  
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "const.h"
! #include "type.h"
! #include "../h/32k.h"
! #include "../h/mmu.h"
! #include "glo.h"
  #include "proc.h"
  
  #define STRICT_MSG_CHK 0
--- 13,22 ----
   *   pick_proc:	pick a process to run (used by system initialization)
   */
  
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include <minix/mmu.h>
  #include "proc.h"
  
  #define STRICT_MSG_CHK 0
***************
*** 143,150 ****
    if (dest_ptr->p_flags & SENDING) {
  	next_ptr = caller_ptr->p_callerq;
  	while (next_ptr) {
! 		if (next_ptr == dest_ptr)
! 			return(E_LOCKED);
  		next_ptr = next_ptr->p_sendlink;
  	}
    }
--- 137,143 ----
    if (dest_ptr->p_flags & SENDING) {
  	next_ptr = caller_ptr->p_callerq;
  	while (next_ptr) {
! 		if (next_ptr == dest_ptr) return(ELOCKED);
  		next_ptr = next_ptr->p_sendlink;
  	}
    }
*** /home/phil/min1.5ref/kernel-1.3/proc.h	Wed Nov 14 00:24:50 1990
--- kernel-1.3/proc.h	Fri Feb  1 12:51:27 1991
***************
*** 8,26 ****
  EXTERN struct proc {
    long p_reg[NR_REGS];		/* process' registers */
    double p_freg[NR_FREGS];	/* process' float registers */
!   long p_sp;			/* 64 stack pointer */
!   long p_fp;			/* 68 frame pointer */
!   long p_pc;			/* 72 program counter */
!   long p_mod_psr;		/* 76 module table, processor status */
!   int p_flags;			/* 80 P_SLOT_FREE,SENDING,RECEIVING, etc. */
!   struct mem_map p_map;		/* 84 memory map */
!   int p_pid;			/* process id passed in from MM */
! 
!   real_time user_time;		/* user time in ticks */
!   real_time sys_time;		/* sys time in ticks */
!   real_time child_utime;	/* cumulative user time of children */
!   real_time child_stime;	/* cumulative sys time of children */
!   real_time p_alarm;		/* time of next alarm in ticks, or 0 */
  
    struct proc *p_callerq;	/* head of list of procs wishing to send */
    struct proc *p_sendlink;	/* link to next proc wishing to send */
--- 8,28 ----
  EXTERN struct proc {
    long p_reg[NR_REGS];		/* process' registers */
    double p_freg[NR_FREGS];	/* process' float registers */
!   long p_sp;			/* 96 stack pointer */
!   long p_fp;			/* 100 frame pointer */
!   long p_pc;			/* 104 program counter */
!   long p_sb;			/* 108 static base */
!   long p_mod_psr;		/* 112 module table, processor status */
!   long p_fsr;			/* 116 floating point status reg */
!   int p_flags;			/* 120 P_SLOT_FREE,SENDING,RECEIVING, etc. */
!   struct mem_map p_map;		/* 124 memory map */
!   int p_pid;			/* process id passed in from MM */
! 
!   time_t user_time;		/* user time in ticks */
!   time_t sys_time;		/* sys time in ticks */
!   time_t child_utime;		/* cumulative user time of children */
!   time_t child_stime;		/* cumulative sys time of children */
!   time_t p_alarm;		/* time of next alarm in ticks, or 0 */
  
    struct proc *p_callerq;	/* head of list of procs wishing to send */
    struct proc *p_sendlink;	/* link to next proc wishing to send */
***************
*** 39,44 ****
--- 41,47 ----
  #define PENDING          020	/* set when process has signals pending */
  #define TRAP_PENDING	 040	/* new NS32k */
  
+ #define isokusern(n)      ((unsigned) ((n) - LOW_USER) < NR_PROCS - LOW_USER)
  #define proc_addr(n) &proc[NR_TASKS + n]
  #define NIL_PROC (struct proc *) 0
  
*** /home/phil/min1.5ref/kernel-1.3/scsi_8490.c	Wed Nov 14 00:24:50 1990
--- kernel-1.3/scsi_8490.c	Fri Nov  9 16:03:49 1990
***************
*** 7,19 ****
   * necessary.
   ****************************************************************************/
  
! #include "../h/const.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "../h/type.h"
! #include "../h/32k.h"
! #include "const.h"			/* for printk if nothing else */
! #include "glo.h"
  
  #undef PRIVATE
  #define PRIVATE
--- 7,14 ----
   * necessary.
   ****************************************************************************/
  
! #include "kernel.h"
! #include <minix/com.h>
  
  #undef PRIVATE
  #define PRIVATE
***************
*** 373,378 ****
--- 368,374 ----
    sc_dma_len = scp->len;
  }
  
+ #ifdef DOIT_IN_C
  /*===========================================================================*
   *				sc_transfer				     *
   *===========================================================================*/
***************
*** 415,420 ****
--- 411,418 ----
    return isr_ret;
  }
  
+ #endif
+ 
  /*===========================================================================*
   *				sc_rd_isr
   *===========================================================================*/
*** /home/phil/min1.5ref/kernel-1.3/scsi_hi.c	Wed Nov 14 00:24:51 1990
--- kernel-1.3/scsi_hi.c	Sun Feb 10 13:31:30 1991
***************
*** 17,32 ****
   *
   */
  
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "const.h"
! #include "type.h"
! #include "glo.h"
! #include "proc.h"
! #include "../h/32k.h"
  
  #define U8 unsigned char
  
--- 17,26 ----
   *
   */
  
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include "proc.h"
  
  #define U8 unsigned char
  
***************
*** 176,231 ****
  	sizeof(wini_parms_cmd), sizeof(wini_parms_data)};
  #endif
  
! /* Drive table */
! PRIVATE struct drive drive_tbl[] = {
! # ifdef OMTI
!   /* These entries are for Bruce Culbertson's OMTI interface and the
!    * floppy and hard disk attached to it.
!    */
!   {1, 0, D8490 | SING_SEC_WR, 0, 2, (17*4)/2, &wini_init0},	/* winchester */
!   {1, 1, D8490 | SING_SEC_WR, 0, 2, (9*2)/2, &floppy_init0},	/* floppy */
! # define WINI 0
! # define FLOP 1
! # define DEFAULT 2
! # else
! # define DEFAULT 0
! # endif
!   /* This entry uses scsi_adr=1 and scsi_lun=0, which I think will be
!    * the most common setup.
!    */
!   {1, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
!   /* These entries exist so that you can patch the binary to add more
!    * disks.  Assuming 512 byte sectors, full SCSI.
!    */
!   {0, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
!   {0, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
!   {0, 0, D8490 | EXTENDED_RDWR | EXTENDED_SENSE, 0, 2, 0, &default_init0},
! };
! #define DRV_TBL_SZ (sizeof (drive_tbl) / sizeof (struct drive))
! 
! /* Partition table */
! PRIVATE
! struct partition_tbl part_tbl [] = {
! # ifdef OMTI
! #   define	ST225LEN ((512*17*4*612)/BLOCK_SIZE)	/* 20808K */
! #   define	PART1LEN ((512*17*4*4)/BLOCK_SIZE)	/* 136K */
! #   define	PART2LEN (ST225LEN - PART1LEN)		/* 20672K */
! #   define	FLOPLEN	 ((512*9*2*40)/BLOCK_SIZE)	/* 360K */
!   {0, ST225LEN, &drive_tbl[WINI], 1},		/* minor 0 whole hard disk */
!   {0, PART1LEN, &drive_tbl[WINI], 1},		/* minor 1 boot image */
!   {PART1LEN, PART2LEN, &drive_tbl[WINI], 1},	/* minor 2 rest of hard disk */
!   {0, FLOPLEN, &drive_tbl[FLOP], 1},		/* minor 3 floppy */
! # else
! /* patch in your own config */
! /* start	length	drive		interleave */
!   {0,		40256,	&drive_tbl[DEFAULT], 1},	/* /dev/hd0 */
!   {0,		256,	&drive_tbl[DEFAULT], 1},	/* /dev/hd1 */
!   {256,		10000,	&drive_tbl[DEFAULT], 1},	/* /dev/hd2 */
!   {10256,	10000,	&drive_tbl[DEFAULT], 1},	/* /dev/hd3 */
!   {20256,	10000,	&drive_tbl[DEFAULT], 1},	/* /dev/hd4 */
!   {30256,	10000,	&drive_tbl[DEFAULT], 1},	/* /dev/hd5 */
! # endif
! };
  #define NR_DRIVES	(sizeof (part_tbl) / sizeof (struct partition_tbl))
  
  /* Round up these buffer lengths to multiple of four since SCSI
--- 170,177 ----
  	sizeof(wini_parms_cmd), sizeof(wini_parms_data)};
  #endif
  
! /* Get the definitions of the drives and the partitions. */
! #include "partition.h"
  #define NR_DRIVES	(sizeof (part_tbl) / sizeof (struct partition_tbl))
  
  /* Round up these buffer lengths to multiple of four since SCSI
***************
*** 285,290 ****
--- 231,237 ----
  	    case DISK_READ:	r = sc_rdwt(&sc_msg);	break;
  	    case DISK_WRITE:	r = sc_rdwt(&sc_msg);	break;
   	    case HARD_INT:	continue;		break;
+ 	    case SCATTERED_IO:	r = do_vrdwt(&sc_msg, sc_rdwt); break;
  	    default:		r = EINVAL;		break;
  	}
  
***************
*** 316,322 ****
    part = &part_tbl[drive];
    drivep = part->drive;
    virt_block = m_ptr->POSITION / BLOCK_SIZE;
!   if (virt_block >= part->len) return EOF;
  
    /* convert virtual block to physical block and sector */
    if (part->interleave != 1) {
--- 263,269 ----
    part = &part_tbl[drive];
    drivep = part->drive;
    virt_block = m_ptr->POSITION / BLOCK_SIZE;
!   if (virt_block >= part->len) return ENXIO/*EOF*/;
  
    /* convert virtual block to physical block and sector */
    if (part->interleave != 1) {
*** /home/phil/min1.5ref/kernel-1.3/system.c	Wed Nov 14 00:24:51 1990
--- kernel-1.3/system.c	Tue Nov 20 17:02:28 1990
***************
*** 61,83 ****
   * In addition to the main sys_task() entry point, there are three other minor
   * entry points:
   *   cause_sig:	take action to cause a signal to occur, sooner or later
!  *   inform:	tell MM about pending signals
   *   umap:	compute the physical address for a given virtual address
   */
  
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "../h/signal.h"
! #include "const.h"
! #include "type.h"
! #include "glo.h"
! #include "proc.h"
! #include "../h/32k.h"
! #include "../h/mmu.h"
! #include "../h/a.out.h"
  
  #define COPY_UNIT     65534L	/* max bytes to copy at once */
  
--- 61,78 ----
   * In addition to the main sys_task() entry point, there are three other minor
   * entry points:
   *   cause_sig:	take action to cause a signal to occur, sooner or later
!  *   inform
! :	tell MM about pending signals
   *   umap:	compute the physical address for a given virtual address
   */
  
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include <signal.h>
! #include "proc.h"
! #include <minix/mmu.h>
! #include <a.out.h>
  
  #define COPY_UNIT     65534L	/* max bytes to copy at once */
  
***************
*** 96,102 ****
    register int r;
    extern char version[];
  
!   printf ("Minix 1.3 kernel version: %s\n", version);
    mem_init();
    while (TRUE) {
  	receive(ANY, &m);
--- 91,97 ----
    register int r;
    extern char version[];
  
!   printf ("Minix 1.5 hybrid kernel version: %s\n", version);
    mem_init();
    while (TRUE) {
  	receive(ANY, &m);
***************
*** 157,163 ****
    *rpc = *rpp;
  
    /* alloc memory space for child */
!   if (OK != alloc_fork (rpp, rpc)) return E_NO_MEM;
  
    /*rpc->p_flags |= NO_MAP;*/	/* inhibit the process from running */
    rpc->p_pid = m_ptr->PID;	/* install child's pid */
--- 152,158 ----
    *rpc = *rpp;
  
    /* alloc memory space for child */
!   if (OK != alloc_fork (rpp, rpc)) return ENOMEM;
  
    /*rpc->p_flags |= NO_MAP;*/	/* inhibit the process from running */
    rpc->p_pid = m_ptr->PID;	/* install child's pid */
***************
*** 226,232 ****
    if 					/* alloc new memory space */
    (alloc_exec (rp, m_ptr->TPGS, m_ptr->DPGS, m_ptr->BPGS, stk_len) != OK) {
      rp->p_map = old_p_map;		/* restore old memory map */
!     return E_NO_MEM;
    }
    sp = (TOP_VADDR - stk_len + 1)	/* compute new SP */
      & ~3;				/* align SP */
--- 221,227 ----
    if 					/* alloc new memory space */
    (alloc_exec (rp, m_ptr->TPGS, m_ptr->DPGS, m_ptr->BPGS, stk_len) != OK) {
      rp->p_map = old_p_map;		/* restore old memory map */
!     return ENOMEM;
    }
    sp = (TOP_VADDR - stk_len + 1)	/* compute new SP */
      & ~3;				/* align SP */
***************
*** 371,377 ****
    register struct proc *rp;
    int proc_nr;			/* process number */
    int sig;			/* signal number 1-16 */
!   int (*sig_handler)();		/* pointer to the signal handler */
    long new_sp;
    struct int_stack {
      int signum;
--- 366,372 ----
    register struct proc *rp;
    int proc_nr;			/* process number */
    int sig;			/* signal number 1-16 */
!   void (*sig_handler)();	/* pointer to the signal handler */
    long new_sp;
    struct int_stack {
      int signum;
***************
*** 380,393 ****
  
    /* Extract parameters and prepare to build the words that get pushed. */
    proc_nr = m_ptr->PR;		/* process being signalled */
!   sig = m_ptr->SIGNUM;		/* signal number, 1 to 16 */
!   sig_handler = m_ptr->FUNC;	/* run time system addr for catching sigs */
!   if (proc_nr < LOW_USER || proc_nr >= NR_PROCS) return(E_BAD_PROC);
!   rp = proc_addr(proc_nr);
  
    new_sp = rp->p_sp - sizeof (struct int_stack);
    if (OK != alloc_stack (rp, new_sp))	/* grow stack if necessary */
!     return E_NO_MEM;
    stack.return_pc = (int (*)()) rp->p_pc;
    stack.signum = sig;
  
--- 375,398 ----
  
    /* Extract parameters and prepare to build the words that get pushed. */
    proc_nr = m_ptr->PR;		/* process being signalled */
!   if (proc_nr < LOW_USER || proc_nr >= NR_PROCS) return(E_BAD_PROC);
!   rp = proc_addr(proc_nr);
!   sig = m_ptr->SIGNUM;		/* signal number, 1 to 16 */
!   if (sig == -1) { /* new for 1.5 */
! 	/* Except -1 is kludged to mean "finished one KSIG". */
! #if 0
! 	if (rp->p_pendcount != 0 &&
! 	    --rp->p_pendcount == 0 &&
! 	    (rp->p_flags &= ~SIG_PENDING) == 0)
! 		lock_ready(rp);
! #endif
! 	return(OK);
!   }
!   sig_handler = m_ptr->FUNC;	/* run time system addr for catching sigs */
  
    new_sp = rp->p_sp - sizeof (struct int_stack);
    if (OK != alloc_stack (rp, new_sp))	/* grow stack if necessary */
!     return ENOMEM;
    stack.return_pc = (int (*)()) rp->p_pc;
    stack.signum = sig;
  
***************
*** 396,402 ****
  
    rp->p_pc = (long)sig_handler;
    rp->p_sp = new_sp;
- 
    return(OK);
  }
  
--- 401,406 ----
***************
*** 414,420 ****
  
    proc_nr = m_ptr->PR;		/* process being signalled */
    sig = m_ptr->SIGNUM;		/* signal number, 1 to 16 */
!   if (proc_nr < LOW_USER || proc_nr >= NR_PROCS) return(E_BAD_PROC);
    cause_sig(proc_nr, sig);
    return(OK);
  }
--- 418,425 ----
  
    proc_nr = m_ptr->PR;		/* process being signalled */
    sig = m_ptr->SIGNUM;		/* signal number, 1 to 16 */
! /*  if (proc_nr < LOW_USER || proc_nr >= NR_PROCS) return(E_BAD_PROC); */
!   if (!isokusern(proc_nr)) return(E_BAD_PROC);
    cause_sig(proc_nr, sig);
    return(OK);
  }
***************
*** 633,641 ****
  	if (OK == r) {
  	  rp->p_flags &= ~TRAP_PENDING;
  	  if (rp->p_flags == 0) ready (rp);
! 	} else if (r == E_NO_MEM)
! 	  cause_sig (m_ptr->T_PROC, SIGMEM);
! 	else cause_sig (m_ptr->T_PROC, SIGBUS);
  	break;
      case VEC_SLAVE:
  	cause_sig (m_ptr->T_PROC, SIGFPE);
--- 638,646 ----
  	if (OK == r) {
  	  rp->p_flags &= ~TRAP_PENDING;
  	  if (rp->p_flags == 0) ready (rp);
! 	} else if (r == ENOMEM)
! 	  cause_sig (m_ptr->T_PROC, SIGSEGV /*SIGMEM*/);
! 	  else cause_sig (m_ptr->T_PROC, SIGBUS);
  	break;
      case VEC_SLAVE:
  	cause_sig (m_ptr->T_PROC, SIGFPE);
***************
*** 644,656 ****
  	cause_sig (m_ptr->T_PROC, SIGILL);
  	break;
      case VEC_DVZ:
! 	cause_sig (m_ptr->T_PROC, SIGDVZ);
! 	break;
!     case VEC_FLG:
! 	cause_sig (m_ptr->T_PROC, SIGFLAG);
! 	break;
!     case VEC_BPT:
! 	cause_sig (m_ptr->T_PROC, SIGBPT);
  	break;
      case VEC_TRC:
  	cause_sig (m_ptr->T_PROC, SIGTRAP);
--- 649,661 ----
  	cause_sig (m_ptr->T_PROC, SIGILL);
  	break;
      case VEC_DVZ:
! 	cause_sig (m_ptr->T_PROC, SIGUSR1 /*SIGDVZ*/);
! 	break;
!     case VEC_FLG:
! 	cause_sig (m_ptr->T_PROC, SIGUSR2 /*SIGFLAG*/);
! 	break;
!     case VEC_BPT:
! 	cause_sig (m_ptr->T_PROC, SIGUNUSED /*SIGBPT*/);
  	break;
      case VEC_TRC:
  	cause_sig (m_ptr->T_PROC, SIGTRAP);
*** /home/phil/min1.5ref/kernel-1.3/table.c	Wed Nov 14 00:24:51 1990
--- kernel-1.3/table.c	Fri Dec 14 12:39:18 1990
***************
*** 24,38 ****
   * in one of the *.h files without the initialization.
   */
  
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/com.h"
! #include "const.h"
! #include "type.h"
! #undef   EXTERN
! #define  EXTERN
! #include "glo.h"
! #include "proc.h"
  
  extern int sys_task(), clock_task(), mem_task(),
             scsi_task(), tty_task(), idle_task(), fs_main(), mm_main(),
--- 24,34 ----
   * in one of the *.h files without the initialization.
   */
  
! #define _TABLE
! #include "kernel.h"
! #include <minix/com.h>
! #include "proc.h"
! #include "tty.h"
  
  extern int sys_task(), clock_task(), mem_task(),
             scsi_task(), tty_task(), idle_task(), fs_main(), mm_main(),
*** /home/phil/min1.5ref/kernel-1.3/tty.c	Sun Jan  6 10:57:06 1991
--- kernel-1.3/tty.c	Sun Jan 27 22:35:25 1991
***************
*** 50,55 ****
--- 50,59 ----
  #include <minix/com.h>
  #include "tty.h"
  
+ /* To get some definitions.  The 1.3 kernel does not have a proto.h file. */
+ #include "proto.h"
+ #include "proc.h"
+ 
  /* Array and macros to convert line numbers to structure pointers. */
  PRIVATE struct tty_struct *p_tty_addr[NR_CONS + NR_RS_LINES];
  #define ctty_addr(line) (&tty_struct[(line)])	/* faster if line is const */
***************
*** 254,268 ****
  
    scode = ch;			/* save the scan code */
  
    /* Function keys are temporarily being used for debug dumps. */
    if (isconsole(tp) && func_key(ch))
  	return;			/* just processed function key */
!   mode = tp->tty_mode & (RAW | CBREAK);
    if (tp->tty_makebreak == TWO_INTS) {
  	c = make_break(ch);	/* console give 2 ints/ch */
  	if (c == -1) return;
  	ch = c;
!   } else if (mode != RAW)
  	ch &= 0177;		/* 7-bit chars except in raw mode */
  
    /* Processing for COOKED and CBREAK mode contains special checks. */
--- 258,278 ----
  
    scode = ch;			/* save the scan code */
  
+ #if (NR_CONS > 0)
    /* Function keys are temporarily being used for debug dumps. */
    if (isconsole(tp) && func_key(ch))
  	return;			/* just processed function key */
! #endif
! 
!   mode = tp->tty_mode & (RAW | CBREAK);
! #if (NR_CONS > 0)
    if (tp->tty_makebreak == TWO_INTS) {
  	c = make_break(ch);	/* console give 2 ints/ch */
  	if (c == -1) return;
  	ch = c;
!   } else
! #endif
!      if (mode != RAW)
  	ch &= 0177;		/* 7-bit chars except in raw mode */
  
    /* Processing for COOKED and CBREAK mode contains special checks. */
***************
*** 345,350 ****
--- 355,361 ----
    if (ch == '\n' && tp->tty_incount < tp->tty_insize)
  	tp->tty_lfct++;		/* count line feeds */
  
+ #if (NR_CONS > 0)
    /* The numeric pad generates ASCII escape sequences: ESC [ letter */
    if (isconsole(tp) && (scode = letter_code(scode)) != 0) {
  	/* This key is to generate a three-character escape sequence. */
***************
*** 352,357 ****
--- 363,369 ----
  	in1_char(tp, BRACKET, BRACKET);
  	ch = scode;
    }
+ #endif
  
    in1_char(tp, ch, ch);
  }
***************
*** 369,378 ****
    if ( (tp->tty_mode & ECHO) == 0) return;	/* if no echoing, don't echo */
  /* MARKER is meaningful only in cooked mode */
    if (c != MARKER || tp->tty_mode & (CBREAK | RAW)) {
  	if (isconsole(tp)) {
  		out_char(tp, c);	/* echo to console */
  		flush(tp);		/* force character out onto screen */
! 	} else if (tp->tty_etail < tp->tty_ebufend)
  		*tp->tty_etail++ = c;	/* echo to RS232 line */
    }
  }
--- 381,393 ----
    if ( (tp->tty_mode & ECHO) == 0) return;	/* if no echoing, don't echo */
  /* MARKER is meaningful only in cooked mode */
    if (c != MARKER || tp->tty_mode & (CBREAK | RAW)) {
+ #if (NR_CONS > 0)
  	if (isconsole(tp)) {
  		out_char(tp, c);	/* echo to console */
  		flush(tp);		/* force character out onto screen */
! 	} else
! #endif
! 	    if (tp->tty_etail < tp->tty_ebufend)
  		*tp->tty_etail++ = c;	/* echo to RS232 line */
    }
  }
***************
*** 451,459 ****
--- 466,484 ----
    if (tp->tty_incount == 0 ||
        !(tp->tty_mode & (RAW | CBREAK)) && tp->tty_lfct == 0)
  	return(SUSPEND);
+ 
+ #if (MACHINE != PC532)
    if ( (user_phys = numap(tp->tty_inproc, (vir_bytes) tp->tty_in_vir,
                            (vir_bytes) tp->tty_inleft)) == 0)
  	return(E_BAD_ADDR);
+ #else
+   if ( !in_mem_space(proc_addr(tp->tty_inproc), (vir_bytes) tp->tty_in_vir,
+                           (vir_bytes) tp->tty_inleft))
+ 	return(E_BAD_ADDR);
+   /* Use the virtual address instead of phys. */
+   user_phys = (phys_bytes) tp->tty_in_vir;
+ #endif
+ 
    if (tp->tty_inleft > tp->tty_incount) tp->tty_inleft = tp->tty_incount;
    user_cum = 0;
  
***************
*** 491,498 ****
  	}
  
  	/* Copy at least half of buffer to user space. */
! 	phys_copy(tp->tty_inphys + (tp->tty_intail - tp->tty_inbuf),
! 		  user_phys, (phys_bytes) user_ct);
  	user_phys += user_ct;
  	user_cum += user_ct;
  	if ( (tp->tty_intail += ct) == tp->tty_inbufend)
--- 516,528 ----
  	}
  
  	/* Copy at least half of buffer to user space. */
! #if (MACHINE != PC532)
! 	phys_copy(tp->tty_inphys + (tp->tty_intail - tp->tty_inbuf),
! 		  user_phys, (phys_bytes) user_ct);
! #else
! 	v_copy ( NULL, tp->tty_inphys + (tp->tty_intail - tp->tty_inbuf),
! 		 proc_addr(tp->tty_inproc), user_phys, (phys_bytes) user_ct);
! #endif
  	user_phys += user_ct;
  	user_cum += user_ct;
  	if ( (tp->tty_intail += ct) == tp->tty_inbufend)
***************
*** 534,539 ****
--- 564,570 ----
  
    vir_bytes out_vir, out_left;
  
+ 
    /* If the slot is already in use, better return an error than mess it up. */
    if (tp->tty_outleft > 0) {	/* if someone else is hanging, give up */
  	tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, EIO);
***************
*** 547,552 ****
--- 578,584 ----
    tp->tty_outleft = m_ptr->COUNT;
  
    /* Compute the physical address where the data is in user space. */
+ #if (MACHINE != PC532)
    out_vir = (vir_bytes) tp->tty_out_vir;
    out_left = (vir_bytes) tp->tty_outleft;
    if ( (tp->tty_phys = numap(tp->tty_outproc, out_vir, out_left)) == 0) {
***************
*** 555,560 ****
--- 587,601 ----
  	tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, E_BAD_ADDR);
  	return;
    }
+ #else
+   if (!in_mem_space(proc_addr(tp->tty_outproc), tp->tty_out_vir, tp->tty_outleft)) {
+ 	/* Buffer address provided by user is outside its address space. */
+ 	tp->tty_outleft = 0;
+ 	tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, E_BAD_ADDR);
+ 	return;
+   }
+   tp->tty_phys = (phys_bytes) tp->tty_out_vir;
+ #endif
  
    /* Everything is OK.  Fill in remaining tty fields.  Only tty_waiting is
     * critical - it must be held at NOT_WAITING together with tty_outleft == 0
***************
*** 630,636 ****
  		 */
  		uninhibit(tp);
  	speed = (int) (m_ptr->TTY_SPEK >> 16);
! 	if (speed != 0) tp->tty_speed = speed;
  	if (isrs232(tp)) tp->tty_speed = rs_ioctl(tp->tty_line, tp->tty_mode,
  						  tp->tty_speed);
  	break;
--- 671,681 ----
  		 */
  		uninhibit(tp);
  	speed = (int) (m_ptr->TTY_SPEK >> 16);
! #if (MACHINE == PC532)
! 	if ((speed & 0xc0c0) == 0) tp->tty_speed = speed;
! #else
! 	if (speed != 0) tp->tty_speed = speed;
! #endif
  	if (isrs232(tp)) tp->tty_speed = rs_ioctl(tp->tty_line, tp->tty_mode,
  						  tp->tty_speed);
  	break;
***************
*** 873,878 ****
--- 918,924 ----
  
    int count;
  
+ 
    if (tp->tty_rwords != 0)
  	return;			/* already going - xon handled at lower level*/
  
***************
*** 890,900 ****
  	if (tp->tty_mode & RAW) {
  		if (count > sizeof tp->tty_ramqueue)
  			count = sizeof tp->tty_ramqueue;
! 		phys_copy(tp->tty_phys, tp->tty_outphys, (phys_bytes) count);
  		tp->tty_rwords = count;
  	} else {
  		if (count > sizeof tty_buf) count = sizeof tty_buf;
! 		phys_copy(tp->tty_phys, tty_bphys, (phys_bytes) count);
  		count = out_process(tp, tty_buf, count);
  	}
  	rs_write(tp->tty_line, (char *) tp->tty_ramqueue, count);
--- 936,956 ----
  	if (tp->tty_mode & RAW) {
  		if (count > sizeof tp->tty_ramqueue)
  			count = sizeof tp->tty_ramqueue;
! #if (MACHINE != PC532)
! 		phys_copy(tp->tty_phys, tp->tty_outphys, (phys_bytes) count);
! #else
! 		v_copy(proc_addr(tp->tty_outproc), tp->tty_phys,
! 		       NULL, tp->tty_outphys, (phys_bytes) count);
! #endif
  		tp->tty_rwords = count;
  	} else {
  		if (count > sizeof tty_buf) count = sizeof tty_buf;
! #if (MACHINE != PC532)
! 		phys_copy(tp->tty_phys, tty_bphys, (phys_bytes) count);
! #else
! 		v_copy(proc_addr(tp->tty_outproc), tp->tty_phys,
! 		       NULL, tty_bphys, (phys_bytes) count);
! #endif
  		count = out_process(tp, tty_buf, count);
  	}
  	rs_write(tp->tty_line, (char *) tp->tty_ramqueue, count);
***************
*** 936,960 ****
  	tp = &tty_struct[line];
  	tp->tty_line = line - NR_CONS;
  	p_tty_addr[line] = tp;
! 	tty_bphys = umap(proc_ptr, D, (vir_bytes) tty_buf, sizeof tty_buf);
  	if (isconsole(tp)) {
  		tp->tty_inbuf = kb_inbuf[line];
  		tp->tty_inbufend = tp->tty_inbuf + KB_IN_BYTES;
  		tp->tty_ihighwater = KB_IN_BYTES;
  		tp->tty_ilow_water = KB_IN_BYTES;
  		tp->tty_insize = KB_IN_BYTES;
! 	} else {
  		tp->tty_inbuf = rs_inbuf[tp->tty_line];
  		tp->tty_inbufend = tp->tty_inbuf + RS_IN_BYTES;
  		tp->tty_ihighwater = RS_IN_BYTES - 2 * RS_IBUFSIZE;
  		tp->tty_ilow_water = (RS_IN_BYTES - 2 * RS_IBUFSIZE) * 7 / 8;
  		tp->tty_insize = RS_IN_BYTES;
  	}
! 	tp->tty_inphys = umap(proc_ptr, D, (vir_bytes) tp->tty_inbuf,
! 			      tp->tty_insize);
! 	tp->tty_intail = tp->tty_inhead = tp->tty_inbuf;
! 	tp->tty_outphys = umap(proc_ptr, D, (vir_bytes) tp->tty_ramqueue,
! 			       sizeof tp->tty_ramqueue);
  	tp->tty_etail = tp->tty_ebuf;
  	tp->tty_ebufend = tp->tty_ebuf + sizeof tp->tty_ebuf;
  	tp->tty_erase = ERASE_CHAR;
--- 992,1029 ----
  	tp = &tty_struct[line];
  	tp->tty_line = line - NR_CONS;
  	p_tty_addr[line] = tp;
! #if (MACHINE != PC532)
! 	tty_bphys = umap(proc_ptr, D, (vir_bytes) tty_buf, sizeof tty_buf);
! #else
! 	/* tty runs in unmapped space. */
! 	tty_bphys = (phys_bytes) tty_buf;
! #endif
! #if (NR_CONS > 0)
  	if (isconsole(tp)) {
  		tp->tty_inbuf = kb_inbuf[line];
  		tp->tty_inbufend = tp->tty_inbuf + KB_IN_BYTES;
  		tp->tty_ihighwater = KB_IN_BYTES;
  		tp->tty_ilow_water = KB_IN_BYTES;
  		tp->tty_insize = KB_IN_BYTES;
! 	} else
! #endif
! 	{
  		tp->tty_inbuf = rs_inbuf[tp->tty_line];
  		tp->tty_inbufend = tp->tty_inbuf + RS_IN_BYTES;
  		tp->tty_ihighwater = RS_IN_BYTES - 2 * RS_IBUFSIZE;
  		tp->tty_ilow_water = (RS_IN_BYTES - 2 * RS_IBUFSIZE) * 7 / 8;
  		tp->tty_insize = RS_IN_BYTES;
  	}
! #if (MACHINE != PC532)
! 	tp->tty_inphys = umap(proc_ptr, D, (vir_bytes) tp->tty_inbuf,
! 			      tp->tty_insize);
! 	tp->tty_outphys = umap(proc_ptr, D, (vir_bytes) tp->tty_ramqueue,
! 			       sizeof tp->tty_ramqueue);
! #else
! 	tp->tty_inphys = (phys_bytes) tp->tty_inbuf;
! 	tp->tty_outphys = (phys_bytes) tp->tty_ramqueue;
! #endif
! 	tp->tty_intail = tp->tty_inhead = tp->tty_inbuf;
  	tp->tty_etail = tp->tty_ebuf;
  	tp->tty_ebufend = tp->tty_ebuf + sizeof tp->tty_ebuf;
  	tp->tty_erase = ERASE_CHAR;
***************
*** 964,969 ****
--- 1033,1040 ----
  	tp->tty_xon   = XON_CHAR;
  	tp->tty_xoff  = XOFF_CHAR;
  	tp->tty_eof   = EOT_CHAR;
+ 	tp->tty_rwords= 0;		/* added - pan */
+ #if (NR_CONS > 0)
  	if (isconsole(tp)) {
  		tp->tty_devread = kb_read;
  		tp->tty_devstart = console;
***************
*** 971,980 ****
  		tp->tty_makebreak = TWO_INTS;
  		scr_init(tp->tty_line);
  		kb_init(tp->tty_line);
! 	} else {
! 		tp->tty_devread = rs_read;
! 		tp->tty_devstart = rs_start;
! 		tp->tty_mode = RAW | BITS8;
  		tp->tty_makebreak = ONE_INT;
  		tp->tty_speed = rs_init(tp->tty_line);
  		rs_setc(tp->tty_line, tp->tty_xoff);
--- 1042,1054 ----
  		tp->tty_makebreak = TWO_INTS;
  		scr_init(tp->tty_line);
  		kb_init(tp->tty_line);
! 	} else 
! #endif
! 	{
! 		tp->tty_devread = rs_read;
! 		tp->tty_devstart = rs_start;
! /*		tp->tty_mode = RAW | BITS8; */
! 		tp->tty_mode = COOKED | CRMOD | BITS8 | ECHO | XTABS;
  		tp->tty_makebreak = ONE_INT;
  		tp->tty_speed = rs_init(tp->tty_line);
  		rs_setc(tp->tty_line, tp->tty_xoff);
***************
*** 1023,1029 ****
  	if (tty_events >= EVENT_THRESHOLD || tty_events == previous_events ||
  	    --wakeup_timeout == 0) {
  		wakeup_timeout = WAKEUP_TIMEOUT;
! 		interrupt(TTY);
  	} else
  		tty_awake = FALSE;
  	previous_events = tty_events;
--- 1097,1104 ----
  	if (tty_events >= EVENT_THRESHOLD || tty_events == previous_events ||
  	    --wakeup_timeout == 0) {
  		wakeup_timeout = WAKEUP_TIMEOUT;
! 		tty_int_mess.m_type = HARD_INT;
! 		interrupt(TTY,&tty_int_mess);
  	} else
  		tty_awake = FALSE;
  	previous_events = tty_events;
*** /home/phil/min1.5ref/kernel-1.3/tty.h	Sun Jan  6 10:57:06 1991
--- kernel-1.3/tty.h	Sun Nov 11 18:01:26 1990
***************
*** 1,5 ****
! #define NR_CONS            1	/* how many consoles can system handle */
! #define	NR_RS_LINES	   2	/* how many rs232 terminals can system handle*/
  #define KB_IN_BYTES      200   	/* keyboard input queue size */
  #define RS_IN_BYTES   (1024 + 2 * RS_IBUFSIZE)	/* RS232 input queue size */
  #define TTY_RAM_WORDS    320	/* ram buffer size */
--- 1,5 ----
! #define NR_CONS            0	/* how many consoles can system handle */
! #define	NR_RS_LINES	   8	/* how many rs232 terminals can system handle*/
  #define KB_IN_BYTES      200   	/* keyboard input queue size */
  #define RS_IN_BYTES   (1024 + 2 * RS_IBUFSIZE)	/* RS232 input queue size */
  #define TTY_RAM_WORDS    320	/* ram buffer size */
*** /home/phil/min1.5ref/kernel-1.3/kernel.h	Wed Nov 14 01:24:21 1990
--- kernel-1.3/kernel.h	Wed Feb 13 19:00:23 1991
***************
*** 16,21 ****
  
  #include "const.h"
  #include "type.h"
! #include "proto.h"
! #include "glo.h"
! 
--- 16,25 ----
  
  #include "const.h"
  #include "type.h"
! /* #include "proto.h" */
! #include "glo.h"
! #ifdef NS32K
! #include "32k.h"
! #undef PRIVATE
! #define PRIVATE
! #endif
*** /home/phil/min1.5ref/kernel-1.3/32k.h	Wed Nov 14 01:23:58 1990
--- kernel-1.3/32k.h	Fri Nov  9 16:03:51 1990
***************
*** 90,92 ****
--- 90,96 ----
    unsigned long	len;
  };
  
+ #ifdef RTC
+ #define ROM_ORIGIN 0x10000000
+ #define ROM_SIZE 0x8000
+ #endif
*** /home/phil/min1.5ref/kernel-1.3/misc.c	Wed Nov 14 01:24:29 1990
--- kernel-1.3/misc.c	Fri Nov  9 16:03:51 1990
***************
*** 6,11 ****
--- 6,13 ----
   */
  
  #include "kernel.h"
+ /* #include "../fs/fs.h" */ 
+ #undef panic
  #include <minix/com.h>
  
  #if (CHIP == INTEL)
***************
*** 66,71 ****
--- 68,80 ----
  		mem_type[3] |= 1;
  	}
    }
+ #ifdef EMS
+   else {
+ 	mem_size[2] = k_to_click(ext_memsize);
+ 	mem_base[2] = EM_BASE >> CLICK_SHIFT;
+ 	mem_type[2] = 1;   /* force it extended (special even in prot) */
+   }
+ #endif /* EMS */
  }
  #endif /* (CHIP == INTEL) */
  
***************
*** 81,93 ****
   * status in the vector.
   */
  
!   register struct iorequest_s *iop;
!   static struct iorequest_s iovec[NR_BUFS];
!   phys_bytes iovec_phys;
!   unsigned nr_requests;
!   int request;
!   int result;
!   phys_bytes user_iovec_phys;
    message vmessage;
    int proc_nr;
    int device;
--- 90,101 ----
   * status in the vector.
   */
  
!   register struct iorequest_s *iop, *iovec;
!   /*  static struct iorequest_s iovec[NR_BUFS]; */
!   unsigned nr_requests;
!   /*  int request; */
!   int result;
!   /*  phys_bytes user_iovec_phys; */
    message vmessage;
    int proc_nr;
    int device;
***************
*** 95,100 ****
--- 103,110 ----
    nr_requests = m_ptr->COUNT;
    proc_nr = m_ptr->PROC_NR;
    device = m_ptr->DEVICE;
+   iovec = (struct iorequest_s *)m_ptr->ADDRESS;
+ #if (MACHINE != PC532)
    if (nr_requests > sizeof iovec / sizeof iovec[0])
  	panic("FS gave some driver too big an i/o vector", nr_requests);
    iovec_phys = umap(proc_ptr, D, (vir_bytes) iovec, (vir_bytes) sizeof iovec);
***************
*** 104,112 ****
  	panic("FS gave some driver bad i/o vector", (int) m_ptr->ADDRESS);
    phys_copy(user_iovec_phys, iovec_phys,
  	    (phys_bytes) nr_requests * sizeof iovec[0]);
! 
!   for (request = 0; request < nr_requests; ++request) {
! 	iop = &iovec[request];
  	vmessage.m_type = iop->io_request & ~OPTIONAL_IO;
  	vmessage.DEVICE = device;
  	vmessage.PROC_NR = proc_nr;
--- 114,124 ----
  	panic("FS gave some driver bad i/o vector", (int) m_ptr->ADDRESS);
    phys_copy(user_iovec_phys, iovec_phys,
  	    (phys_bytes) nr_requests * sizeof iovec[0]);
! #endif /* PC532 */
! 
!   for (iop = iovec; iop < iovec + nr_requests; ++iop) {
!         /*request = 0; request < nr_requests; ++request) { */
! 	/*iop = &iovec[request];*/
  	vmessage.m_type = iop->io_request & ~OPTIONAL_IO;
  	vmessage.DEVICE = device;
  	vmessage.PROC_NR = proc_nr;
***************
*** 122,128 ****
  		iop->io_nbytes -= result;
    }
  
!   phys_copy(iovec_phys, user_iovec_phys,
! 	    (phys_bytes) nr_requests * sizeof iovec[0]);
!   return(OK);
  }
--- 134,142 ----
  		iop->io_nbytes -= result;
    }
  
! #if (MACHINE != PC532)
!   phys_copy(iovec_phys, user_iovec_phys,
! 	    (phys_bytes) nr_requests * sizeof iovec[0]);
! #endif /* PC532 */
!   return(OK);
  }
*** /home/phil/min1.5ref/kernel-1.3/mpx32k.s	Wed Nov 14 00:24:49 1990
--- kernel-1.3/mpx32k.s	Fri Feb  1 12:50:57 1991
***************
*** 17,22 ****
--- 17,23 ----
  ROOT_MAJOR:	.equ	2
  ROOT_MINOR:	.equ	2
  ROOT_DEV:	.equ	(ROOT_MAJOR shl 8) or ROOT_MINOR
+ RAMIMAGEDEV:	.equ	0
  RAM_DISK_SZ:	.equ	0		; in 1024-byte blocks
  
  psr_usp:	.equ	h'200
***************
*** 32,43 ****
  
  PROC_F0:	.equ	32
  
! PROC_SP:	.equ	32+64		;added 64 for fregs
! PROC_FP:	.equ	36+64
! PROC_PC:	.equ	40+64
! PROC_MOD_PSR:	.equ	44+64
! PROC_PSR:	.equ	46+64
! PROC_PTB:	.equ	52+64
  
  TASK_CLOCK:	.equ	-3
  TASK_SCSI:	.equ	-5
--- 33,46 ----
  
  PROC_F0:	.equ	32
  
! PROC_SP:	.equ	96		;added 64 for fregs
! PROC_FP:	.equ	100
! PROC_PC:	.equ	104
! PROC_SB:	.equ	108
! PROC_MOD_PSR:	.equ	112
! PROC_PSR:	.equ	114
! PROC_FSR:	.equ	116
! PROC_PTB:	.equ	124
  
  TASK_CLOCK:	.equ	-3
  TASK_SCSI:	.equ	-5
***************
*** 68,79 ****
  	.double	_msg_log
  	.double _cur_proc
  	.double _num_free_pages	;offset=0x20
! _root_dev::			;make these easy to find
! 	.double ROOT_DEV	;offset=0x24
! _ram_disk_sz::
! 	.double RAM_DISK_SZ	;offset=0x28
! _have_rtc::
! 	.double 0		;offset=0x2c
  	;
  	; Here is where to set up environment.
  	; For now, run on int stack set up by debugger or boot
--- 71,87 ----
  	.double	_msg_log
  	.double _cur_proc
  	.double _num_free_pages	;offset=0x20
! _boot_parameters::
! _root_dev::			;make these easy to find
! 	.word ROOT_DEV		;offset=0x24
! _ramimagedev::
! 	.word RAMIMAGEDEV	;offset=0x26
! _ram_disk_sz::
! 	.word RAM_DISK_SZ	;offset=0x28
! _bpt_char_enable::
! 	.byte 0			; 0 => disabled
! _bpt_char::
! 	.byte h'1b		; this is Control-[
  	;
  	; Here is where to set up environment.
  	; For now, run on int stack set up by debugger or boot
***************
*** 374,379 ****
--- 382,388 ----
  
  	cmpqd	INIT_SLOT,_cur_proc(pc)	;save float regs
  	bge	sgu1
+ 	sfsr	PROC_FSR(r0)
  	movl	f0,PROC_F0+0*8(r0)
  	movl	f1,PROC_F0+1*8(r0)
  	movl	f2,PROC_F0+2*8(r0)
***************
*** 384,395 ****
--- 393,406 ----
  	movl	f7,PROC_F0+7*8(r0)
  sgu1:
  	addr	0(fp),PROC_FP(r0)	;save fp
+ 	addr	0(sb),PROC_SB(r0)	;save sb
  	sprd	usp,PROC_SP(r0)		;save usp
  	movd	8(sp),PROC_PC(r0)	;save pc
  	movd	12(sp),PROC_MOD_PSR(r0)	;save mod, psr
  	;
  	; Proc is saved, now handle interrupt or trap.
  	;
+ 	lprd	sb,0			;GCC expects this
  	jsr	0(4(sp))		;call isr code
  	;
  	; Now restore new proc.
***************
*** 402,407 ****
--- 413,419 ----
  sgu2:
  	cmpqd	INIT_SLOT,_cur_proc(pc)	;restore float regs
  	bge	sgu3
+ 	lfsr	PROC_FSR(r0)
  	movl	PROC_F0+0*8(r0),f0
  	movl	PROC_F0+1*8(r0),f1
  	movl	PROC_F0+2*8(r0),f2
***************
*** 414,419 ****
--- 426,432 ----
  	movd	PROC_MOD_PSR(r0),12(sp)	;restore mod, psr
  	movd	PROC_PC(r0),8(sp)	;restore pc
  	lprd	fp,PROC_FP(r0)
+ 	lprd	sb,PROC_SB(r0)
  	lprd	usp,PROC_SP(r0)		;restore usp
  	addr	0(sp),@sp_save		;save sp
  	lprd	sp,r0
