$SYSPROG ON$
(***************************************************************)
(*                                                             *)
(*                                                             *)
(*      IOLIB           example drivers                        *)
(*                                                             *)
(*                                                             *)
(***************************************************************)
(*                                                             *)
(*                                                             *)
(*      library      -  IOLIB                                  *)
(*      name         -  DUMMY                                  *)
(*      module(s)    -  extd                                   *)
(*                   -  init_dummy                             *)
(*                   -  dummy_initialize                       *)
(*                                                             *)
(*      date         -  July 21 , 1982                         *)
(*      update       -  July 21 , 1982                         *)
(*                                                             *)
(***************************************************************)

PROGRAM dummy_initialize (INPUT , OUTPUT);
        { This module has a program segment so that there is
          an executable entry point into the module.
          At INITLIB time this program is executed. }

MODULE extd;
IMPORT  sysglobals , iodeclarations ;  
EXPORT
  PROCEDURE ed_init  (temp : ANYPTR);
  PROCEDURE ed_rdb   (temp : ANYPTR ;  VAR x : CHAR);
  PROCEDURE ed_wtb   (temp : ANYPTR ;  val   : CHAR);
  PROCEDURE ed_send  (temp : ANYPTR ;  val   : CHAR);
IMPLEMENT

  PROCEDURE ed_init  (temp : ANYPTR);
  BEGIN
    WRITELN('INITIALIZATION  on ',io_find_isc(temp):4);
  END;
  
  PROCEDURE ed_rdb   (temp : ANYPTR ;  VAR x : CHAR);
  BEGIN
    WRITELN('READ CHARACTER  on ',io_find_isc(temp):4);
    READ(x);
  END;
  
  PROCEDURE ed_wtb   (temp : ANYPTR ;  val   : CHAR);
  BEGIN
    WRITELN('WRITE CHARACTER on ',io_find_isc(temp):4);
    WRITE(val);
  END;
  
  PROCEDURE ed_send  (temp : ANYPTR ;  val   : CHAR);
  BEGIN
    WRITELN('SEND COMMAND    on ',io_find_isc(temp):4,
            ' of command ',ORD(val):3);
  END;
END; { of extd }


MODULE init_dummy ; { This module initializes the HPIB drivers. }
IMPORT    sysglobals , isr , general_0 , extd, iodeclarations ;  
EXPORT
  CONST dummy_id    = -100;
        dummy_type  =  100;
  VAR my_dummy_drivers  : drv_table_type;
  PROCEDURE io_init_dummy;
IMPLEMENT
  
  PROCEDURE io_init_dummy;
  VAR io_isc        : type_isc;
      dummy         : INTEGER;
      io_lvl        : io_byte;
  BEGIN
    io_revid := io_revid + ' DUMMY1.0';     { io_revid indicates 
                                              what version of the 
                                              drivers are in the 
                                              system.  }
    { set up the driver tables }
    WITH my_dummy_drivers DO BEGIN
      my_dummy_drivers := dummy_drivers;    { sets up the table 
                                              with all dummy 
                                              entries }
      iod_init  := ed_init;
      iod_rdb   := ed_rdb;
      iod_wtb   := ed_wtb;
      iod_send  := ed_send;
    END; { of WITH }
    
    { set up drivers for the interfaces }
    FOR io_isc:=iominisc TO iomaxisc DO 
      WITH isc_table[io_isc] DO BEGIN
        IF (card_id = no_id) 
          THEN BEGIN
            card_id := dummy_id;                { put in my id }
            card_type := dummy_type;            { put in my type }
            io_drv_ptr:=ADDR(my_dummy_drivers);
            { link in an ISR here if it is necessary }
          END; { of IF card_id }
      END; { of FOR io_isc WITH isc_table[io_isc] BEGIN }
    
    { call the actual driver initialization }
    { this is separate from the set up code in case
      there are 2 or more cards connected - and generate
      an isr between each other }
    FOR io_isc:=iominisc TO iomaxisc DO 
      WITH isc_table[io_isc] DO 
      IF (card_id = dummy_id)
        THEN BEGIN
          CALL(io_drv_ptr^.iod_init , io_tmp_ptr);
        END; { of WITH IF }
  END; { of io_init_dummy }
END; { of MODULE init_dummy }


IMPORT    init_dummy ;  
BEGIN
  io_init_dummy;
END. { of dummy_initialize }
