home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~1.z / update~1 / gkernel / kernel / kernel.diff
Encoding:
Text File  |  1989-08-24  |  26.7 KB  |  988 lines

  1. *** /tmp/,RCSt1a27031    Thu Aug 24 00:01:21 1989
  2. --- proc.c    Thu Aug 17 17:29:27 1989
  3. ***************
  4. *** 24,29 ****
  5. --- 24,33 ----
  6.   #include "proc.h"
  7.   #include "k_proto.h"
  8.   
  9. + #ifdef ATARI_ST
  10. + unsigned long busy_map = 0L;
  11. + #endif
  12.   static int mini_rec(int, struct proc *, int, message *);
  13.   static void cp_mess(int, struct proc *, message *, struct proc *, message *); 
  14.   
  15. ***************
  16. *** 46,52 ****
  17.   message *m_ptr;            /* interrupt message to send to the task */
  18.   {
  19.   /* An interrupt has occurred.  Schedule the task that handles it. */
  20.   
  21.   #ifdef i8088
  22.     /* Re-enable the 8259A interrupt controller. */
  23. --- 50,59 ----
  24.   message *m_ptr;            /* interrupt message to send to the task */
  25.   {
  26.   /* An interrupt has occurred.  Schedule the task that handles it. */
  27. ! #if 1
  28. !   int i, n;
  29. !   unsigned long old_map, this_bit;
  30. ! #endif
  31.   
  32.   #ifdef i8088
  33.     /* Re-enable the 8259A interrupt controller. */
  34. ***************
  35. *** 56,63 ****
  36. --- 63,101 ----
  37.         port_out(INT2_CTL, ENABLE);
  38.   #endif
  39.   
  40. + #if 0
  41.     /* Try to send the interrupt message to the indicated task. */
  42.     mini_send(HARDWARE, proc_addr(HARDWARE), task, m_ptr);
  43. + #else
  44. +   /* Try to send the interrupt message to the indicated task. */
  45. +   this_bit = 1 << (-task);
  46. +   if (mini_send(HARDWARE, proc_addr(HARDWARE), task, m_ptr) != OK) {
  47. +     /* The message could not be sent to the task; it was not waiting. */
  48. +     old_map = busy_map;    /* save original map of busy tasks */
  49. +     if (task == CLOCK) {
  50. +         lost_ticks++;
  51. +     } else {
  52. +         busy_map |= this_bit;        /* mark task as busy */
  53. +         task_mess[-task] = m_ptr;    /* record message pointer */
  54. +     }
  55. +   } else {
  56. +     /* Hardware interrupt was successfully sent as a message. */
  57. +     busy_map &= ~this_bit;    /* turn off the bit in case it was on */
  58. +     old_map = busy_map;
  59. +   }
  60. +   /* See if any tasks that were previously busy are now listening for msgs. */
  61. +   if (old_map != 0) {
  62. +     for (i = 2, this_bit = 4; i <= NR_TASKS; this_bit <<= 1, i++) {
  63. +         /* Check each task looking for one with a pending interrupt. */
  64. +         if ( old_map & this_bit ) {
  65. +             /* Task 'i' has a pending interrupt. */
  66. +             n = mini_send(HARDWARE, proc_addr(HARDWARE), -i, task_mess[i]);
  67. +             if (n == OK) busy_map &= ~this_bit;
  68. +         }
  69. +     }
  70. +   }
  71. + #endif
  72.   
  73.   #ifndef ATARI_ST
  74.     /* If a task has just been readied and a user is running, run the task. */
  75. ***************
  76. *** 103,109 ****
  77.     }
  78.   
  79.     if (function & RECEIVE) {
  80. !     n = mini_rec(caller,  rp, src_dest, m_ptr);  /* func = RECEIVE or BOTH */
  81.       rp->p_reg[RET_REG] = n;
  82.     }
  83.   }
  84. --- 141,147 ----
  85.     }
  86.   
  87.     if (function & RECEIVE) {
  88. !     n = mini_rec(caller, rp, src_dest, m_ptr);  /* func = RECEIVE or BOTH */
  89.       rp->p_reg[RET_REG] = n;
  90.     }
  91.   }
  92. ***************
  93. *** 127,133 ****
  94.     vir_clicks vlo, vhi;        /* virtual clicks containing message to send */
  95.     vir_clicks len;        /* length of data segment in clicks */
  96.     int s;
  97.     /* User processes are only allowed to send to FS and MM.  Check for this. */
  98.     if (caller >= LOW_USER && (dest != FS_PROC_NR && dest != MM_PROC_NR))
  99.       return(E_BAD_DEST);
  100. --- 165,171 ----
  101.     vir_clicks vlo, vhi;        /* virtual clicks containing message to send */
  102.     vir_clicks len;        /* length of data segment in clicks */
  103.     int s;
  104. !   
  105.     /* User processes are only allowed to send to FS and MM.  Check for this. */
  106.     if (caller >= LOW_USER && (dest != FS_PROC_NR && dest != MM_PROC_NR))
  107.       return(E_BAD_DEST);
  108. ***************
  109. *** 152,183 ****
  110.     }
  111.   
  112.     /* Check to see if 'dest' is blocked waiting for this message. */
  113. !   s = lock();
  114. !   if ( (dest_ptr->p_flags & RECEIVING) &&
  115. !         (dest_ptr->p_flags & SENDING) == 0 &&
  116. !         (dest_ptr->p_getfrom == ANY || dest_ptr->p_getfrom == caller) ) {
  117.       /* Destination is indeed waiting for this message. */
  118.       CopyMess(caller, caller_ptr, m_ptr, dest_ptr, dest_ptr->p_messbuf);
  119.       dest_ptr->p_flags &= ~RECEIVING;    /* deblock destination */
  120. -      restore(s);
  121.       if (dest_ptr->p_flags == 0) ready(dest_ptr);
  122.     } else {
  123.       /* Destination is not waiting.  Block and queue caller. */
  124. !     if (caller == HARDWARE) {
  125. !         restore(s);
  126. !         if (dest == CLOCK)
  127. !             lost_ticks++;
  128. ! #ifdef NEEDED
  129. !         else if (task_mess[-dest])
  130. !             printf("interrupt for task %d lost\n", dest);
  131. ! #endif
  132. !         else
  133. !             task_mess[-dest] = m_ptr;    /* record message pointer */
  134. !         return(E_OVERRUN);
  135. !     }
  136.       caller_ptr->p_messbuf = m_ptr;
  137. !     if (caller_ptr->p_flags == 0)
  138. !         unready(caller_ptr);
  139.       caller_ptr->p_flags |= SENDING;
  140.   
  141.       /* Process is now blocked.  Put in on the destination's queue. */
  142. --- 190,211 ----
  143.     }
  144.   
  145.     /* Check to see if 'dest' is blocked waiting for this message. */
  146. ! /*   s = lock(); */
  147. !   if ( (dest_ptr->p_flags & RECEIVING) && (dest_ptr->p_flags & SENDING) == 0 &&
  148. !         (dest_ptr->p_getfrom == ANY || dest_ptr->p_getfrom == caller)){
  149.       /* Destination is indeed waiting for this message. */
  150.       CopyMess(caller, caller_ptr, m_ptr, dest_ptr, dest_ptr->p_messbuf);
  151.       dest_ptr->p_flags &= ~RECEIVING;    /* deblock destination */
  152.       if (dest_ptr->p_flags == 0) ready(dest_ptr);
  153.     } else {
  154.       /* Destination is not waiting.  Block and queue caller. */
  155. !       if (caller == HARDWARE)
  156. !       {
  157. !       /* restore(s); */
  158. !       return(E_OVERRUN);
  159. !       }
  160.       caller_ptr->p_messbuf = m_ptr;
  161. !     if (caller_ptr->p_flags == 0) unready(caller_ptr);
  162.       caller_ptr->p_flags |= SENDING;
  163.   
  164.       /* Process is now blocked.  Put in on the destination's queue. */
  165. ***************
  166. *** 189,195 ****
  167.           next_ptr->p_sendlink = caller_ptr;
  168.       }
  169.       caller_ptr->p_sendlink = NIL_PROC;
  170. !     restore(s);
  171.     }
  172.     return(OK);
  173.   }
  174. --- 217,223 ----
  175.           next_ptr->p_sendlink = caller_ptr;
  176.       }
  177.       caller_ptr->p_sendlink = NIL_PROC;
  178. ! /*        restore(s); */
  179.     }
  180.     return(OK);
  181.   }
  182. ***************
  183. *** 211,231 ****
  184.    * Calls from the tasks, MM, and FS are trusted.
  185.    */
  186.   
  187. !   register struct proc *sender_ptr, *prev_ptr;
  188.     int sender;
  189.     if ((caller_ptr->p_flags & SENDING) == 0) {
  190. !      if (caller < 0 && task_mess[-caller]) {
  191.       /* we have a HARDWARE message waiting */
  192.       if (src == ANY || src == HARDWARE) {
  193.           sender_ptr = proc_addr(HARDWARE);
  194.           CopyMess(HARDWARE, sender_ptr, task_mess[-caller],
  195.                       caller_ptr, m_ptr);
  196. !         task_mess[-caller] = 0;
  197.           return(OK);
  198.       }
  199.        }
  200. !      /* Check to see if a message from desired source is already available. */
  201.        sender_ptr = caller_ptr->p_callerq;
  202.        while (sender_ptr != NIL_PROC) {
  203.       sender = (sender_ptr - proc) - NR_TASKS;
  204. --- 239,261 ----
  205.    * Calls from the tasks, MM, and FS are trusted.
  206.    */
  207.   
  208. !   register struct proc *sender_ptr, *previous_ptr;
  209.     int sender;
  210. !   unsigned long this_bit;
  211. !   
  212. !   /* Check to see if a message from desired source is already available. */
  213.     if ((caller_ptr->p_flags & SENDING) == 0) {
  214. !      if (caller < 0 && (busy_map & (this_bit = (1L << (-caller))))) {
  215.       /* we have a HARDWARE message waiting */
  216.       if (src == ANY || src == HARDWARE) {
  217.           sender_ptr = proc_addr(HARDWARE);
  218.           CopyMess(HARDWARE, sender_ptr, task_mess[-caller],
  219.                       caller_ptr, m_ptr);
  220. !         busy_map &= ~this_bit;
  221.           return(OK);
  222.       }
  223.        }
  224. !      /* not a hardware message, but one is avail */
  225.        sender_ptr = caller_ptr->p_callerq;
  226.        while (sender_ptr != NIL_PROC) {
  227.       sender = (sender_ptr - proc) - NR_TASKS;
  228. ***************
  229. *** 232,247 ****
  230.       if (src == ANY || src == sender) {
  231.           /* An acceptable message has been found. */
  232.           CopyMess(sender, sender_ptr, sender_ptr->p_messbuf,
  233. !                     caller_ptr, m_ptr);
  234.           sender_ptr->p_flags &= ~SENDING;    /* deblock sender */
  235.           if (sender_ptr->p_flags == 0) ready(sender_ptr);
  236.           if (sender_ptr == caller_ptr->p_callerq)
  237.               caller_ptr->p_callerq = sender_ptr->p_sendlink;
  238.           else
  239. !             prev_ptr->p_sendlink = sender_ptr->p_sendlink;
  240.           return(OK);
  241.       }
  242. !     prev_ptr = sender_ptr;
  243.       sender_ptr = sender_ptr->p_sendlink;
  244.        }
  245.     }
  246. --- 262,277 ----
  247.       if (src == ANY || src == sender) {
  248.           /* An acceptable message has been found. */
  249.           CopyMess(sender, sender_ptr, sender_ptr->p_messbuf,
  250. !                  caller_ptr, m_ptr);
  251.           sender_ptr->p_flags &= ~SENDING;    /* deblock sender */
  252.           if (sender_ptr->p_flags == 0) ready(sender_ptr);
  253.           if (sender_ptr == caller_ptr->p_callerq)
  254.               caller_ptr->p_callerq = sender_ptr->p_sendlink;
  255.           else
  256. !             previous_ptr->p_sendlink = sender_ptr->p_sendlink;
  257.           return(OK);
  258.       }
  259. !     previous_ptr = sender_ptr;
  260.       sender_ptr = sender_ptr->p_sendlink;
  261.        }
  262.     }
  263. ***************
  264. *** 249,265 ****
  265.     /* No suitable message is available.  Block the process trying to receive. */
  266.     caller_ptr->p_getfrom = src;
  267.     caller_ptr->p_messbuf = m_ptr;
  268. !   if (caller_ptr->p_flags == 0)
  269. !     unready(caller_ptr);
  270.     caller_ptr->p_flags |= RECEIVING;
  271.   
  272.     /* If MM has just blocked and there are kernel signals pending, now is the
  273.      * time to tell MM about them, since it will be able to accept the message.
  274.      */
  275. !   if (sig_procs > 0 && caller == MM_PROC_NR && src == ANY) 
  276. !   {
  277. !       inform();
  278. !       pick_proc();
  279.     }
  280.     return(OK);
  281.   }
  282. --- 279,293 ----
  283.     /* No suitable message is available.  Block the process trying to receive. */
  284.     caller_ptr->p_getfrom = src;
  285.     caller_ptr->p_messbuf = m_ptr;
  286. !   if (caller_ptr->p_flags == 0) unready(caller_ptr);
  287.     caller_ptr->p_flags |= RECEIVING;
  288.   
  289.     /* If MM has just blocked and there are kernel signals pending, now is the
  290.      * time to tell MM about them, since it will be able to accept the message.
  291.      */
  292. !   if (sig_procs > 0 && caller == MM_PROC_NR && src == ANY) {
  293. !     inform();
  294. !     pick_proc();
  295.     }
  296.     return(OK);
  297.   }
  298. ***************
  299. *** 315,335 ****
  300.    */
  301.   
  302.     register int q;        /* TASK_Q, SERVER_Q, or USER_Q */
  303. !   register int s;
  304. !   s = lock();            /* disable interrupts */
  305. !   DEBUG(if (rp->p_flags != 0)
  306. !     panic("ready with flags. proc =", (rp-proc)-NR_TASKS);
  307. !   );
  308. !   DEBUG({ register struct proc *xp;
  309. !     for (q = 0; q < NQ; q++)
  310. !         for (xp = rdy_head[q]; xp != NIL_PROC; xp = xp->p_nextready)
  311. !             if (xp == rp)
  312. !                 panic("ready, but already ready. proc =",
  313. !                     (rp-proc)-NR_TASKS);
  314. !   });
  315.   
  316.     if (rp < &proc[NR_TASKS])
  317.       q = TASK_Q;
  318.     else if (rp < &proc[NR_TASKS+LOW_USER])
  319. --- 343,351 ----
  320.    */
  321.   
  322.     register int q;        /* TASK_Q, SERVER_Q, or USER_Q */
  323. !   int  old_state;
  324.   
  325. +   old_state = lock();        /* disable interrupts */
  326.     if (rp < &proc[NR_TASKS])
  327.       q = TASK_Q;
  328.     else if (rp < &proc[NR_TASKS+LOW_USER])
  329. ***************
  330. *** 348,354 ****
  331.       rdy_tail[q]->p_nextready = rp;    /* add to tail of nonempty queue */
  332.     rdy_tail[q] = rp;        /* new entry has no successor */
  333.     rp->p_nextready = NIL_PROC;
  334. !   restore(s);            /* restore interrupts to previous state */
  335.   }
  336.   
  337.   
  338. --- 364,370 ----
  339.       rdy_tail[q]->p_nextready = rp;    /* add to tail of nonempty queue */
  340.     rdy_tail[q] = rp;        /* new entry has no successor */
  341.     rp->p_nextready = NIL_PROC;
  342. !   restore(old_state);        /* restore interrupts to previous state */
  343.   }
  344.   
  345.   
  346. ***************
  347. *** 361,374 ****
  348.   /* A process has blocked. */
  349.   
  350.     register struct proc *xp;
  351. !   int q, s;
  352.   
  353. !   s = lock();            /* disable interrupts */
  354.   
  355. -   DEBUG(if (rp->p_flags != 0)
  356. -     panic("unready with flags. proc =", (rp-proc)-NR_TASKS);
  357. -   );
  358.     if (rp < &proc[NR_TASKS])
  359.       q = TASK_Q;
  360.     else if (rp < &proc[NR_TASKS+LOW_USER])
  361. --- 377,386 ----
  362.   /* A process has blocked. */
  363.   
  364.     register struct proc *xp;
  365. !   int q, old_state;
  366.   
  367. !   old_state = lock();            /* disable interrupts */
  368.   
  369.     if (rp < &proc[NR_TASKS])
  370.       q = TASK_Q;
  371.     else if (rp < &proc[NR_TASKS+LOW_USER])
  372. ***************
  373. *** 381,396 ****
  374.       q = USER_Q;
  375.   
  376.     if ( (xp = rdy_head[q]) == NIL_PROC) {
  377. !     restore(s);
  378.       return;
  379.     }
  380.     if (xp == rp) {
  381.       /* Remove head of queue */
  382.       rdy_head[q] = xp->p_nextready;
  383. ! #ifdef ATARI_ST
  384. !     if (rp == proc_ptr)
  385. ! #endif
  386. !         pick_proc();
  387.     } else {
  388.       /* Search body of queue.  A process can be made unready even if it is
  389.        * not running by being sent a signal that kills it.
  390. --- 393,405 ----
  391.       q = USER_Q;
  392.   
  393.     if ( (xp = rdy_head[q]) == NIL_PROC) {
  394. !     restore(old_state);
  395.       return;
  396.     }
  397.     if (xp == rp) {
  398.       /* Remove head of queue */
  399.       rdy_head[q] = xp->p_nextready;
  400. !     if (rp == proc_ptr) pick_proc();
  401.     } else {
  402.       /* Search body of queue.  A process can be made unready even if it is
  403.        * not running by being sent a signal that kills it.
  404. ***************
  405. *** 397,405 ****
  406.        */
  407.       while (xp->p_nextready != rp)
  408.           if ( (xp = xp->p_nextready) == NIL_PROC) {
  409. !             DEBUG(panic("unready, but not ready, proc =",
  410. !                 (rp-proc)-NR_TASKS));
  411. !             restore(s);
  412.               return;
  413.           }
  414.       xp->p_nextready = xp->p_nextready->p_nextready;
  415. --- 406,412 ----
  416.        */
  417.       while (xp->p_nextready != rp)
  418.           if ( (xp = xp->p_nextready) == NIL_PROC) {
  419. !             restore(old_state);
  420.               return;
  421.           }
  422.       xp->p_nextready = xp->p_nextready->p_nextready;
  423. ***************
  424. *** 406,412 ****
  425.       while (xp->p_nextready != NIL_PROC) xp = xp->p_nextready;
  426.       rdy_tail[q] = xp;
  427.     }
  428. !   restore(s);            /* restore interrupts to previous state */
  429.   }
  430.   
  431.   
  432. --- 413,419 ----
  433.       while (xp->p_nextready != NIL_PROC) xp = xp->p_nextready;
  434.       rdy_tail[q] = xp;
  435.     }
  436. !   restore(old_state);            /* restore interrupts to prev state */
  437.   }
  438.   
  439.   
  440. ***************
  441. *** 420,430 ****
  442.    * possibly promoting another user to head of the queue.
  443.    */
  444.   
  445. !   register int s;
  446.   
  447. !   s = lock();            /* disable interrupts */
  448.     if (rdy_head[USER_Q] == NIL_PROC) {
  449. !     restore(s);        /* restore interrupts to previous state */
  450.       return;
  451.     }
  452.   
  453. --- 427,437 ----
  454.    * possibly promoting another user to head of the queue.
  455.    */
  456.   
  457. !   int old_state;
  458.   
  459. !   old_state = lock();            /* disable interrupts */
  460.     if (rdy_head[USER_Q] == NIL_PROC) {
  461. !     restore(old_state);        /* restore interrupts to prev state */
  462.       return;
  463.     }
  464.   
  465. ***************
  466. *** 434,440 ****
  467.     rdy_head[USER_Q] = rdy_head[USER_Q]->p_nextready;
  468.     rdy_tail[USER_Q]->p_nextready = NIL_PROC;
  469.     pick_proc();
  470. !   restore(s);            /* restore interrupts to previous state */
  471.   }
  472.   
  473.   #ifdef ATARI_ST
  474. --- 441,447 ----
  475.     rdy_head[USER_Q] = rdy_head[USER_Q]->p_nextready;
  476.     rdy_tail[USER_Q]->p_nextready = NIL_PROC;
  477.     pick_proc();
  478. !   restore(old_state);            /* restore interrupts to prev state */
  479.   }
  480.   
  481.   #ifdef ATARI_ST
  482. *** /tmp/,RCSt1a27031    Thu Aug 24 00:02:07 1989
  483. --- stvdu.c    Thu Aug 17 17:56:05 1989
  484. ***************
  485. *** 74,89 ****
  486.   {
  487.     if (tp->tty_outleft == 0)
  488.       return(1);
  489.     vducursor(0);
  490.     do {
  491. !     if (tp->tty_inhibited == TRUE) {
  492. !         vducursor(1);
  493. !         return(0);
  494. !     }
  495. !     vduput(*((char *)tp->tty_phys));
  496.                   /* write 1 byte to terminal */
  497. !     tp->tty_phys++;        /* advance physical data pointer */
  498. !     tp->tty_cum++;        /* number of characters printed */
  499.     } while (--tp->tty_outleft != 0);
  500.     vducursor(1);
  501.     return(1);
  502. --- 74,93 ----
  503.   {
  504.     if (tp->tty_outleft == 0)
  505.       return(1);
  506. +   if (tp->tty_inhibited == TRUE)
  507. +       return(0);
  508.     vducursor(0);
  509.     do {
  510. !       if (tp->tty_inhibited == TRUE) 
  511. !       {
  512. !       vducursor(1);
  513. !       return(0);
  514. !       }
  515. !       vduput(*((char *)tp->tty_phys));
  516.                   /* write 1 byte to terminal */
  517. !       tp->tty_phys++;        /* advance physical data pointer */
  518. !       tp->tty_cum++;        /* number of characters printed */
  519.     } while (--tp->tty_outleft != 0);
  520.     vducursor(1);
  521.     return(1);
  522. ***************
  523. *** 190,196 ****
  524. --- 194,204 ----
  525.       return;
  526.     case 012: /* LF */
  527.       if (mode & CRMOD)
  528. + #if 0
  529.           vduput('\r');
  530. + #else
  531. +             moveto(v->crow, 0);
  532. + #endif
  533.     case 013: /* VT */
  534.     case 014: /* FF */
  535.       if (v->crow == v->nrow - 1) {
  536. ***************
  537. *** 480,487 ****
  538. --- 488,499 ----
  539.     if (c >= '0' && c <= '9') {
  540.       i = 0;
  541.       do {
  542. + #if 0
  543.           i *= 10;
  544.           i += (c - '0');
  545. + #else
  546. +         i = (((i << 2) + i) << 1) + (c - '0');
  547. + #endif        
  548.           c = *v->next++;
  549.       } while (c >= '0' && c <= '9');
  550.     }
  551. ***************
  552. *** 508,519 ****
  553.     src = (long*)&v->vram[r1 * v->bytr];
  554.     dst = (long*)&v->vram[r2 * v->bytr];
  555.     i = v->bytr >> 4;    /* 16 bytes per iteration */
  556. !   while (--i >= 0) {
  557.       *dst++ = *src++;
  558.       *dst++ = *src++;
  559.       *dst++ = *src++;
  560.       *dst++ = *src++;
  561. !   }
  562.   }
  563.   
  564.   /*
  565. --- 520,531 ----
  566.     src = (long*)&v->vram[r1 * v->bytr];
  567.     dst = (long*)&v->vram[r2 * v->bytr];
  568.     i = v->bytr >> 4;    /* 16 bytes per iteration */
  569. !   do {
  570.       *dst++ = *src++;
  571.       *dst++ = *src++;
  572.       *dst++ = *src++;
  573.       *dst++ = *src++;
  574. !   } while(--i > 0);
  575.   }
  576.   
  577.   /*
  578. ***************
  579. *** 594,605 ****
  580.   
  581.     p = (long*)&v->vram[r * v->bytr];
  582.     i = v->bytr >> 4;    /* 16 bytes per iteration */
  583. !   while (--i >= 0) {
  584.       *p++ = 0L;
  585.       *p++ = 0L;
  586.       *p++ = 0L;
  587.       *p++ = 0L;
  588. !   }
  589.   }
  590.   
  591.   /*
  592. --- 606,617 ----
  593.   
  594.     p = (long*)&v->vram[r * v->bytr];
  595.     i = v->bytr >> 4;    /* 16 bytes per iteration */
  596. !   do {
  597.       *p++ = 0L;
  598.       *p++ = 0L;
  599.       *p++ = 0L;
  600.       *p++ = 0L;
  601. !   }   while (--i > 0) ;
  602.   }
  603.   
  604.   /*
  605. ***************
  606. *** 644,655 ****
  607. --- 656,699 ----
  608.   {
  609.     register struct vduinfo *v = &vduinfo;
  610.   
  611. + #ifdef NO_AUTOWRAP
  612.     if (r < 0 || r >= v->nrow || c < 0 || c > NCOL)
  613. + #else
  614. +   if (r < 0 || r >= v->nrow || c > NCOL)
  615. + #endif
  616.       return;
  617. + #ifndef NO_AUTOWRAP
  618. +   if (c < 0)        /* wrap backwards to previous line */
  619. +   {
  620. +       if(r == 0)
  621. +       moveto(0, 0);
  622. +       else
  623. +       moveto(r - 1, NCOL - 1);
  624. +       return;
  625. +   }
  626. + #endif
  627. +   
  628.     v->crow = r;
  629.     v->ccol = c;
  630.     if (c == NCOL)
  631. + #ifdef NO_AUTOWRAP
  632.       c--;            /* show cursor in last column */
  633. + #else
  634. +   {
  635. +     v->ccol = c = 0;        /* auto wrap */
  636. +     if(r == v->nrow - 1)
  637. +     {
  638. +     register int i;
  639. +     for (i = 0; i < r; i++)
  640. +         cpyline(i + 1, i);
  641. +     clrline(i);
  642. +     } else
  643. +     v->crow = ++r;
  644. +     v->curs = &v->vram[(r * v->bytr)];
  645. +     return;
  646. +   }
  647. + #endif
  648.   
  649.     if (!v->mono) {        /* 0->0, 1->1, 2->4, 3->5, 4->8, ... */
  650.       c <<= 1;
  651. *** /tmp/,RCSt1a27031    Thu Aug 24 00:02:11 1989
  652. --- stwini.c    Thu Aug 17 00:50:55 1989
  653. ***************
  654. *** 111,116 ****
  655. --- 111,119 ----
  656.   
  657.   /* Parameters for the disk drive. */
  658.   #define SECTOR_SIZE    512    /* physical sector size in bytes */
  659. + #define SECTOR_MASK    (SECTOR_SIZE - 1) /* mask for modulus */
  660. + #define SECTOR_SHIFT    9    /* 2^SECTOR_SHIFT == SECTOR_SIZE */
  661.   #define NR_DRIVES    8    /* maximum number of drives */
  662.   #define    MAX_MINOR    (NR_DRIVES<<3)
  663.   #define MAX_ERRORS    10    /* how often to try rd/wt before quitting */
  664. ***************
  665. *** 144,150 ****
  666.    *===========================================================================*/
  667.   PUBLIC void winchester_task()
  668.   {
  669. !   register    r, drive, minor, caller, procno;
  670.     long offset;    
  671.   
  672.    /*
  673. --- 147,154 ----
  674.    *===========================================================================*/
  675.   PUBLIC void winchester_task()
  676.   {
  677. !   register int    r, drive, minor, caller, procno;
  678. !   register struct pi *p;
  679.     long offset;    
  680.   
  681.    /*
  682. ***************
  683. *** 158,186 ****
  684.       minor = drive << 3;
  685.   
  686.   /* virtual drive 0 == physical drive */
  687.       /* read sector 0 of the drive and copy the partition info */
  688. !     pi[minor].pi_size = 1;
  689.       dmagrab(WINCHESTER, hdcint);
  690.       r = do_xfer(drive, (phys_bytes)&hi, 0L, 1, DISK_READ);
  691.       dmafree(WINCHESTER);
  692.       if (r != OK) {
  693. !         pi[minor].pi_size = 0;
  694.           continue;
  695.       }
  696. !     for (r = 0, minor++; r < NPARTS; r++, minor++) {
  697. !         pi[minor] = hi.hd_pi[r];
  698. !         if (pi[minor].pi_flag == PI_INVALID)
  699. !             pi[minor].pi_size = 0;
  700. !         if( pi[minor].pi_size )
  701. !             offset = pi[minor].pi_start + pi[minor].pi_size ;
  702.       }
  703.   /* partition 7 is the whole physical disk */
  704. !     pi[minor+2].pi_size = hi.hd_size;
  705.   #if HCJ_PARTITION
  706.   /* change partition 5 to be the whole physical disk */
  707.   /* but if a virtual drive is found, this is changed to the virtual size */
  708. !     pi[minor].pi_size = hi.hd_size;
  709. !     minor += 2;
  710.   
  711.       if(drive == 0 && pi[3].pi_size > 512) {
  712.           pi[3].pi_size -= 512;
  713. --- 162,191 ----
  714.       minor = drive << 3;
  715.   
  716.   /* virtual drive 0 == physical drive */
  717.       /* read sector 0 of the drive and copy the partition info */
  718. !     p = &pi[minor];
  719. !     p->pi_size = 1;
  720.       dmagrab(WINCHESTER, hdcint);
  721.       r = do_xfer(drive, (phys_bytes)&hi, 0L, 1, DISK_READ);
  722.       dmafree(WINCHESTER);
  723.       if (r != OK) {
  724. !         p->pi_size = 0;
  725.           continue;
  726.       }
  727. !     for (r = 0, p++; r < NPARTS; r++, p++) {
  728. !         *p = hi.hd_pi[r];
  729. !         if (p->pi_flag == PI_INVALID)
  730. !             p->pi_size = 0;
  731. !         if( p->pi_size )
  732. !             offset = p->pi_start + p->pi_size ;
  733.       }
  734.   /* partition 7 is the whole physical disk */
  735. !     (p+2)->pi_size = hi.hd_size;
  736.   #if HCJ_PARTITION
  737.   /* change partition 5 to be the whole physical disk */
  738.   /* but if a virtual drive is found, this is changed to the virtual size */
  739. !     p->pi_size = hi.hd_size;
  740.   
  741.       if(drive == 0 && pi[3].pi_size > 512) {
  742.           pi[3].pi_size -= 512;
  743. ***************
  744. *** 188,194 ****
  745.           pi[6].pi_start = pi[3].pi_start + pi[3].pi_size;
  746.       }
  747.   /* virtual drive 1 */
  748. !     minor = (drive+1) << 3;
  749.       if ( hi.bsl_start != 0L ) {
  750.   printf("Drive %d, virtual omitted: bsl_start=%lx offset=%lx \n",
  751.    DRIVE(drive),hi.bsl_start,offset);
  752. --- 193,199 ----
  753.           pi[6].pi_start = pi[3].pi_start + pi[3].pi_size;
  754.       }
  755.   /* virtual drive 1 */
  756. !     p = &pi[((drive+1) << 3)];
  757.       if ( hi.bsl_start != 0L ) {
  758.   printf("Drive %d, virtual omitted: bsl_start=%lx offset=%lx \n",
  759.    DRIVE(drive),hi.bsl_start,offset);
  760. ***************
  761. *** 197,220 ****
  762.       if(offset > hi.hd_size)
  763.           continue;
  764.       /* read sector 0 of the (virtual) drive and copy the partition info */
  765. !     pi[minor].pi_start = offset;
  766. !     pi[minor].pi_size = 1;
  767.       dmagrab(WINCHESTER, hdcint);
  768.       r = do_xfer(drive, (phys_bytes)&hi, offset, 1, DISK_READ);
  769.       dmafree(WINCHESTER);
  770.       if (r != OK) {
  771. !         pi[minor].pi_size = 0;
  772.           continue;
  773.       }
  774. !     for (r = 0, minor++; r < NPARTS; r++, minor++) {
  775. !         pi[minor] = hi.hd_pi[r];
  776. !         pi[minor].pi_start += offset;
  777. !         if (pi[minor].pi_flag == PI_INVALID)
  778. !             pi[minor].pi_size = 0;
  779.       }
  780.   /* set up partition 5 as whole virtual disk */
  781. !     pi[minor].pi_start = offset;
  782. !     pi[minor].pi_size = hi.hd_size - offset +1;
  783.   
  784.   /* change 'real' disk (virtural 0) to have only its own size in part. 5 */
  785.       pi[(drive<<3)+5].pi_size = offset;
  786. --- 202,225 ----
  787.       if(offset > hi.hd_size)
  788.           continue;
  789.       /* read sector 0 of the (virtual) drive and copy the partition info */
  790. !     p->pi_start = offset;
  791. !     p->pi_size = 1;
  792.       dmagrab(WINCHESTER, hdcint);
  793.       r = do_xfer(drive, (phys_bytes)&hi, offset, 1, DISK_READ);
  794.       dmafree(WINCHESTER);
  795.       if (r != OK) {
  796. !         p->pi_size = 0;
  797.           continue;
  798.       }
  799. !     for (r = 0, p++; r < NPARTS; r++, p++) {
  800. !         *p = hi.hd_pi[r];
  801. !         p->pi_start += offset;
  802. !         if (p->pi_flag == PI_INVALID)
  803. !             p->pi_size = 0;
  804.       }
  805.   /* set up partition 5 as whole virtual disk */
  806. !     p->pi_start = offset;
  807. !     p->pi_size = hi.hd_size - offset +1;
  808.   
  809.   /* change 'real' disk (virtural 0) to have only its own size in part. 5 */
  810.       pi[(drive<<3)+5].pi_size = offset;
  811. ***************
  812. *** 227,243 ****
  813.    * The next physical drive is hd16, with hd16-hd24, and hd24-hd31 
  814.    * the same as hd0-hd7 and hd8-hd15. Etc., for each addl drive.
  815.    */
  816. !     for (r = 0, minor=((drive+1) << 3); r < 8; r++, minor++) {
  817. !         pi[minor] = hi.hd_supra[r];
  818. !                 if (pi[minor].pi_flag == PI_INVALID)
  819. !             pi[minor].pi_size = 0;
  820.   /*
  821.    * HCJ: this is an added test of sanity:
  822.    * start and end of partition must be < hd_size 
  823.    */
  824. !         if (pi[minor].pi_start >= hi.hd_size || /* start is too big */
  825. !             pi[minor].pi_start + pi[minor].pi_size -1 >= hi.hd_size)
  826. !             pi[minor].pi_size = 0;
  827.       }
  828.   #endif
  829.                   
  830. --- 232,248 ----
  831.    * The next physical drive is hd16, with hd16-hd24, and hd24-hd31 
  832.    * the same as hd0-hd7 and hd8-hd15. Etc., for each addl drive.
  833.    */
  834. !     for (r = 0,p= &pi[((drive+1) << 3)]; r < 8; r++, p++) {
  835. !         *p = hi.hd_supra[r];
  836. !                 if (pi->pi_flag == PI_INVALID)
  837. !             p->pi_size = 0;
  838.   /*
  839.    * HCJ: this is an added test of sanity:
  840.    * start and end of partition must be < hd_size 
  841.    */
  842. !         if (p->pi_start >= hi.hd_size || /* start is too big */
  843. !             p->pi_start + p->pi_size -1 >= hi.hd_size)
  844. !             p->pi_size = 0;
  845.       }
  846.   #endif
  847.                   
  848. ***************
  849. *** 292,298 ****
  850.   register message *mp;
  851.   {
  852.     register struct proc    *rp;
  853. !   register        r, errors, count, rw, drive, minor;
  854.     register long        secnum;
  855.     register phys_bytes    address;
  856.     extern phys_bytes    umap(struct proc *, int, long, long);
  857. --- 297,304 ----
  858.   register message *mp;
  859.   {
  860.     register struct proc    *rp;
  861. !   register int        r, errors, count, rw, drive, minor;
  862. !   register struct pi    *p;
  863.     register long        secnum;
  864.     register phys_bytes    address;
  865.     extern phys_bytes    umap(struct proc *, int, long, long);
  866. ***************
  867. *** 302,327 ****
  868.     drive = minor >> 3;
  869.     if (drive < 0 || drive >= NR_DRIVES)
  870.       return(EIO);
  871. !   if (pi[minor].pi_size == 0)
  872.       return(EIO);
  873. !   if ((mp->POSITION % SECTOR_SIZE) != 0)
  874.       return(EINVAL);
  875. !   secnum = (long)(mp->POSITION / SECTOR_SIZE);
  876.     count = mp->COUNT;
  877. !   if ((count % SECTOR_SIZE) != 0)
  878.       return(EINVAL);
  879.     rp = proc_addr(mp->PROC_NR);
  880.     address = umap(rp, D, (vir_bytes) mp->ADDRESS, (vir_bytes) count);
  881.     if (address == 0)
  882.       return(EINVAL);
  883. !   count /= SECTOR_SIZE;
  884.     TRACE(printf("hd%d: %s: sec=%D; cnt=%d\n",
  885.       minor, rw == DISK_READ ? "read" : "write", secnum, count));
  886. !   if (pi[minor].pi_size - secnum < count)
  887. !     count = pi[minor].pi_size - secnum;
  888.     if (count <= 0)
  889.       return(EOF);
  890. !   secnum += pi[minor].pi_start;
  891.     rp->p_physio = 1;        /* disable (un)shadowing */
  892.     dmagrab(WINCHESTER, hdcint);
  893.     /* This loop allows a failed operation to be repeated. */
  894. --- 308,335 ----
  895.     drive = minor >> 3;
  896.     if (drive < 0 || drive >= NR_DRIVES)
  897.       return(EIO);
  898. !   p = &pi[minor];
  899. !   if (p->pi_size == 0)
  900.       return(EIO);
  901. !   if ((mp->POSITION & SECTOR_MASK) != 0)
  902.       return(EINVAL);
  903. !   secnum = (long)(mp->POSITION >> SECTOR_SHIFT);
  904.     count = mp->COUNT;
  905. !   if ((count & SECTOR_MASK) != 0)
  906.       return(EINVAL);
  907.     rp = proc_addr(mp->PROC_NR);
  908.     address = umap(rp, D, (vir_bytes) mp->ADDRESS, (vir_bytes) count);
  909.     if (address == 0)
  910.       return(EINVAL);
  911. !   count >>= SECTOR_SHIFT;
  912.     TRACE(printf("hd%d: %s: sec=%D; cnt=%d\n",
  913.       minor, rw == DISK_READ ? "read" : "write", secnum, count));
  914. !   if (p->pi_size - secnum < count)
  915. !     count = p->pi_size - secnum;
  916.     if (count <= 0)
  917.       return(EOF);
  918. !   secnum += p->pi_start;
  919.     rp->p_physio = 1;        /* disable (un)shadowing */
  920.     dmagrab(WINCHESTER, hdcint);
  921.     /* This loop allows a failed operation to be repeated. */
  922. ***************
  923. *** 334,340 ****
  924.     rp->p_physio = 0;        /* enable (un)shadowing */
  925.     if (r != OK)
  926.       return(EIO);
  927. !   return(count * SECTOR_SIZE);
  928.   }
  929.   
  930.   
  931. --- 342,348 ----
  932.     rp->p_physio = 0;        /* enable (un)shadowing */
  933.     if (r != OK)
  934.       return(EIO);
  935. !   return(count << SECTOR_SHIFT);
  936.   }
  937.   
  938.   
  939. *** /tmp/,RCSt1a27031    Thu Aug 24 00:02:14 1989
  940. --- system.c    Thu Aug 17 02:06:43 1989
  941. ***************
  942. *** 761,767 ****
  943.   }
  944.   
  945.   #ifdef ATARI_ST
  946. ! #if 0
  947.   /*===========================================================================*
  948.    *                phys_copy                     * 
  949.    *===========================================================================*/
  950. --- 761,767 ----
  951.   }
  952.   
  953.   #ifdef ATARI_ST
  954. ! #if 0 /* see copy68k.cpp */
  955.   /*===========================================================================*
  956.    *                phys_copy                     * 
  957.    *===========================================================================*/
  958. ***************
  959. *** 807,813 ****
  960.     }
  961.   }
  962.   
  963. ! #endif
  964.   
  965.   /*===========================================================================*
  966.    *                build_sig                     * 
  967. --- 807,813 ----
  968.     }
  969.   }
  970.   
  971. ! #endif /* see copy68k.cpp */
  972.   
  973.   /*===========================================================================*
  974.    *                build_sig                     * 
  975.