head     56.3;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @# @;


56.3
date     93.01.27.13.37.36;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.13.01;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.43.14;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.21.26;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.25.37;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.26.47;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.10.46;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.10.20;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.25.10;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.09.29;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.15.31;  author jwh;  state Exp;
branches ;
next     47.1;

47.1
date     90.05.14.10.57.23;  author dew;  state Exp;
branches ;
next     46.1;

46.1
date     90.05.07.08.44.32;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.15.52.13;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.09.36;  author jwh;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.14.01.00;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.45.35;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.28.24;  author jwh;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.11.50.26;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.34.47;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.26.24;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.38.58;  author dew;  state Exp;
branches ;
next     36.1;

36.1
date     89.02.06.10.17.29;  author dew;  state Exp;
branches ;
next     35.1;

35.1
date     89.02.02.13.31.33;  author dew;  state Exp;
branches ;
next     34.1;

34.1
date     89.01.23.16.06.46;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.39.27;  author dew;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.47.16;  author bayes;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.08.31;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.45.47;  author dew;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.30.27;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.10.58.03;  author dew;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.29.22;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.13.10.32;  author bayes;  state Exp;
branches ;
next     25.1;

25.1
date     88.03.02.09.26.53;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.09.46.07;  author jws;  state Exp;
branches ;
next     23.1;

23.1
date     87.08.26.10.23.10;  author bayes;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.11.08.30;  author bayes;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.13.51.40;  author bayes;  state Exp;
branches ;
next     20.1;

20.1
date     87.07.30.11.05.01;  author bayes;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.20.43;  author jws;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.15.17.04;  author bayes;  state Exp;
branches ;
next     17.1;

17.1
date     87.04.30.10.31.30;  author jws;  state Exp;
branches ;
next     16.1;

16.1
date     87.04.26.15.44.07;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.09.18.10;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.15.21.50;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.29.48;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.20.13;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.09.46.19;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.10.54.02;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.14.33.46;  author bayes;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.11.51.45;  author jws;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.13.41.38;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.17.53.14;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.16.41.57;  author hal;  state Exp;
branches ;
next     4.1;

4.1
date     86.09.30.19.42.57;  author hal;  state Exp;
branches ;
next     3.2;

3.2
date     86.09.03.10.04.31;  author hal;  state Exp;
branches ;
next     3.1;

3.1
date     86.09.01.11.53.53;  author hal;  state Exp;
branches ;
next     2.1;

2.1
date     86.07.30.14.39.48;  author hal;  state Exp;
branches ;
next     1.1;

1.1
date     86.06.30.14.51.16;  author danm;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@					       (*

 (c) Copyright Hewlett-Packard Company, 1984,1985,1986.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)

$sysprog$
$stackcheck off$ $heap_dispose off$
$iocheck off$ $range off$ $ovflcheck off$
$debug off$

program loopinit;

module hphil; { HP Human Interface Loop }

import a804xdvr,sysdevs,sysglobals,asm;

export
  FUNCTION INITLOOP:BOOLEAN;     {4/6/84 SFB}

implement
const
  readctrl = hex('FB'); { 8042 COMMANDS }
  writectrl= hex('EB');
  startcmd = hex('E0');
  readbusy = hex('02');
  trigger  = hex('C5');


