*** /home/phil/min1.5ref/mm/const.h	Wed Nov 14 00:06:30 1990
--- mm/const.h	Tue Nov 13 00:25:20 1990
***************
*** 21,27 ****
  #define MAX_PAGES       4096	/* how many pages in the virtual addr space */
  #endif
  
! #define HDR_SIZE	  32	/* # bytes in the exec file header */
  #define printf        printk
  
  #define INIT_PID	   1	/* init's process id number */
--- 21,31 ----
  #define MAX_PAGES       4096	/* how many pages in the virtual addr space */
  #endif
  
! #if (MACHINE == PC532)
! #define HDR_SIZE  (sizeof (struct exec))
! #else
! #define HDR_SIZE	  32	/* # bytes in the exec file header */
! #endif
  #define printf        printk
  
  #define INIT_PID	   1	/* init's process id number */
*** /home/phil/min1.5ref/mm/mproc.h	Wed Nov 14 00:06:30 1990
--- mm/mproc.h	Thu Nov  1 14:27:12 1990
***************
*** 25,30 ****
--- 25,33 ----
    void (*mp_func)();		/* all signals vectored to a single user fcn */
  
    unsigned mp_flags;		/* flag bits */
+ #if (MACHINE == PC532)
+   char mp_name[NAME_MAX];	/* exec name, size should be macro */
+ #endif /* PC532 */
  } mproc[NR_PROCS];
  
  /* Flag values */
*** /home/phil/min1.5ref/mm/main.c	Wed Nov 14 00:06:31 1990
--- mm/main.c	Thu Nov  1 14:27:13 1990
***************
*** 42,48 ****
    	/* Set some flags. */
  	error = OK;
  	dont_reply = FALSE;
! 	err_code = -999;
  
  	/* If the call number is valid, perform the call. */
  	if (mm_call < 0 || mm_call >= NCALLS)
--- 42,50 ----
    	/* Set some flags. */
  	error = OK;
  	dont_reply = FALSE;
! #if (MACHINE != PC532)		/* this is not ever used */
! 	err_code = -999;
! #endif /* PC532 */
  
  	/* If the call number is valid, perform the call. */
  	if (mm_call < 0 || mm_call >= NCALLS)
***************
*** 101,107 ****
  {
  /* Initialize the memory manager. */
  
!   mem_init();			/* initialize tables to all physical mem */
  
    /* Initialize MM's tables. */
    mproc[MM_PROC_NR].mp_flags |= IN_USE;
--- 103,111 ----
  {
  /* Initialize the memory manager. */
  
! #if (MACHINE != PC532)
!   mem_init();			/* initialize tables to all physical mem */
! #endif /* PC532 */
  
    /* Initialize MM's tables. */
    mproc[MM_PROC_NR].mp_flags |= IN_USE;
***************
*** 109,117 ****
--- 113,127 ----
    mproc[INIT_PROC_NR].mp_flags |= IN_USE;
    mproc[INIT_PROC_NR].mp_pid = INIT_PID;
    procs_in_use = 3;
+ #if (MACHINE == PC532)
+   strcpy (mproc[MM_PROC_NR].mp_name, "MM");
+   strcpy (mproc[FS_PROC_NR].mp_name, "FS");
+   strcpy (mproc[INIT_PROC_NR].mp_name, "INIT");
+ #endif /* PC532 */
  }
  
  
+ #if (MACHINE != PC532)
  /*===========================================================================*
   *				do_brk2	   				     *
   *===========================================================================*/
***************
*** 220,222 ****
--- 230,233 ----
    *pbase = (phys_clicks) mm_out.POSITION;
    return((phys_clicks) mm_out.COUNT);
  }
+ #endif /* PC532 */
*** /home/phil/min1.5ref/mm/signal.c	Wed Nov 14 00:06:32 1990
--- mm/signal.c	Thu Nov  1 14:27:13 1990
***************
*** 17,26 ****
  
  
  #include "mm.h"
! #include <sys/stat.h>
! #include <signal.h>
! #include <minix/callnr.h>
! #include <minix/com.h>
  #include "mproc.h"
  #include "param.h"
  
--- 17,26 ----
  
  
  #include "mm.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
! #include <sys/stat.h>
! #include <signal.h>
  #include "mproc.h"
  #include "param.h"
  
