

{IncludeFrom=iodeclarations <p2c/iodecl.h>}


{*VarStrings=0} {*ExportSymbol=P_%s} {*Export_Symbol=%s}


MODULE IODECLARATIONS;
IMPORT  sysglobals;

EXPORT

   CONST
      iominisc   = 0 ;
      iomaxisc   = 31;
      minrealisc = 7 ;
      maxrealisc = 31;

      io_line_feed    = CHR(10);
      io_carriage_rtn = CHR(13);

      ioescapecode    =  -26;

      ioe_no_error    = 0;
      ioe_no_card     = 1;
      ioe_not_hpib    = 2;
      ioe_not_act     = 3;
      ioe_not_dvc     = 4;
      ioe_no_space    = 5;
      ioe_no_data     = 6;
      ioe_bad_tfr     = 7;
      ioe_isc_busy    = 8;
      ioe_buf_busy    = 9;
      ioe_bad_cnt     = 10;
      ioe_bad_tmo     = 11;
      ioe_no_driver   = 12;
      ioe_no_dma      = 13;
      ioe_no_word     = 14;
      ioe_not_talk    = 15;
      ioe_not_lstn    = 16;
      ioe_timeout     = 17;
      ioe_not_sctl    = 18;
      ioe_rds_wtc     = 19;
      ioe_bad_sct     = 20;
      ioe_crd_dwn     = 21;
      ioe_eod_seen    = 22;
      ioe_misc        = 23;

      ioe_sr_toomany  = 304;
      ioe_dc_fail     = 306;
      ioe_dc_usart    = 313;
      ioe_dc_ovfl     = 314;
      ioe_dc_clk      = 315;
      ioe_dc_cts      = 316;
      ioe_dc_car      = 317;
      ioe_dc_act      = 318;
      ioe_dc_conn     = 319;
      ioe_dc_conf     = 325;
      ioe_dc_reg      = 326;
      ioe_dc_rval     = 327;
      ioe_sr_fail     = 353;

      no_isc          = 255;

      gtl_message     = CHR( 1  );
      sdc_message     = CHR( 4  );
      ppc_message     = CHR( 5  );
      get_message     = CHR( 8  );
      tct_message     = CHR( 9  );
      llo_message     = CHR( 17 );
      dcl_message     = CHR( 20 );
      ppu_message     = CHR( 21 );
      spe_message     = CHR( 24 );
      spd_message     = CHR( 25 );
      unl_message     = CHR( 63 );
      unt_message     = CHR( 95 );
      ppe_message     = CHR( 96 );
      ppd_message     = CHR(112 );

      talk_constant   = 64;
      listen_constant = 32;

      no_card         = 0 ;
      other_card      = 1 ;

      system_card     = 2 ;
      hpib_card       = 3 ;
      gpio_card       = 4 ;
      serial_card     = 5 ;
      graphics_card   = 6 ;
      srm_card        = 7 ;
      bubble_card     = 8 ;
      eprom_prgmr     = 9 ;

      hp98628_dsndl   = -7;
      hp98629         = -6;
      hp_datacomm     = -5;
      hp98620         = -4;
      internal_kbd    = -3;
      internal_crt    = -2;
      internal_hpib   = -1;

      no_id           =  0;

      hp98624         =  1;
      hp98626         =  2;

      hp98622         =  3;
      hp98623         =  4;
      hp98625         =  8;
      hp98628_async   = 20;
      hpGATOR         = 25;
      hp98253         = 27;
      hp98627         = 28;
      hp98259         = 30;
      hp98644         = 66;



   TYPE
      type_isc        = iominisc..iomaxisc ;
      type_device     = iominisc..iomaxisc*100+99;
      io_bit          = 0..15 ;
      io_byte         = 0..255 ;
      io_word         = -32768..32767 ;
      io_string       =
      STRING[255];
      io_proc_type    = PROCEDURE;
      errlnk_type     = PROCEDURE ( errorcode : INTEGER ; VAR s     : io_string );

      type_of_card    = io_word;
      type_card_id    = io_word;




      type_hpib_addr  = 0..31 ;
      type_hpib_line  = ( ren_line ,
                          ifc_line ,
                          srq_line ,
                          eoi_line ,
                          nrfd_line ,
                          ndac_line ,
                          dav_line ,
                          atn_line
                        ) ;




      type_parity     = ( no_parity ,
                          odd_parity ,
                          even_parity ,
                          zero_parity ,
                          one_parity
                        );
      type_serial_line= ( rts_line ,
                          cts_line ,
                          dcd_line ,
                          dsr_line ,
                          drs_line ,
                          ri_line  ,

                          dtr_line
                        );



      io_proc         = PROCEDURE ( temp  : ANYPTR );
      io_proc_c       = PROCEDURE ( temp  : ANYPTR; v     : CHAR );
      io_proc_vc      = PROCEDURE ( temp  : ANYPTR; VAR v : CHAR);
      io_proc_w       = PROCEDURE ( temp  : ANYPTR; v     : io_word );
      io_proc_vw      = PROCEDURE ( temp  : ANYPTR; VAR v : io_word );
      io_proc_s       = PROCEDURE ( temp  : ANYPTR; reg   : io_word ;
                                    v     : io_word );
      io_proc_vs      = PROCEDURE ( temp  : ANYPTR; reg   : io_word ;
                                    VAR v : io_word );
      io_proc_l       = PROCEDURE ( temp  : ANYPTR; line  : io_bit );
      io_proc_vl      = PROCEDURE ( temp  : ANYPTR; line  : io_bit ;
                                    VAR v : BOOLEAN );
      io_proc_vb      = PROCEDURE ( temp  : ANYPTR; VAR v : BOOLEAN );
      io_proc_ptr     = PROCEDURE ( temp  : ANYPTR; v     : ANYPTR );

      drv_table_type  = RECORD
                           iod_init  : io_proc ;
                           iod_isr   : ISRPROCTYPE ;
                           iod_rdb   : io_proc_vc ;
                           iod_wtb   : io_proc_c ;
                           iod_rdw   : io_proc_vw ;
                           iod_wtw   : io_proc_w ;
                           iod_rds   : io_proc_vs ;
                           iod_wtc   : io_proc_s ;
                           iod_end   : io_proc_vb ;
                           iod_tfr   : io_proc_ptr ;
                           iod_send  : io_proc_c;
                           iod_ppoll : io_proc_vc ;
                           iod_set   : io_proc_l ;
                           iod_clr   : io_proc_l ;
                           iod_test  : io_proc_vl ;
                        END;



      io_funny_proc   = RECORD
                           CASE BOOLEAN OF
                              TRUE: ( real_proc : io_proc );
                              FALSE: ( dummy_pr  : ANYPTR ; dummy_sl  : ANYPTR )
                        END;

      io_temp_type    = PACKED RECORD
                           myisrib   : ISRIB ;
                           user_isr  : io_funny_proc;
                           user_parm : ANYPTR ;
                           card_addr : ANYPTR ;
                           in_bufptr : ANYPTR ;
                           out_bufptr: ANYPTR ;
                           eirbyte   : CHAR ;
                           my_isc    : io_byte ;
                           timeout   : INTEGER ;
                           addressed : io_word ;
                           drv_misc  : ARRAY[1..32] OF CHAR ;
                        END;

      io_temp_type2   = PACKED RECORD
                           myisrib   : ISRIB ;
                           user_isr  : io_funny_proc;
                           user_parm : ANYPTR ;
                           card_addr : ANYPTR ;
                           in_bufptr : ANYPTR ;
                           out_bufptr: ANYPTR ;
                           eirbyte   : CHAR ;
                           my_isc    : io_byte ;
                           timeout   : INTEGER ;
                           addressed : io_word ;
                           drv_misc  : ARRAY[1..128] OF CHAR ;
                        END;

      io_temp_type3   = PACKED RECORD
                           myisrib   : ISRIB ;
                           user_isr  : io_funny_proc;
                           user_parm : ANYPTR ;
                           card_addr : ANYPTR ;
                           in_bufptr : ANYPTR ;
                           out_bufptr: ANYPTR ;
                           eirbyte   : CHAR ;
                           my_isc    : io_byte ;
                           timeout   : INTEGER ;
                           addressed : io_word ;
                           drv_misc  : ARRAY[1..160] OF CHAR ;
                        END;

      io_temp_type4   = PACKED RECORD
                           myisrib   : ISRIB ;
                           user_isr  : io_funny_proc;
                           user_parm : ANYPTR ;
                           card_addr : ANYPTR ;
                           in_bufptr : ANYPTR ;
                           out_bufptr: ANYPTR ;
                           eirbyte   : CHAR ;
                           my_isc    : io_byte ;
                           timeout   : INTEGER ;
                           addressed : io_word ;
                           drv_misc  : ARRAY[1..164] OF CHAR ;
                        END;


      pio_tmp_ptr     = ^io_temp_type;


      isc_table_type  = RECORD
                           io_drv_ptr: ^drv_table_type;
                           io_tmp_ptr: pio_tmp_ptr;
                           card_type : type_of_card;
                           user_time : INTEGER;
                           card_id   : type_card_id;
                           card_ptr  : ANYPTR;
                        END;



      user_tfr_type   = ( dummy_tfr_1 ,
                          serial_DMA ,
                          serial_FHS ,
                          serial_FASTEST ,
                          dummy_tfr_2 ,
                          overlap_INTR ,
                          overlap_DMA ,
                          overlap_FHS ,
                          overlap_FASTEST ,
                          OVERLAP ) ;
                          actual_tfr_type = ( no_tfr ,
                          INTR_tfr ,
                          DMA_tfr ,
                          BURST_tfr ,
                          FHS_tfr
                        ) ;
      dir_of_tfr      = ( to_memory,
                          from_memory
                        ) ;

      buf_type        = PACKED ARRAY[0..maxint] OF CHAR;

      buf_info_type   = RECORD
                           drv_tmp_ptr : pio_tmp_ptr;
                           active_isc  : io_byte;
                           act_tfr     : actual_tfr_type ;
                           usr_tfr     : user_tfr_type ;
                           b_w_mode    : BOOLEAN ;
                           end_mode    : BOOLEAN ;
                           direction   : dir_of_tfr ;
                           term_char   : -1..255 ;
                           term_count  : INTEGER ;
                           buf_ptr     : ^buf_type ;
                           buf_size    : INTEGER ;
                           buf_empty   : ANYPTR ;
                           buf_fill    : ANYPTR ;
                           eot_proc    : io_funny_proc;
                           eot_parm    : ANYPTR ;
                           dma_priority: BOOLEAN;
                        END;

   VAR
      dma_ch_0        : io_funny_proc ;
      dma_isc_0       : io_byte ;
      dma_ch_1        : io_funny_proc ;
      dma_isc_1       : io_byte ;
      dma_isrib0      : ISRIB ;
      dma_isrib1      : ISRIB ;
      dma_here        : BOOLEAN;

      io_work_char    : CHAR;

      ioe_result      : INTEGER;
      ioe_isc         : INTEGER;

      isc_table       : PACKED ARRAY [type_isc]
      OF isc_table_type;

      io_revid        : STRING[96];

      io_error_link   : errlnk_type;

   PROCEDURE io_escape   ( my_code    : INTEGER ; select_code: INTEGER);
   FUNCTION  io_find_isc ( iod_temp   : ANYPTR ): io_byte;
END.