type
  stat5datatype = packed record { data bye with status 5 }
		    case integer of
		    0     :(b:byte);
		    1     :(lerror  : boolean;          {7}
			    padding : 0..3;          {6..5}
			    polling : boolean;          {4}
			    command : boolean;          {3}
			    devaddr : 0..7);         {2..0}
		  end;

  lpctrltype = packed record    { loop control byte }
		 case boolean of
		 true :(b:byte);
		 false:(doreconfigure: boolean;
			pad6,pad5    : boolean;
			cookkbd      : boolean;
			pad3         : boolean;
			noreconfig   : boolean;
			noerrs       : boolean;
			doautopoll   : boolean )
	       end;

  var
  oldstatus5isr : kbdhooktype;
  oldclrio      : procedure;

  procedure dummydataproc(var statbyte,databyte:byte; var done:boolean);
  begin end;
  procedure dummyopsproc(op:loopdvrop);
  begin end;

  procedure lcommand;
  const
    timeout20= hex('FE');
  begin
    WITH LOOPCONTROL^ DO        {4/6/84 SFB}
     if loopisok or loopinconfig then
     begin
       sendcmd(startcmd);
       senddata(8+loopdevice);   { command & address }
       senddata(loopcmd);        { id command }
       senddata(timeout20);      { 20 milli secs }
       loopcmddone:=false; looperror:=false;
       sendcmd(trigger);
       repeat call(kbdpollhook,true);
       until loopcmddone or looperror;
     end
     else looperror:=true;
  end;  { lcommand }

  { status6 isr for describe operation }
  procedure describedata(var statbyte,databyte:byte; var done:boolean);
  begin { load describe record for the current loop device }
   WITH LOOPCONTROL^ DO                 {4/10/84 SFB}
    with loopdevices[loopdevice] do     {4/6/84 SFB}
    case devstate of
    1: begin descrip.darray[1]:=chr(databyte); devstate:=2; end;
    2: begin
	 descrip.darray[2]:=chr(databyte);      { header byte }
	 if descrip.numaxes>0 then devstate:=3
			      else devstate:=11;
       end;                                     { low order count }
    3: begin descrip.darray[4]:=chr(databyte); devstate:=4; end;
    4: begin
	 descrip.darray[3]:=chr(databyte);      { high order count }
	 if descrip.abscoords then devstate:=5
			      else devstate:=11;
       end;
    5..10:begin { swap even / odd bytes }
	    descrip.darray[devstate-1+(ord(odd(devstate))*2)]:=chr(databyte);
	    devstate:=devstate+1 {+ord(not descrip.size16)}; {bugfix SFB 4/4/85}
	    if (devstate>6) and (descrip.numaxes=1) then devstate:=11
	    else
	    if (devstate>8) and (descrip.numaxes=2) then devstate:=11;
	  end;
    11: begin   { prompts & buttons }
	  if descrip.hasprompts then descrip.darray[11]:=chr(databyte);
	  devstate:=12;
	end;
    otherwise
    end; { case devstate }
  end;  { describedata }


  procedure rawshift;    { change 8042 to raw mode }
  var
    oldpriority : integer;
    ctrlreg     : lpctrltype;
    tempstuff   : byte;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    if not rawmode then
    begin
      oldpriority:=intlevel;    { lock out interupts }
      setintlevel(7);
      cmd_read_1(readctrl,tempstuff); ctrlreg.b:=tempstuff;

      ctrlreg.doautopoll:=false;
      ctrlreg.noerrs:=true;
      ctrlreg.noreconfig:=false;
      sendcmd(writectrl);
      senddata(ord(ctrlreg.b));

      repeat  { wait for polling to stop }
	cmd_read_1(readbusy,loopdata);
      until not odd(loopdata div 4);
      rawmode:=true;
      setintlevel(oldpriority); { restore interupts }
    end;
  end;  { rawshift }

  procedure normshift; { change 8042 to normal mode }
  var
    oldpriority : integer;
    ctrlreg     : lpctrltype;
    tempstuff   : byte;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    if rawmode then
    begin
      oldpriority:=intlevel;    { lock out interupts }
      setintlevel(7);
      cmd_read_1(readctrl,tempstuff); ctrlreg.b:=tempstuff;
      ctrlreg.doautopoll:=true;
      ctrlreg.noerrs:=true;
      ctrlreg.noreconfig:=false;

      sendcmd(writectrl); senddata(ord(ctrlreg.b)); { start auto polling }

      rawmode := false;
      setintlevel(oldpriority);
    end;
  end;  { normshift }

  procedure describe;   { issue describe for loopdevice }
  const
    idcmd    = hex('03');

  var
    oldpriority : integer;
    i           : 1..11;
  begin { describe }
   oldpriority := intlevel;    { lockout interupts }
   setintlevel(7);
   status6hook:=describedata;
   WITH LOOPCONTROL^ DO          {4/10/84 SFB}
    with loopdevices[loopdevice] do
     begin
      devstate:=1;
      opsproc:=dummyopsproc;
      dataproc:=dummydataproc;
      for i:=1 to 11 do descrip.darray[i]:=chr(0); { clear the record }
      loopcmd:=idcmd;
      lcommand; { send the command and wait for it to finish }
     end;
   status6hook:=dummydataproc;
   setintlevel(oldpriority);
  end; { describe }

  procedure checkloop;
  const
    readlstat = hex('FA');
  var
    oldpriority : integer;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    BEGIN
     loopisok:=false;
     LOOPDATA := 0;             {4/24/84 SFB }
     oldpriority:=intlevel;    { lock out interupts }
     setintlevel(7);
     cmd_read_1(readlstat,loopdata);
     loopisok:=loopdata<128;
     setintlevel(oldpriority);
    END;                        {4/6/84 SFB}
  end;  { checkloop }

  procedure configure;
  label 1;
  CONST
    READ_INTR_MASK = 4; { SFB 3/5/84 }
  var
    temp    : loopdvrptr;
    i       : shortint;
    OLDMASK : BYTE;     { SFB 3/5/84 }
  begin { configure }
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    BEGIN
     CMD_READ_1(READ_INTR_MASK,OLDMASK);{ SAVE OLD 804X MASK - SFB 3/5/84 }
     CALL(MASKOPSHOOK,KBDMASK,0);      { ENABLE LOOP - SFB 3/5/84 }
     loopdevreading:=false;            { 3.0 BUG #39  3/17/84 }
     checkloop;
     if not loopisok then goto 1;
     rawshift;
     loopinconfig:=true;
     { get device description for all (7) devices }
     for i:=1 to 7 do
     begin
       loopdevice:=i;
       with loopdevices[loopdevice] do   {SFB 4/8/85}
	  call(opsproc,uninitdevice);    { tell driver to uninitialize }
       describe;
       if looperror then goto 1; { kick out & wait for status5, le_configured }
     end;

     { find and attach drivers to devices }
     for i:=1 to 7 do
     begin
       loopdevice:=i;
       temp:=loopdriverlist;
       while temp<>nil do
       with loopdevices[loopdevice] do
       begin
	 if (temp^.daddr=0) or (temp^.daddr=loopdevice) then
	   if (descrip.id>=temp^.lowid) and (descrip.id<=temp^.highid) then
	   begin   { hook up the driver }
	     opsproc:=temp^.opsproc;
	     dataproc:=temp^.dataproc;
	     call(opsproc,resetdevice);    { tell driver to reset }
	     temp:=nil;    { cancel the search }
	   end
	   else temp:=temp^.next
	 else temp:=temp^.next;    { 3.0 BUG FIX  4/6/84 }
       end; { while .. with }
     end;   { for }

   1:loopinconfig:=false;
     normshift;
     IF ODD(OLDMASK) THEN
      CALL(MASKOPSHOOK,0,KBDMASK);      { DISABLE LOOP IF IT WAS PREVIOUSLY
					  OFF - SFB 3/5/84 }
   END;                         {4/6/84 SFB}
  end;  { configure }

  procedure resettheloop; { cleario call }
   begin
    configure; call(oldclrio);
  end;

  procedure endcmdproc(var statbyte,databyte:byte; var done:boolean);
  begin
    WITH LOOPCONTROL^ DO        {4/6/84 SFB}
     BEGIN
      loopcmddone := true; status6hook:=dummydataproc;
      loopdata    := databyte;
     END;
  end;

  PROCEDURE SENDHPHILCMD(OP : HPHILOP);         {4/9/84 SFB}
  BEGIN
   CASE OP OF
    RAWSHIFTOP  : RAWSHIFT;
    NORMSHIFTOP : NORMSHIFT;
    CHECKLOOPOP : CHECKLOOP;
    CONFIGUREOP : CONFIGURE;
    LCOMMANDOP  : LCOMMAND;
   END;
  END;

  procedure status5isr(var statbyte,databyte:byte; var done:boolean);
  var status : stat5datatype;
  begin
   status.b:=databyte;
   WITH LOOPCONTROL^ DO        {4/6/84 SFB}
    if status.lerror then
     begin
      looperror:=true;
      status6hook:=dummydataproc;
      if status.b=le_loopdown then
       loopisok:=false
      else
       if status.b=le_configured then
	begin     { loop has been reconfigured }
	 call(oldstatus5isr,statbyte,databyte,done); { let keyboard proc know }
	 if not loopinconfig then configure;
	 loopdevreading:=false;              { 3.0 bug #39   3/17/84 }
	end;
     end
    else
     if status.command then
      begin
       if status.polling then    { end of polled data }
	begin
	 status6hook:=dummydataproc;     { ignore next data }
	 call(loopdevices[loopdevice].opsproc,dataended);
	 loopdevreading:=false;                { 3.0 bug #39  3/17/84 }
	end
       else
	begin     { command ending }
	 status6hook:=endcmdproc;
	end;
      end
     else
      if status.polling then
       begin       { polling data starting }
	{ check if device now reading        3.0 bug #39   3/17/84}
	if loopdevreading then                           {3.0 bug #39 3/17/84}
	 call(loopdevices[loopdevice].opsproc, dataended){3.0 bug #39 3/17/84}
	else                                             {3.0 bug #39 3/17/84}
	  loopdevreading:=true;                          {3.0 bug #39 3/17/84}
	loopdevice:=status.devaddr;
	status6hook:=loopdevices[loopdevice].dataproc;
	call(loopdevices[loopdevice].opsproc,datastarting);
       end
      else
       begin       { data starting for current command }
	looperror:= loopdevice<>status.devaddr;
       end;
  end;  { status5isr }

  function initloop:boolean;
  var dev : 1..lmaxdevices;       {4/9/85 SFB}
  begin
    IF LOOPCONTROL = NIL THEN     {4/9/84 SFB}
     BEGIN
      NEW(LOOPCONTROL);           {4/9/84 SFB}
      WITH LOOPCONTROL^ DO        {4/6/84 SFB}
       BEGIN
	for dev := 1 to lmaxdevices do {4/9/85 SFB}
	    loopdevices[dev].opsproc := dummyopsproc;
	initloop:=false;
	rawmode :=false;
	loopisok :=false;

	if HIL_PRESENT then                 { 6/18/86 JWS }
	 begin
	  oldstatus5isr:=status5hook;       { save old hook }
	  status5hook:=status5isr;
	  status6hook:=dummydataproc;
	  oldclrio   :=cleariohook;         { save old hook }
	  cleariohook:=resettheloop;
	  HPHILCMDHOOK:=SENDHPHILCMD;     {4/9/84 SFB}
	  configure;
	  initloop := true;
	 end;
       END;     {WITH LOOPCONTROL^}
     END        {IF LOOPCONTROL = NIL}
    ELSE
     BEGIN                        {4/9/84 SFB}
      CONFIGURE;                  {IF INITLOOP ALREADY DONE JUST CONFIGURE}
      INITLOOP := FALSE;          {DON'T MARKUSER}
     END;
  end;  { initloop }

end;    { loopinterface  module }

import hphil, loader;

begin
  if initloop then markuser;
end.

@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 396
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 396
					       (*

 (c) Copyright Hewlett-Packard Company, 1984,1985,1986.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)

$sysprog$
$stackcheck off$ $heap_dispose off$
$iocheck off$ $range off$ $ovflcheck off$
$debug off$

program loopinit;

module hphil; { HP Human Interface Loop }

import a804xdvr,sysdevs,sysglobals,asm;

export
  FUNCTION INITLOOP:BOOLEAN;     {4/6/84 SFB}

implement
const
  readctrl = hex('FB'); { 8042 COMMANDS }
  writectrl= hex('EB');
  startcmd = hex('E0');
  readbusy = hex('02');
  trigger  = hex('C5');


type
  stat5datatype = packed record { data bye with status 5 }
		    case integer of
		    0     :(b:byte);
		    1     :(lerror  : boolean;          {7}
			    padding : 0..3;          {6..5}
			    polling : boolean;          {4}
			    command : boolean;          {3}
			    devaddr : 0..7);         {2..0}
		  end;

  lpctrltype = packed record    { loop control byte }
		 case boolean of
		 true :(b:byte);
		 false:(doreconfigure: boolean;
			pad6,pad5    : boolean;
			cookkbd      : boolean;
			pad3         : boolean;
			noreconfig   : boolean;
			noerrs       : boolean;
			doautopoll   : boolean )
	       end;

  var
  oldstatus5isr : kbdhooktype;
  oldclrio      : procedure;

  procedure dummydataproc(var statbyte,databyte:byte; var done:boolean);
  begin end;
  procedure dummyopsproc(op:loopdvrop);
  begin end;

  procedure lcommand;
  const
    timeout20= hex('FE');
  begin
    WITH LOOPCONTROL^ DO        {4/6/84 SFB}
     if loopisok or loopinconfig then
     begin
       sendcmd(startcmd);
       senddata(8+loopdevice);   { command & address }
       senddata(loopcmd);        { id command }
       senddata(timeout20);      { 20 milli secs }
       loopcmddone:=false; looperror:=false;
       sendcmd(trigger);
       repeat call(kbdpollhook,true);
       until loopcmddone or looperror;
     end
     else looperror:=true;
  end;  { lcommand }

  { status6 isr for describe operation }
  procedure describedata(var statbyte,databyte:byte; var done:boolean);
  begin { load describe record for the current loop device }
   WITH LOOPCONTROL^ DO                 {4/10/84 SFB}
    with loopdevices[loopdevice] do     {4/6/84 SFB}
    case devstate of
    1: begin descrip.darray[1]:=chr(databyte); devstate:=2; end;
    2: begin
	 descrip.darray[2]:=chr(databyte);      { header byte }
	 if descrip.numaxes>0 then devstate:=3
			      else devstate:=11;
       end;                                     { low order count }
    3: begin descrip.darray[4]:=chr(databyte); devstate:=4; end;
    4: begin
	 descrip.darray[3]:=chr(databyte);      { high order count }
	 if descrip.abscoords then devstate:=5
			      else devstate:=11;
       end;
    5..10:begin { swap even / odd bytes }
	    descrip.darray[devstate-1+(ord(odd(devstate))*2)]:=chr(databyte);
	    devstate:=devstate+1 {+ord(not descrip.size16)}; {bugfix SFB 4/4/85}
	    if (devstate>6) and (descrip.numaxes=1) then devstate:=11
	    else
	    if (devstate>8) and (descrip.numaxes=2) then devstate:=11;
	  end;
    11: begin   { prompts & buttons }
	  if descrip.hasprompts then descrip.darray[11]:=chr(databyte);
	  devstate:=12;
	end;
    otherwise
    end; { case devstate }
  end;  { describedata }


  procedure rawshift;    { change 8042 to raw mode }
  var
    oldpriority : integer;
    ctrlreg     : lpctrltype;
    tempstuff   : byte;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    if not rawmode then
    begin
      oldpriority:=intlevel;    { lock out interupts }
      setintlevel(7);
      cmd_read_1(readctrl,tempstuff); ctrlreg.b:=tempstuff;

      ctrlreg.doautopoll:=false;
      ctrlreg.noerrs:=true;
      ctrlreg.noreconfig:=false;
      sendcmd(writectrl);
      senddata(ord(ctrlreg.b));

      repeat  { wait for polling to stop }
	cmd_read_1(readbusy,loopdata);
      until not odd(loopdata div 4);
      rawmode:=true;
      setintlevel(oldpriority); { restore interupts }
    end;
  end;  { rawshift }

  procedure normshift; { change 8042 to normal mode }
  var
    oldpriority : integer;
    ctrlreg     : lpctrltype;
    tempstuff   : byte;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    if rawmode then
    begin
      oldpriority:=intlevel;    { lock out interupts }
      setintlevel(7);
      cmd_read_1(readctrl,tempstuff); ctrlreg.b:=tempstuff;
      ctrlreg.doautopoll:=true;
      ctrlreg.noerrs:=true;
      ctrlreg.noreconfig:=false;

      sendcmd(writectrl); senddata(ord(ctrlreg.b)); { start auto polling }

      rawmode := false;
      setintlevel(oldpriority);
    end;
  end;  { normshift }

  procedure describe;   { issue describe for loopdevice }
  const
    idcmd    = hex('03');

  var
    oldpriority : integer;
    i           : 1..11;
  begin { describe }
   oldpriority := intlevel;    { lockout interupts }
   setintlevel(7);
   status6hook:=describedata;
   WITH LOOPCONTROL^ DO          {4/10/84 SFB}
    with loopdevices[loopdevice] do
     begin
      devstate:=1;
      opsproc:=dummyopsproc;
      dataproc:=dummydataproc;
      for i:=1 to 11 do descrip.darray[i]:=chr(0); { clear the record }
      loopcmd:=idcmd;
      lcommand; { send the command and wait for it to finish }
     end;
   status6hook:=dummydataproc;
   setintlevel(oldpriority);
  end; { describe }

  procedure checkloop;
  const
    readlstat = hex('FA');
  var
    oldpriority : integer;
  begin
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    BEGIN
     loopisok:=false;
     LOOPDATA := 0;             {4/24/84 SFB }
     oldpriority:=intlevel;    { lock out interupts }
     setintlevel(7);
     cmd_read_1(readlstat,loopdata);
     loopisok:=loopdata<128;
     setintlevel(oldpriority);
    END;                        {4/6/84 SFB}
  end;  { checkloop }

  procedure configure;
  label 1;
  CONST
    READ_INTR_MASK = 4; { SFB 3/5/84 }
  var
    temp    : loopdvrptr;
    i       : shortint;
    OLDMASK : BYTE;     { SFB 3/5/84 }
  begin { configure }
   WITH LOOPCONTROL^ DO         {4/6/84 SFB}
    BEGIN
     CMD_READ_1(READ_INTR_MASK,OLDMASK);{ SAVE OLD 804X MASK - SFB 3/5/84 }
     CALL(MASKOPSHOOK,KBDMASK,0);      { ENABLE LOOP - SFB 3/5/84 }
     loopdevreading:=false;            { 3.0 BUG #39  3/17/84 }
     checkloop;
     if not loopisok then goto 1;
     rawshift;
     loopinconfig:=true;
     { get device description for all (7) devices }
     for i:=1 to 7 do
     begin
       loopdevice:=i;
       with loopdevices[loopdevice] do   {SFB 4/8/85}
	  call(opsproc,uninitdevice);    { tell driver to uninitialize }
       describe;
       if looperror then goto 1; { kick out & wait for status5, le_configured }
     end;

     { find and attach drivers to devices }
     for i:=1 to 7 do
     begin
       loopdevice:=i;
       temp:=loopdriverlist;
       while temp<>nil do
       with loopdevices[loopdevice] do
       begin
	 if (temp^.daddr=0) or (temp^.daddr=loopdevice) then
	   if (descrip.id>=temp^.lowid) and (descrip.id<=temp^.highid) then
	   begin   { hook up the driver }
	     opsproc:=temp^.opsproc;
	     dataproc:=temp^.dataproc;
	     call(opsproc,resetdevice);    { tell driver to reset }
	     temp:=nil;    { cancel the search }
	   end
	   else temp:=temp^.next
	 else temp:=temp^.next;    { 3.0 BUG FIX  4/6/84 }
       end; { while .. with }
     end;   { for }

   1:loopinconfig:=false;
     normshift;
     IF ODD(OLDMASK) THEN
      CALL(MASKOPSHOOK,0,KBDMASK);      { DISABLE LOOP IF IT WAS PREVIOUSLY
					  OFF - SFB 3/5/84 }
   END;                         {4/6/84 SFB}
  end;  { configure }

  procedure resettheloop; { cleario call }
   begin
    configure; call(oldclrio);
  end;

  procedure endcmdproc(var statbyte,databyte:byte; var done:boolean);
  begin
    WITH LOOPCONTROL^ DO        {4/6/84 SFB}
     BEGIN
      loopcmddone := true; status6hook:=dummydataproc;
      loopdata    := databyte;
     END;
  end;

  PROCEDURE SENDHPHILCMD(OP : HPHILOP);         {4/9/84 SFB}
  BEGIN
   CASE OP OF
    RAWSHIFTOP  : RAWSHIFT;
    NORMSHIFTOP : NORMSHIFT;
    CHECKLOOPOP : CHECKLOOP;
    CONFIGUREOP : CONFIGURE;
    LCOMMANDOP  : LCOMMAND;
   END;
  END;

  procedure status5isr(var statbyte,databyte:byte; var done:boolean);
  var status : stat5datatype;
  begin
   status.b:=databyte;
   WITH LOOPCONTROL^ DO        {4/6/84 SFB}
    if status.lerror then
     begin
      looperror:=true;
      status6hook:=dummydataproc;
      if status.b=le_loopdown then
       loopisok:=false
      else
       if status.b=le_configured then
	begin     { loop has been reconfigured }
	 call(oldstatus5isr,statbyte,databyte,done); { let keyboard proc know }
	 if not loopinconfig then configure;
	 loopdevreading:=false;              { 3.0 bug #39   3/17/84 }
	end;
     end
    else
     if status.command then
      begin
       if status.polling then    { end of polled data }
	begin
	 status6hook:=dummydataproc;     { ignore next data }
	 call(loopdevices[loopdevice].opsproc,dataended);
	 loopdevreading:=false;                { 3.0 bug #39  3/17/84 }
	end
       else
	begin     { command ending }
	 status6hook:=endcmdproc;
	end;
      end
     else
      if status.polling then
       begin       { polling data starting }
	{ check if device now reading        3.0 bug #39   3/17/84}
	if loopdevreading then                           {3.0 bug #39 3/17/84}
	 call(loopdevices[loopdevice].opsproc, dataended){3.0 bug #39 3/17/84}
	else                                             {3.0 bug #39 3/17/84}
	  loopdevreading:=true;                          {3.0 bug #39 3/17/84}
	loopdevice:=status.devaddr;
	status6hook:=loopdevices[loopdevice].dataproc;
	call(loopdevices[loopdevice].opsproc,datastarting);
       end
      else
       begin       { data starting for current command }
	looperror:= loopdevice<>status.devaddr;
       end;
  end;  { status5isr }

  function initloop:boolean;
  var dev : 1..lmaxdevices;       {4/9/85 SFB}
  begin
    IF LOOPCONTROL = NIL THEN     {4/9/84 SFB}
     BEGIN
      NEW(LOOPCONTROL);           {4/9/84 SFB}
      WITH LOOPCONTROL^ DO        {4/6/84 SFB}
       BEGIN
	for dev := 1 to lmaxdevices do {4/9/85 SFB}
	    loopdevices[dev].opsproc := dummyopsproc;
	initloop:=false;
	rawmode :=false;
	loopisok :=false;

	if HIL_PRESENT then                 { 6/18/86 JWS }
	 begin
	  oldstatus5isr:=status5hook;       { save old hook }
	  status5hook:=status5isr;
	  status6hook:=dummydataproc;
	  oldclrio   :=cleariohook;         { save old hook }
	  cleariohook:=resettheloop;
	  HPHILCMDHOOK:=SENDHPHILCMD;     {4/9/84 SFB}
	  configure;
	  initloop := true;
	 end;
       END;     {WITH LOOPCONTROL^}
     END        {IF LOOPCONTROL = NIL}
    ELSE
     BEGIN                        {4/9/84 SFB}
      CONFIGURE;                  {IF INITLOOP ALREADY DONE JUST CONFIGURE}
      INITLOOP := FALSE;          {DON'T MARKUSER}
     END;
  end;  { initloop }

end;    { loopinterface  module }

import hphil, loader;

begin
  if initloop then markuser;
end.

@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@@


50.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@@


47.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


46.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@@


40.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


39.1
log
@Automatic bump of revision number for PWS version 3.23b
@
text
@@


38.1
log
@Automatic bump of revision number for PWS version 3.23a
@
text
@@


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


36.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


35.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


34.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


33.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@@


32.1
log
@Automatic bump of revision number for PWS version 3.22C
@
text
@@


31.1
log
@Automatic bump of revision number for PWS version 3.22B
@
text
@@


30.1
log
@Automatic bump of revision number for PWS version 3.22A
@
text
@@


29.1
log
@Automatic bump of revision number for PWS version 3.22b
@
text
@@


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@@


25.1
log
@Automatic bump of revision number for PWS version 3.2Y
@
text
@@


24.1
log
@Automatic bump of revision number for PWS version 3.2
@
text
@@


23.1
log
@Automatic bump of revision number for PWS version 3.2P
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@@


19.1
log
@Automatic bump of revision number for PWS version 3.2K
@
text
@@


18.1
log
@Automatic bump of revision number for PWS version 3.2J
@
text
@@


17.1
log
@Automatic bump of revision number for PWS version 3.2I+
@
text
@@


16.1
log
@Automatic bump of revision number for PWS version 3.2I
@
text
@@


15.1
log
@Automatic bump of revision number for PWS version 3.2H
@
text
@@


14.1
log
@Automatic bump of revision number for PWS version 3.2G
@
text
@@


13.1
log
@Automatic bump of revision number for PWS version 3.2F
@
text
@@


12.1
log
@Automatic bump of revision number for PWS version 3.2E
@
text
@@


11.1
log
@Automatic bump of revision number for PWS version 3.2D
@
text
@@


10.1
log
@Automatic bump of revision number for PWS version 3.2C
@
text
@@


9.1
log
@Automatic bump of revision number for PWS version 3.2B
@
text
@@


8.1
log
@Automatic bump of revision number for PWS version 3.2A
@
text
@@


7.1
log
@Automatic bump of revision number for PWS version 3.2l
@
text
@@


6.1
log
@Automatic bump of revision number for PWS version 3.2k
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@@


3.2
log
@Changes sent by Scott Bayes and John Schmidt.
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@d3 1
a3 1
 (c) Copyright Hewlett-Packard Company, 1984.
d369 1
a369 1
	if kbdtype=itfkbd then
@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@@


1.1
log
@Initial revision
@
text
@@