***************
*** 112,119 ****
    mp->mp_procgrp = rmp->mp_procgrp;	/* get process group right */
  
    /* Stack faults are passed from kernel to MM as pseudo-signal 16. */
!   if (sig_map == 1 << (SIGSTKFLT - 1))
! 	stack_fault(proc_nr);
  
    /* Check each bit in turn to see if a signal is to be sent.  Unlike
     * kill(), the kernel may collect several unrelated signals for a process
--- 112,121 ----
    mp->mp_procgrp = rmp->mp_procgrp;	/* get process group right */
  
    /* Stack faults are passed from kernel to MM as pseudo-signal 16. */
! #if (MACHINE != PC532)
!   if (sig_map == 1 << (SIGSTKFLT - 1))
! 	stack_fault(proc_nr);
! #endif /* PC532 */
  
    /* Check each bit in turn to see if a signal is to be sent.  Unlike
     * kill(), the kernel may collect several unrelated signals for a process
***************
*** 162,172 ****
     */
    for (rmp = &mproc[INIT_PROC_NR]; rmp < &mproc[NR_PROCS]; rmp++ ) {
  	if ( (rmp->mp_flags & IN_USE) == 0) continue;
! 	send_sig = TRUE;	/* if it's FALSE at end of loop, don't signal*/
  	if (send_uid != rmp->mp_effuid && send_uid != SUPER_USER)send_sig=FALSE;
  	if (proc_id > 0 && proc_id != rmp->mp_pid) send_sig = FALSE;
  	if (rmp->mp_flags & HANGING) send_sig = FALSE;   /*don't wake the dead*/
! 	if (proc_id == 0 && mp->mp_procgrp != rmp->mp_procgrp)send_sig = FALSE;
  	if (send_uid == SUPER_USER && proc_id == -1) send_sig = TRUE;
  	if (rmp->mp_pid == INIT_PID && proc_id == -1) send_sig = FALSE;
  	if (rmp->mp_pid == INIT_PID && sig_nr == SIGKILL) send_sig = FALSE;
--- 164,174 ----
     */
    for (rmp = &mproc[INIT_PROC_NR]; rmp < &mproc[NR_PROCS]; rmp++ ) {
  	if ( (rmp->mp_flags & IN_USE) == 0) continue;
! 	send_sig = TRUE;	/* if it's FALSE at end of loop, don't signal */
  	if (send_uid != rmp->mp_effuid && send_uid != SUPER_USER)send_sig=FALSE;
  	if (proc_id > 0 && proc_id != rmp->mp_pid) send_sig = FALSE;
  	if (rmp->mp_flags & HANGING) send_sig = FALSE;   /*don't wake the dead*/
! 	if (proc_id == 0 && mp->mp_procgrp != rmp->mp_procgrp) send_sig = FALSE;
  	if (send_uid == SUPER_USER && proc_id == -1) send_sig = TRUE;
  	if (rmp->mp_pid == INIT_PID && proc_id == -1) send_sig = FALSE;
  	if (rmp->mp_pid == INIT_PID && sig_nr == SIGKILL) send_sig = FALSE;
***************
*** 184,190 ****
  	count++;
  	if (rmp->mp_ignore & mask) continue;
  
! #if AM_KERNEL
  	/* see if an amoeba transaction should be signalled */
  	Tfs = am_check_sig((int)(rmp - mproc), 0);
  #endif
--- 186,192 ----
  	count++;
  	if (rmp->mp_ignore & mask) continue;
  
! #ifdef AM_KERNEL
  	/* see if an amoeba transaction should be signalled */
  	Tfs = am_check_sig((int)(rmp - mproc), 0);
  #endif
***************
*** 198,204 ****
    }
  
    /* If the calling process has killed itself, don't reply. */
!   if ((mp->mp_flags & IN_USE) == 0 || (mp->mp_flags & HANGING))dont_reply=TRUE;
    return(count > 0 ? OK : ESRCH);
  }
  
--- 200,206 ----
    }
  
    /* If the calling process has killed itself, don't reply. */
!   if ((mp->mp_flags & IN_USE) == 0 || (mp->mp_flags & HANGING))dont_reply =TRUE;
    return(count > 0 ? OK : ESRCH);
  }
  
***************
*** 230,241 ****
    if (rmp->mp_catch & mask) {
  	/* Signal should be caught. */
  	rmp->mp_catch &= ~mask;		/* disable further signals */
! 	sys_getsp((int)(rmp - mproc), &new_sp);
! 	new_sp -= SIG_PUSH_BYTES;
! 	if (adjust(rmp, rmp->mp_seg[D].mem_len, new_sp) == OK) {
! 		sys_sig((int)(rmp - mproc), sig_nr, rmp->mp_func);
! 		return;		/* successful signal */
! 	}
    }
  
    /* Signal should not or cannot be caught.  Take default action. */
--- 232,239 ----
    if (rmp->mp_catch & mask) {
  	/* Signal should be caught. */
  	rmp->mp_catch &= ~mask;		/* disable further signals */
! 	sys_sig((int)(rmp - mproc), sig_nr, rmp->mp_func);
! 	return;
    }
  
    /* Signal should not or cannot be caught.  Take default action. */
***************
*** 345,350 ****
--- 343,357 ----
  }
  
  
+ #define real_time time_t
+ #define NR_REGS	8			/* yucky kludge -- fix this */
+ #define NR_FREGS 8
+ #define NQ 3
+ #if (MACHINE == PC532)			/* for core dumps */
+ #  include "../kernel-1.3/proc.h"
+ #  include <minix/mmu.h>		/* for PAGESZ */
+ #endif /* PC532 */
+ 
  /*===========================================================================*
   *				dump_core				     *
   *===========================================================================*/
***************
*** 352,366 ****
  register struct mproc *rmp;	/* whose core is to be dumped */
  {
  /* Make a core dump on the file "core", if possible. */
! 
!   struct stat s_buf, d_buf;
!   char buf[DUMP_SIZE];
!   int i, r, s, er1, er2, slot;
!   vir_bytes v_buf;
!   long a, c, ct, dest;
!   struct mproc *xmp;
!   long trace_data;
!   int trace_off;
  
    /* Change to working directory of dumpee. */
    slot = (int)(rmp - mproc);
--- 359,375 ----
  register struct mproc *rmp;	/* whose core is to be dumped */
  {
  /* Make a core dump on the file "core", if possible. */
! /* This code violates the spirit of MM being a user process because it
!  * peeks at the kernel proc table.  This is naughty!
!  */
!   struct stat s_buf, d_buf;
!   int r, s, slot;
!   struct mproc *xmp;
!   struct proc *kp;
!   extern char core_name[];
!   struct {
!     long dlen, slen;
!   } lengths;
  
    /* Change to working directory of dumpee. */
    slot = (int)(rmp - mproc);
***************
*** 371,377 ****
  	tell_fs(CHDIR, 0, 1, 0);	/* go back to MM's directory */
  	return;
    }
!   xmp = mp;			/* allowed() looks at 'mp' */
    mp = rmp;
    r = allowed(core_name, &s_buf, W_BIT);	/* is core_file writable */
    s = allowed(".", &d_buf, W_BIT);	/* is directory writable? */
--- 380,386 ----
  	tell_fs(CHDIR, 0, 1, 0);	/* go back to MM's directory */
  	return;
    }
!   xmp = mp;					/* allowed() looks at 'mp' */
    mp = rmp;
    r = allowed(core_name, &s_buf, W_BIT);	/* is core_file writable */
    s = allowed(".", &d_buf, W_BIT);	/* is directory writable? */
***************
*** 387,430 ****
  	if (r < 0) return;
  	rmp->mp_sigstatus |= DUMPED;
  
! 	/* First write the memory map of all segments on core file. */
! 	if (write(r, (char *) rmp->mp_seg, (int)sizeof(rmp->mp_seg)) < 0) {
  		close(r);
  		return;
  	}
! 
! 	/* Write out the whole kernel process table entry to get the regs. */
! 	trace_off = 0;
! 	while (sys_trace(3, slot, (long)trace_off, (long)&trace_data) == OK) { 
! 		write(r, (char *) &trace_data, (unsigned) sizeof(long));
!  		trace_off += sizeof(long);
! 	}
! 
! 	/* Now loop through segments and write the segments themselves out. */
! 	v_buf = (vir_bytes) buf;
! 	dest = (long) v_buf;
! 	for (i = 0; i < NR_SEGS; i++) {
! 		a = (phys_bytes) rmp->mp_seg[i].mem_vir << CLICK_SHIFT;
! 		c = (phys_bytes) rmp->mp_seg[i].mem_len << CLICK_SHIFT;
! 
! 		/* Loop through a segment, dumping it. */
! 		while (c > 0) {
! 			ct = MIN(c, DUMP_SIZE);
! 			er1 = mem_copy(slot, i, a, MM_PROC_NR, D, dest, ct);
! 			er2 = write(r, buf, (int) ct);
! 			if (er1 < 0 || er2 < 0) {
! 				close(r);
! 				return;
! 			}
! 			a += ct;
! 			c -= ct;
! 		}
  	}
    } else {
  	tell_fs(CHDIR, 0, 1, 0);	/* go back to MM's own dir */
  	close(r);
  	return;
    }
! 
!   close(r);
  }
--- 396,433 ----
  	if (r < 0) return;
  	rmp->mp_sigstatus |= DUMPED;
  
! 	/* dump registers */
! 	kp = &proc [slot + NR_TASKS];
! 	s = (char *) (&kp->p_flags) - (char *) kp;
! 	if (write(r, (char *) kp, s) < 0) {
  		close(r);
  		return;
  	}
! 	
! 	/* dump data and stack segment lengths */
! 	lengths.dlen = kp->p_map.dlen * PAGESZ;
! 	lengths.slen = kp->p_map.slen * PAGESZ;
! 	if (write(r, (char *) &lengths, sizeof(lengths)) < 0) {
! 		close(r);
! 		return;
! 	}
! 
! 	/* dump data and stack segments */
! 	s = r | (slot << 8);		/* tell FS to use user space */
! 	if (write(s, (char *) (kp->p_map.tlen * PAGESZ), lengths.dlen) < 0) {
! 		close(r);
! 		return;
! 	}
! 	if (write(s, (char *) (TOP_VADDR + 1 - lengths.slen),
! 	  lengths.slen) < 0) 
! 	{
! 		close(r);
! 		return;
  	}
    } else {
  	tell_fs(CHDIR, 0, 1, 0);	/* go back to MM's own dir */
  	close(r);
  	return;
    }
!   close(r);
  }
*** /home/phil/min1.5ref/mm/table.c	Wed Nov 14 00:06:32 1990
--- mm/table.c	Thu Nov  1 14:27:13 1990
***************
*** 13,19 ****
  char core_name[] = "core";	/* file name where core images are produced */
  unshort core_bits = 0x0EFC;	/* which signals cause core images */
  
! char *stackpt = &mm_stack[MM_STACK_BYTES];	/* initial stack pointer */
  
  int (*call_vec[NCALLS])() = {
  	no_sys,		/*  0 = unused	*/
--- 13,21 ----
  char core_name[] = "core";	/* file name where core images are produced */
  unshort core_bits = 0x0EFC;	/* which signals cause core images */
  
! #if (MACHINE != PC532)
! char *stackpt = &mm_stack[MM_STACK_BYTES];	/* initial stack pointer */
! #endif /* PC532 */
  
  int (*call_vec[NCALLS])() = {
  	no_sys,		/*  0 = unused	*/
***************
*** 83,89 ****
  
  	do_ksig,	/* 64 = KSIG: signals originating in the kernel	*/
  	no_sys,		/* 65 = UNPAUSE	*/
! 	do_brk2, 	/* 66 = BRK2 (used to tell MM size of FS,INIT) */
  	no_sys,		/* 67 = REVIVE	*/
  	no_sys,		/* 68 = TASK_REPLY	*/
  #if (CHIP == INTEL)
--- 85,95 ----
  
  	do_ksig,	/* 64 = KSIG: signals originating in the kernel	*/
  	no_sys,		/* 65 = UNPAUSE	*/
! #if (MACHINE == PC532)
! 	no_sys, 	/* 66 = BRK2 (used to tell MM size of FS,INIT) */
! #else
! 	do_brk2, 	/* 66 = BRK2 (used to tell MM size of FS,INIT) */
! #endif /* PC532 */
  	no_sys,		/* 67 = REVIVE	*/
  	no_sys,		/* 68 = TASK_REPLY	*/
  #if (CHIP == INTEL)
*** /home/phil/min1.5ref/mm/utility.c	Wed Nov 14 00:06:32 1990
--- mm/utility.c	Thu Nov  1 14:27:13 1990
***************
*** 13,19 ****
  #include <minix/com.h>
  #include "mproc.h"
  
! PRIVATE message copy_mess;
  
  /*===========================================================================*
   *				allowed					     *
--- 13,21 ----
  #include <minix/com.h>
  #include "mproc.h"
  
! #if (MACHINE != PC532)
! PRIVATE message copy_mess;
! #endif /* PC532 */
  
  /*===========================================================================*
   *				allowed					     *
***************
*** 58,64 ****
    }
  }
  
! 
  /*===========================================================================*
   *				mem_copy				     *
   *===========================================================================*/
--- 60,66 ----
    }
  }
  
! #if (MACHINE != PC532)
  /*===========================================================================*
   *				mem_copy				     *
   *===========================================================================*/
***************
*** 89,94 ****
--- 91,97 ----
    sys_copy(&copy_mess);
    return(copy_mess.m_type);
  }
+ 
  /*===========================================================================*
   *				no_sys					     *
   *===========================================================================*/
***************
*** 98,104 ****
  
    return(EINVAL);
  }
! 
  
  /*===========================================================================*
   *				panic					     *
--- 101,107 ----
  
    return(EINVAL);
  }
! #endif /* PC532 */
  
  /*===========================================================================*
   *				panic					     *
*** /home/phil/min1.5ref/mm/proto.h	Wed Nov 14 00:06:32 1990
--- mm/proto.h	Thu Nov  1 14:27:13 1990
***************
*** 1,11 ****
--- 1,13 ----
  /* Function prototypes. */
  
+ #if (MACHINE != PC532)
  /* alloc.c */
  extern phys_clicks alloc_mem();
  extern void free_mem();
  extern phys_clicks max_hole();
  extern void mem_init();
  extern phys_clicks mem_left();
+ #endif /* PC532 */
  
  /* amoeba.c */
  #if AM_KERNEL
***************
*** 32,38 ****
  
  /* main.c */
  extern int do_brk2();
! extern phys_clicks get_mem();
  #if (MACHINE == MACINTOSH)
  extern phys_clicks start_click();
  #endif
--- 34,42 ----
  
  /* main.c */
  extern int do_brk2();
! #if (MACHINE != PC532)
! extern phys_clicks get_mem();
! #endif /* PC532 */
  #if (MACHINE == MACINTOSH)
  extern phys_clicks start_click();
  #endif
***************
*** 75,84 ****
  extern void sys_abort();
  extern void sys_copy();
  extern void sys_exec();
! extern void sys_fork();
! extern void sys_getsp();
! extern void sys_newmap();
! extern void sys_sig();
  extern int sys_trace();
  extern void sys_xit();
  extern void tell_fs();
--- 79,97 ----
  extern void sys_abort();
  extern void sys_copy();
  extern void sys_exec();
! #if (MACHINE == PC532)
! extern int sys_fork();
! #else
! extern void sys_fork();
! #endif /* PC532 */
! extern void sys_getsp();
! #if (MACHINE == PC532)
! extern int sys_newmap();
! extern int sys_sig();
! #else
! extern void sys_newmap();
! extern void sys_sig();
! #endif /* PC532 */
  extern int sys_trace();
  extern void sys_xit();
  extern void tell_fs();
*** /home/phil/min1.5ref/mm/mm.h	Wed Nov 14 00:06:32 1990
--- mm/mm.h	Thu Nov  1 14:27:13 1990
***************
*** 7,12 ****
--- 7,27 ----
  
  /* The following are so basic, all the *.c files get them automatically. */
  #include <minix/config.h>	/* MUST be first */
+ 
+ #if (MACHINE == PC532)
+ /* so mm can be linked with fs and kernel */
+ #define do_exec		mm_do_exec
+ #define	do_fork		mm_do_fork
+ #define	do_kill		mm_do_kill
+ #define	dont_reply	mm_dont_reply
+ #define	get_work	mm_get_work
+ #define	main		mm_main
+ #define	panic		mm_panic
+ #define	reply		mm_reply
+ #define	who		mm_who
+ #define printf		printk
+ #endif /* PC532 */
+ 
  #include <minix/const.h>
  #include <minix/type.h>
  
***************
*** 19,21 ****
--- 34,40 ----
  #include "proto.h"
  #include "glo.h"
  
+ #if (MACHINE == PC532)
+ #undef PRIVATE
+ #define PRIVATE				/* put symbols in a.out for debugging */
+ #endif /* PC532 */
